LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-20-2016, 12:36 PM   #1
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,473
Blog Entries: 2

Rep: Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981
Lightbulb installation trimming helper (low space? which package to remove?)


Ever tried to squeeze fit a installation to a small medium?

I wanted to maintain a install on a 32GB SD card (don't ask ) and had to prune any package not absolutely essential to productivity.

Again and again.

I ended up with this script, to stop wading the history of bash.

path:~/bin/
filename: wg
Code:
#!/bin/sh
#
# (GPL) cest73@ya.ru
#
echo "wg stands for Which Goes ?"
echo "list (20?) largesst installed packages"
echo "usage : "
echo -ne "  wg [how many] [regep filter]\n\n"

N=${1:-20}
shift
G=${@:-.}

grep "UNCOMPRESSED " /var/log/packages/* \
	| grep $G \
	| sed -e s/"\/.*\/"/":"/g \
	| awk -F: '{print $4 " / " $2}' \
	| sort -b -h -r \
	| head -n $N
typical usage:

Code:
$ wg
wg stands for Which Goes ?
list (20?) largesst installed packages
usage : 
  wg [how many] [regep filter]

     625M / kernel-source-4.4.19-noarch-1_slack14.2
     614M / libreoffice-5.2.0-x86_64-1alien
     453M / wine-1.9.15-x86_64-1alien
     351M / jdk-8u102-x86_64-1_SBo
     327M / llvm-3.8.0-x86_64-2
     269M / llvm-compat32-3.8.0-x86_64-2compat32
     244M / xulrunner-41.0.2-x86_64-2_slonly
     233M / glibc-i18n-2.23_multilib-x86_64-1alien
     227M / Arduino-1.6.9-x86_64-1_slonly
     226M / astromenace-1.3.2-x86_64-3_slonly
     182M / mariadb-10.0.26-x86_64-1
     160M / seamonkey-2.40-x86_64-1
     160M / kernel-firmware-20160823git-noarch-1_slack14.2
     159M / mariadb-compat32-10.0.26-x86_64-1compat32
     156M / tetex-3.0-x86_64-10
     141M / kernel-modules-4.4.19-x86_64-1_slack14.2
     136M / gcc-java-5.3.0_multilib-x86_64-3alien
     131M / gcc-go-5.3.0_multilib-x86_64-3alien
     130M / qt-4.8.7-x86_64-4
     128M / qt-compat32-4.8.7-x86_64-4compat32
special usage:
Code:
$ wg 10 compat
wg stands for Which Goes ?
list (20?) largesst installed packages
usage : 
  wg [how many] [regep filter]

     269M / llvm-compat32-3.8.0-x86_64-2compat32
     159M / mariadb-compat32-10.0.26-x86_64-1compat32
     128M / qt-compat32-4.8.7-x86_64-4compat32
     65M / TeamSpeak3-compat32-3.0.19.4-x86_64-1_SBocompat32
     46M / samba-compat32-4.4.5-x86_64-1_slack14.2compat32
     43M / mesa-compat32-11.2.2-x86_64-1compat32
     29M / icu4c-compat32-56.1-x86_64-2compat32
     18M / aaa_elflibs-compat32-14.2-x86_64-23compat32
     12M / fftw-compat32-3.3.4-x86_64-1compat32
     10M / sane-compat32-1.0.25-x86_64-2compat32
or
Code:
$ wg 10 SBo
wg stands for Which Goes ?
list (20?) largesst installed packages
usage : 
  wg [how many] [regep filter]

     351M / jdk-8u102-x86_64-1_SBo
     101M / inkscape-0.91-x86_64-1_SBo
     66M / moka-icon-theme-5.3.2-noarch-1_SBo
     66M / TeamSpeak3-3.0.19.4-x86_64-1_SBo
     65M / TeamSpeak3-compat32-3.0.19.4-x86_64-1_SBocompat32
     55M / GeoIP-1.6.9-x86_64-1_SBo
     36M / linphone-3.9.1-x86_64-1_SBo
     26M / frozen-bubble-905bf71-x86_64-2_SBo
     25M / fontforge-20150824-x86_64-1_SBo
     23M / avidemux-2.6.12-x86_64-1_SBo
Practical use is to quickly locate the main space-hogs and deal with them

Last edited by SCerovec; 10-20-2016 at 12:37 PM. Reason: no rainbow :-J
 
Old 10-20-2016, 01:32 PM   #2
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Great idea! I don't know if I would've thought of that, even though I sort by installed size on both Windows and my Android phone frequently. I just never thought to do it with Slackware. However, I would suggest changing the echo statement to only display when someone asks. I think I would end up finding it annoying to have it echoed every time.

Something like the following would allow for normal expectations from the commandline (obviously formatting it to your liking). It would take wg with either -h or --help and display the echo statement. Then if it detects anything else, it assumes it is the rest of the command and proceeds accordingly. You could also throw in a quick check for a second argument, and if it doesn't exist, you could display the help too.

Code:
#!/bin/sh
#
# (GPL) cest73@ya.ru
#

help()
{
  echo "wg stands for Which Goes ?"
  echo "list (20?) largesst installed packages"
  echo "usage : "
  echo -ne "  wg [how many] [regep filter]\n\n"
}

doit()
{
  N=${N:-20}
  shift
  G=${G:-.}

  grep "UNCOMPRESSED " /var/log/packages/* \
	| grep $G \
	| sed -e s/"\/.*\/"/":"/g \
	| awk -F: '{print $4 " / " $2}' \
	| sort -b -h -r \
	| head -n $N
}

case "$1" in
  -h|--help)
     help ;;
  *) 
     N=$1
     G=$2
     doit ;;
esac
EDIT: Got home and once I tried it, I found it didn't pass the arguments through the case statement (not really sure why, but there's probably an easy way to fix it...), so instead I just set the N and G variables in the case statement itself.

One other suggestion after using it a bit... it might be nice to just specify the term and use the default number (20). That way, you could just type wg alien and have it spit out the top 20 alien packages instead of wg 20 alien. I would probably reverse the "[how many] [regep filter]" options... but that's just me.

If you feel I'm overstepping my bounds with these suggestions (and adding the case statement), please let me know. I'm sorry if that is the case. Feel free to let me know you're not interested in making any or all of my changes and I'll just modify a local copy

Last edited by bassmadrigal; 10-20-2016 at 04:34 PM.
 
Old 10-20-2016, 01:51 PM   #3
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
This is basically what my darkstar-packsize does, but it actually computes the package size based on the files found on the system. Early incarnations of it was a shell script not unlike yours, but I found the UNCOMPRESSED SIZE was often misleadingly large, since I can't help myself to not remove "useless" files, such as locale, icons, gtk-docs, info-pages... I'm sorting the other way though, but that's nothing `tac` can't fix..
Code:
$ darkstar-packsize -L20 | tac
236M	nvidia-driver-367.57-x86_64-1_llt
202M	chromium-53.0.2785.92-x86_64-3_llt
167M	kernel-firmware-20160823git-noarch-1_slack14.2
163M	texlive-20161013-x86_64-1_llt
163M	vivaldi-1.5.638.3.1-x86_64-1_llt
150M	wine-1.8.4-i686-1_llt
94.4M	avr-gcc-4.9.2-x86_64-1_SBo
87.3M	wireshark-2.2.1-x86_64-1_llt
81.7M	font-nonlatin-ttf-20130521-noarch-2_llt
75.8M	valgrind-3.11.0-x86_64-1_SBo
68.2M	python-2.7.11-x86_64-2
64.5M	gcc-5.3.0-x86_64-3
60.5M	ghostscript-9.19-x86_64-2
59.1M	samba-4.4.5-x86_64-1_slack14.2
53.6M	perl-5.22.2-x86_64-1
51.3M	failsafe-4.4.14-x86_64-4_llt
42.7M	linux-modules-4.4.25-x86_64-1_llt
42.5M	cmake-3.5.2-x86_64-1
40.6M	octave-4.0.3-x86_64-3_llt
37.7M	gcc-g++-5.3.0-x86_64-3

Last edited by e5150; 10-20-2016 at 01:55 PM.
 
Old 10-21-2016, 03:06 AM   #4
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,473

Original Poster
Blog Entries: 2

Rep: Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981
Thumbs up

Quote:
Originally Posted by bassmadrigal View Post
Great idea! I don't know if I would've thought of that, even though I sort by installed size on both Windows and my Android phone frequently. I just never thought to do it with Slackware. However, I would suggest changing the echo statement to only display when someone asks. I think I would end up finding it annoying to have it echoed every time.

Something like the following would allow for normal expectations from the commandline (obviously formatting it to your liking). It would take wg with either -h or --help and display the echo statement. Then if it detects anything else, it assumes it is the rest of the command and proceeds accordingly. You could also throw in a quick check for a second argument, and if it doesn't exist, you could display the help too.

Code:
#!/bin/sh
#
# (GPL) cest73@ya.ru
#

help()
{
  echo "wg stands for Which Goes ?"
  echo "list (20?) largesst installed packages"
  echo "usage : "
  echo -ne "  wg [how many] [regep filter]\n\n"
}

doit()
{
  N=${N:-20}
  shift
  G=${G:-.}

  grep "UNCOMPRESSED " /var/log/packages/* \
	| grep $G \
	| sed -e s/"\/.*\/"/":"/g \
	| awk -F: '{print $4 " / " $2}' \
	| sort -b -h -r \
	| head -n $N
}

case "$1" in
  -h|--help)
     help ;;
  *) 
     N=$1
     G=$2
     doit ;;
esac
EDIT: Got home and once I tried it, I found it didn't pass the arguments through the case statement (not really sure why, but there's probably an easy way to fix it...), so instead I just set the N and G variables in the case statement itself.

One other suggestion after using it a bit... it might be nice to just specify the term and use the default number (20). That way, you could just type wg alien and have it spit out the top 20 alien packages instead of wg 20 alien. I would probably reverse the "[how many] [regep filter]" options... but that's just me.

If you feel I'm overstepping my bounds with these suggestions (and adding the case statement), please let me know. I'm sorry if that is the case. Feel free to let me know you're not interested in making any or all of my changes and I'll just modify a local copy
Dude it's GLP You are very welcome for the addition!
 
Old 10-21-2016, 03:38 AM   #5
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,473

Original Poster
Blog Entries: 2

Rep: Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981
Thumbs up

Quote:
Originally Posted by e5150 View Post
This is basically what my darkstar-packsize does, but it actually computes the package size based on the files found on the system. Early incarnations of it was a shell script not unlike yours, but I found the UNCOMPRESSED SIZE was often misleadingly large, since I can't help myself to not remove "useless" files, such as locale, icons, gtk-docs, info-pages... I'm sorting the other way though, but that's nothing `tac` can't fix..
[snip]
Kudos for the great package suite there

I knew wg was useful, but I didn't bother for any accuracy just mere comparison:
wg is merely a tool for picking space hogs, nothing about accuracy:
Where I in for any accuracy, I would use 1k blocks and not -h switch and end up probably using Your tool?
 
Old 10-21-2016, 04:36 AM   #6
SCerovec
Senior Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware on x86 and arm
Posts: 2,473

Original Poster
Blog Entries: 2

Rep: Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981
Talking

The best and latest yet:

Code:
#!/bin/sh
#
# (GPL) SCerovec & bassmadrigal on linuxquestions.org
#
#
# changelog:
#
# development started by bassmadrigal
# shift_bugfix and enhanced parameter evaluation by SCerovec
#
A=$1
B=$2

version()
{
  echo "Version 0.2-alpha"
}

howto()
{
cat <<EOF
list (20?) largest installed packages

wg stands for Which Goes ?
parameters :
  -h     :get therse usage instructions
  --help
  -u
  --usage

  number :list this much packages, if omitted
          defaults to 20

  regexp :GNU regular expression evaluated by
          grep to filer out packages of
          interest

 Parameters will be accepted in any order:
 wg 12 SBo
 wg alien 15   -both will work properly.
EOF
}

doit()
{
  grep "UNCOMPRESSED " /var/log/packages/* \
        | grep "${G}" \
        | sed -e s/"\/.*\/"/":"/g \
        | awk -F: '{print $4 " / " $2}' \
        | sort -b -h -r \
        | head -n $N
}

# empty parameters?
if [ "X${A}${B}" == "X" ];then
  #defaults
   N=20
   G=.
else
  # non numeric vars evaluate to 0
  # and upon increment are equal to 1
  # as well as any number less than 1
  if (( +A > 1 )) ; then
    # 1st is numeric
    N=${A:-20}
    G=${B:-.}
  elif (( +B > 1 )) ; then
    # 2nd is numeric
    G=${A:-.}
    N=${B:-20}
  else
    #none gnumeric O.o ?
    N=20
    G="${@}"
  fi
fi

case "$1" in
  -h|--help|-u|--usage)
     howto ;;
  -v|--version)
     version ;;
   *)
     doit ;;
esac
changelog:
too many to count (just kidding)
parameter handling
expanded online help (wg -h)
improved stability
user friendlyness a notch up

do test and report?
 
  


Reply

Tags
administration, low space, post instalation, slackware, trim



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
[SOLVED] Try to remove previous installation and create a package but got an error ethereal1m Linux - Newbie 4 04-09-2010 12:08 PM
[SOLVED] Low disk space,which packages to remove? cola Slackware 2 03-12-2010 05:25 AM
Low Disk Space Peacefrog10 Linux - Newbie 9 07-27-2009 12:23 PM
apt-get installation hung-up and I cannot remove or purge package qajaq Debian 8 06-13-2009 08:48 AM
Low disk space??? kevinlyfellow Linux - General 6 11-12-2003 02:37 PM

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

All times are GMT -5. The time now is 09:23 PM.

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