Page 1 of 1

[SCRIPT] remove only recently installed packages GUI

Posted: 27 Jan 2012, 19:19
by bigbass
what this does is remove recently installed packages NOT modules
you must have an installed Porteus because this looks for the "boot device:" /mnt/live/var/log/livedbg
this way only a small list of packages will be seen making it easy to see what you had installed recently
it uses a Xdialog GUI checklist

*If you have no packages installed this app wont do anything so install a package to test

I may have to install quite a few packages to compile and this allows for better quick control
of what is installed by me to view and remove when needed


Code: Select all

#!/bin/bash

# 8-7-2010  modified for Porteus Jan-27-2012
# built for TXZ_pup  big_bass 
# remove-recently-installed-packages 
# make a smaller list so its easy to 
# find recently installed packages  


# make folders clean up files
mkdir -p /tmp/remover

rm -f /tmp/remover/new_list.*  
rm -f /tmp/remover/return2


# these are the packages recently installed  to Porteus
# thanks Hamza for letting me know about the osdev string 
osdev=`grep -A1 "boot device:" /mnt/live/var/log/livedbg | sed -n '2p'`
echo $osdev
cd /mnt/live/mnt/$osdev/porteus/changes/var/log/packages
ls $pwd -1 >/tmp/remover/new_list.tmp
cd $HOME

# generated list for Xdialog GUI added to the body later
    for i in  `cat /tmp/remover/new_list.tmp` ; do
        echo \"$i\" \" \" OFF "\\">> /tmp/remover/new_list.tmp3   
    done  


#================================================
#                  GUI
#================================================
# head  of the viewer (static part)
cat << 'EOF' > /tmp/remover/files_files_viewer
#!/bin/sh
Xdialog --title " files files(s) you want to remove" \
--backtitle "Remove files files  "     \
--checklist "Select  files to remove       \
                                             \n"  0 0 0  \
EOF


# body viewer    (dynamic part)                                           
# build the list of packages  to remove                                           
echo "`cat /tmp/remover/new_list.tmp3`">>  /tmp/remover/files_files_viewer



# had to add choice string for it to work on Porteus
# take care of close box ,ok and cancel (static part)
cat << 'EOF' >>/tmp/remover/files_files_viewer
2> /tmp/remover/return2 
choice=`cat /tmp/remover/return2`

case $choice in
  0)
    echo "Yes chosen.";;
  1)
    echo "No chosen."
    
	exit
	;;
  255)
    echo "Box closed."
    exit
	;;

esac 
EOF

#================================================


# set permissions for the GUI script 
chmod a+x  /tmp/remover/files_files_viewer
    

# run the viewer sourced    
. /tmp/remover/files_files_viewer


# add multiple removes  
# its done after the  selection of the packages 

# raw original convert slash to space
echo $choice| sed 's/\// /g'> /tmp/remover/return2


# convert space to new line 
echo $choice | tr ' ' '\n' > /tmp/remover/return2


  
    # quick check to see if no packages were found in this directory 
    # if no packages found xdialog would crash 
	if ! [ -s /tmp/remover/return2 ];then
        Xdialog --title "NO tgz or txz packages  found or selected " \
        	     --infobox "\nYou must have or select tgz or txz packages in this directory!.\n" 0 0 7000
        exit 
    fi




# make a list of all the packages that were removed 
LIST=$(</tmp/remover/return2)

# remove files selected in the GUI
 

    for i in $LIST ;do 
        removepkg $i
    done


# display the package removed 
Xdialog --title "Complete" \
       	--infobox "\nRemoved $LIST finished.\n" 0 0 6000


	
   

Re: [SCRIPT] remove only recently installed packages GUI

Posted: 27 Jan 2012, 19:49
by Hamza
Please provide us a short description of this wonderful script :)

Re: [SCRIPT] remove only recently installed packages GUI

Posted: 28 Jan 2012, 05:49
by bigbass
Hamza
Please provide us a short description
Yes, I also updated the script (cleaned up some un used stuff) it had a strange error that I corrected for Porteus use
sorry I was late to respond just came back from work
Joe

Re: [SCRIPT] remove only recently installed packages GUI

Posted: 28 Jan 2012, 12:10
by Hamza
It was possible to track directly the porteus boot device by using $porteus variable but it has been removed due to some reported user's troubles.