LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-28-2015, 01:07 AM   #1
lazardo
Member
 
Registered: Feb 2010
Location: SD Bay Area
Posts: 274

Rep: Reputation: Disabled
thinning packages


Ah, finally got around to that.

Patch at #7 to change reported sizes from MB to KB

Code:
#!/bin/bash

# thinner
# sorts installed slackware packages by actual size

ASCDEC="-nr"			# largest first

case "$1" in
	-h|--help)
		echo "use: thinner [-r]" >> /dev/stderr
		exit
		;;
	-r)
		ASCDEC="-n"	# smallest first
		;;
	*)
esac


awk '
BEGIN{
	printf "%6s %-50s %s\n",
		"MB", "Package name", "Description" >> "/dev/stderr"
};

/^PACKAGE NAME/{
	name=$3
	next
};
/^UNCOMPRESSED/{
	len=length($4)
	size=substr($4,1,len-1)
	if(substr($4,len) == "K"){ size/=1024 }
	next
};
/^PACKAGE DESC/{
	getline
	printf "%6.1f %-50s %s\n",
		size, name, substr($0,length($1)+2)
}' /var/log/packages/* | sort $ASCDEC -k1,2

Last edited by lazardo; 02-07-2015 at 10:01 PM. Reason: pointer to patch below
 
Old 01-28-2015, 05:01 AM   #2
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
I usually do something like this:

Code:
grep -x 'U.*M' /var/log/packages/* | sed 's,.*/\(.*\):U.*: *\(.*\),\2\t\1,' | sort -n
Though your addition of descriptions is nice.

P.S. I would sort the other way around.
 
2 members found this post helpful.
Old 01-28-2015, 05:30 AM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,062

Rep: Reputation: Disabled
@ruario: nice one liner, but neglects packages whose uncompressed size is less than 1M. But I assume that those are intentionally put aside

Last edited by Didier Spaier; 01-28-2015 at 05:31 AM.
 
Old 01-28-2015, 05:38 AM   #4
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Yeah it does miss the smallest packages, but that would make things more complex. Additionally you need to delete a lot of packages that are under 1M to make space savings. IMHO, it is almost never worth it.

As you know I am generally in favour of a more complete install. However I do occasionally need something smaller. Some people favour the start small and build up approach. I favour the stripping back approach and the first thing I look at (after excluding complete package sets) is the size of the packages. The one liner really helps.

I actually wrote a short post on my blog about this method: http://ruario.ghost.io/2014/12/19/se...kware-install/ (though I use awk in that example, rather than sed).
 
Old 01-28-2015, 06:51 AM   #5
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,062

Rep: Reputation: Disabled
Thanks for sharing Ruarí, I've added a reference to your blog post to this post.
 
Old 01-28-2015, 07:04 AM   #6
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
@lazardo: Sorry I didn't mean to take over your post. Your script is better in that it also includes descriptions and I have just realised that you do allow reversing the order with "-r". Maybe host it on https://gist.github.com or somewhere so that it can be easily referenced, forked, etc.

Last edited by ruario; 01-28-2015 at 07:06 AM.
 
Old 02-03-2015, 11:56 AM   #7
lazardo
Member
 
Registered: Feb 2010
Location: SD Bay Area
Posts: 274

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ruario View Post
@lazardo: Sorry I didn't mean to take over your post. Your script is better in that it also includes descriptions and I have just realised that you do allow reversing the order with "-r". Maybe host it on https://gist.github.com or somewhere so that it can be easily referenced, forked, etc.
No worries. I build mostly focused task servers (digital image processing, backup management, distcc, automation) and prefer simple/clean installs, plus even now I don't always recognize function from just the package name.

The aggregate size of <1M packages is only about 10% of the >1M group, but there are twice as many.

As for github, that would make me a 'maintainer'. Besides, it is already perfect save for this one patch:

Patch to change reported sizes from MB to KB

Code:
--- thinner	2015-02-03 09:38:20.150660150 -0800
+++ thinnerMB	2015-02-03 09:44:55.801649495 -0800
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# thinner
+# thinnerMB
 # sorts installed slackware packages by actual size
 
 ASCDEC="-nr"			# largest first
@@ -19,7 +19,7 @@
 
 awk '
 BEGIN{
-	printf "%6s %-50s %s\n",
+	printf "%7s %-50s %s\n",
 		"MB", "Package name", "Description" >> "/dev/stderr"
 };
 
@@ -30,11 +30,11 @@
 /^UNCOMPRESSED/{
 	len=length($4)
 	size=substr($4,1,len-1)
-	if(substr($4,len) == "K"){ size/=1024 }
+	if(substr($4,len) == "M"){ size*=1024 }
 	next
 };
 /^PACKAGE DESC/{
 	getline
-	printf "%6.1f %-50s %s\n",
+	printf "%7d %-50s %s\n",
 		size, name, substr($0,length($1)+2)
 }' /var/log/packages/* | sort $ASCDEC -k1,2

Last edited by lazardo; 02-07-2015 at 09:59 PM. Reason: description of patch
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apt/dpkg: How do I segregate user application packages from system packages? boxyzzy Ubuntu 2 12-03-2010 11:04 AM
LXer: Minimalist computing - thinning the herd (having nothing whatsoever to do with the Hurd) LXer Syndicated Linux News 0 11-10-2010 05:30 AM
Installation of packages in RHEL-5.3 using X windows menu Add/Remove packages akluthra Linux - Newbie 2 09-21-2010 05:34 AM
Thinning? Frank Soranno Slackware 6 10-20-2006 01:46 PM
Thinning the Herd synaptical General 1 10-14-2003 08:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration