home *** CD-ROM | disk | FTP | other *** search
Wrap
#!/bin/sh #package manager for Puppy Linux. #(c) copyright 2005,2006 Barry Kauler www.puppylinux.com #packages.txt is placed in /root/.packages by the createpuppy script in Unleashed. #this script can only install to /usr, /etc and /root, as these are all in /root #thus will persist. /bin, /sbin, /lib, etc will not persist. #therefore, the onus is on the createpuppy script to filter /root/.packages/packages.txt #to remove such packages from the list. #v2.0.0 DLG1=" <wtitle>PupGet package manager</wtitle> <vbox> <text><label>Welcome to the PupGet package manager!</label></text> <hbox> <text><label>Click the button to choose a package, download from the Internet, and install it. Or, an installed package may be removed. Note, any local (previously downloaded and saved locally) PupGet package may also be installed. Click here:</label></text> <vbox> <button> <input file>/usr/local/lib/X11/pixmaps/packaging48.xpm</input> <action>EXIT:10</action> </button> </vbox> </hbox> <text><label>\" \"</label></text> <hbox> <text><label>Also, you may install (and later remove) any binary tarball (.tar.gz or .tar.bz2), but it must already be downloaded. (developers may use this to test a pkg that is not yet in the Unleashed suite). Click here:</label></text> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/pupget.xpm</input> <action>EXIT:13</action> </button> </vbox> </hbox> <hbox> <text><label>When a PupGet package is installed, dependencies are checked. However, you can retest any installed package by clicking this button. This will test whether all required shared libraries are present:</label></text> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/package.xpm</input> <action>EXIT:11</action> </button> </vbox> </hbox> <hbox> <text><label>Note that PupGet only offers packages from the Unleashed package suite, but many Puppy enthusiasts have contributed other packages that are available in what we call DotPup format. Click button for web page information:</label></text> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/info16.xpm</input> <action>/usr/local/bin/defaultbrowser http://www.puppylinux.org/wikka/DotPup &</action> </button> </vbox> </hbox> <button cancel></button> </vbox> " #v1.0.5 COMMANDPKG="" DISABLEDX="" if [ "$1" ];then COMMANDPKG="$1" #want pupget script to be noninteractive. #passed param is a pkg name preceded by a + to install pkg, - to uninstall pkg. if [ "`echo -n "$COMMANDPKG" | cut -b 1`" = '-' ];then RETVAL="`xmessage -center -timeout 1 "testing" 2>&1`" if [ ! "`echo "$RETVAL" | grep "Error:"`" = "" ];then #this situation only when uninstalling a pkg, so haven't bypassed all xmessages. DISABLEDX="yes" fi fi fi THISVER="`cat /etc/puppyversion`" DIGIT1="`echo "$THISVER" | cut -b 1`" DIGIT2="`echo "$THISVER" | cut -b 2`" DIGIT3="`echo "$THISVER" | cut -b 3`" RIGHTVER="${DIGIT1}.${DIGIT2}.${DIGIT3}" #WKGDIR="`pwd`" WKGDIR="/root/.packages" cd /root/.packages dependcheck() { echo -n "" > /tmp/missinglibs.txt echo -n "" > /tmp/missinglibs0.txt #v1.0.4 #for openoffice, really need to add /usr/OpenOffice.org1.1.4/program to LD_LIBRARY_PATH, #but cannot be bothered for now... nah, do something now... if [ ! "`echo -n "$APKGNAME" | grep "openoffice"`" = "" ];then #return #bypass dependency check. if [ "`echo "$LD_LIBRARY_PATH" | grep "OpenOffice"`" = "" ];then LD_LIBRARY_PATH="/usr/OpenOffice.org1.1.4/program:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH #...need to generalise this code for different versions of openoffice. fi fi #APATTERN="s/.\/$APKGNAME//g" #cd $WKGDIR #FNDFILES="`find ./$APKGNAME -type f | sed -e "$APATTERN" | tr "\n" " "`" FNDFILES="`cat ./$APKGNAME.files`" for ONEFILE in $FNDFILES do ISANEXEC="`file --brief $ONEFILE | grep --extended-regexp "LSB executable|shared object"`" if [ ! "$ISANEXEC" = "" ];then LDDRESULT="`ldd $ONEFILE`" MISSINGLIBS="`echo "$LDDRESULT" | grep "not found" | cut -f 2 | cut -f 1 -d " " | tr "\n" " "`" if [ ! "$MISSINGLIBS" = "" ];then echo "File $ONEFILE has these missing library files:" >> /tmp/missinglibs.txt echo " $MISSINGLIBS" >> /tmp/missinglibs.txt fi fi done sync #an entry in livepackages.txt can also list any dependent packages... #second field in comments-field has a comma-delimited list of dependencies... BPATTERN="\"${APKGNAME}\" " DEPENDPKGS="`cat ./livepackages.txt | grep "$BPATTERN" | cut -f 6 -d '"' | cut -f 2 -d " " | tr "," "\n" | grep "\+" | tr '+' '"'`" if [ ! "$DEPENDPKGS" = "" ];then cp -f ./packages.txt /tmp/tempzzz cat ./livepackages.txt >> /tmp/tempzzz # echo "Package $APKGNAME has these missing packages that it is dependent on:" >> /tmp/missinglibs.txt for ADEPENDPKG in $DEPENDPKGS do BPATTERN="$ADEPENDPKG\" " if [ "`cat /tmp/tempzzz | grep '" on "' | grep "$BPATTERN"`" = "" ];then echo "This dependent package is missing: $ADEPENDPKG\" " >> /tmp/missinglibs.txt fi done fi } installpkgfunc () { if [ -f ./$APKGNAME/puninstall.sh ];then mv ./$APKGNAME/puninstall.sh ./$APKGNAME.remove fi if [ -d ./$APKGNAME/root0 ];then mv ./$APKGNAME/root0 ./$APKGNAME/root fi if [ -f ./$APKGNAME/keyword ];then mv ./$APKGNAME/keyword ./$APKGNAME.keyword fi if [ -f ./$APKGNAME.keyword ];then #code here to add menu entries etc... AKEYWORD="`cat ./$APKGNAME.keyword | cut -f 1 -d " "`" #incmplete, as can have multi keywords. #v1.0.5 #if [ -f /root/.fvwm95rc ];then # APATTERN="s/#+ \"$AKEYWORD/+ \"$AKEYWORD/g" # cat /root/.fvwm95rc | sed -e "$APATTERN" > /tmp/fvwm95rctmp # sync # cp -f /tmp/fvwm95rctmp /root/.fvwm95rc #mv -f gives Busybox error! #fi ##JWM is more difficult... #if [ -f /root/.jwmrc ];then # NUMLINES=`wc -l /root/.jwmrc | tr -s " " | cut -f 2 -d " "` # echo -n "" > /tmp/DOTjwmrc # REDUCELIST="`cat /root/.jwmrc`" # while [ ! $NUMLINES -eq 0 ];do # HEAD1ST="`echo "$REDUCELIST" | head -n 1`" # NUMLINES=`expr $NUMLINES - 1` # REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`" # BPATTERN="label=\"${AKEYWORD}" #looking for format label="PackageName # if [ "`echo "$HEAD1ST" | grep "$BPATTERN"`" = "" ];then # echo "$HEAD1ST" >> /tmp/DOTjwmrc # else # echo "$HEAD1ST" | sed -e 's/<!-- //g' | sed -e 's/ -->//g' >> /tmp/DOTjwmrc # fi # sync # done # cp -f /tmp/DOTjwmrc /root/.jwmrc #fi ##also do the help index... #if [ -f /usr/share/doc/index.html ];then # NUMLINES=`wc -l /usr/share/doc/index.html | tr -s " " | cut -f 2 -d " "` # echo -n "" > /tmp/DOCindex.html # REDUCELIST="`cat /usr/share/doc/index.html`" # while [ ! $NUMLINES -eq 0 ];do # HEAD1ST="`echo "$REDUCELIST" | head -n 1`" # NUMLINES=`expr $NUMLINES - 1` # REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`" # BPATTERN=">${AKEYWORD}" #looking for format >PackageName # if [ "`echo "$HEAD1ST" | grep "$BPATTERN"`" = "" ];then # echo "$HEAD1ST" >> /tmp/DOCindex.html # else # echo "$HEAD1ST" | sed -e 's/<!-- //g' | sed -e 's/ -->//g' >> /tmp/DOCindex.html # fi # sync # done # cp -f /tmp/DOCindex.html /usr/share/doc/index.html #fi #v1.0.5 /usr/sbin/fixmenus /root $AKEYWORD fi #v1.0.2 problem, these images must be in .files file so can be uninstalled... for ONEIMAGEFILE in `ls -1 ./$APKGNAME/*[0-9].xpm 2>/dev/null` do BASEONEIMAGE="`basename $ONEIMAGEFILE`" echo "/usr/local/lib/X11/pixmaps/$BASEONEIMAGE" >> ./$APKGNAME.files done for ONEIMAGEFILE in `ls -1 ./$APKGNAME/*[0-9].png 2>/dev/null` do BASEONEIMAGE="`basename $ONEIMAGEFILE`" echo "/usr/local/lib/X11/pixmaps/$BASEONEIMAGE" >> ./$APKGNAME.files done for ONEIMAGEFILE in `ls -1 ./$APKGNAME/*[^0-9].xpm 2>/dev/null` do BASEONEIMAGE="`basename $ONEIMAGEFILE`" echo "/usr/local/lib/X11/mini-icons/$BASEONEIMAGE" >> ./$APKGNAME.files done sync #...images.files is appended to the .files file further down. #window and menu icons can also be in the top-level directory of the package... mv ./$APKGNAME/*24.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null mv ./$APKGNAME/*32.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null mv ./$APKGNAME/*32.png /usr/local/lib/X11/pixmaps/ 2>/dev/null mv ./$APKGNAME/*48.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null mv ./$APKGNAME/*48.png /usr/local/lib/X11/pixmaps/ 2>/dev/null mv ./$APKGNAME/*.xpm /usr/local/lib/X11/mini-icons/ 2>/dev/null #now copy files to destination... #v1.0.5 #problem if jwm or fvwm95 not installed by Unleashed. Unleashed createpuppy script #installs .jwmrc and .fvwm95rc anyway and processes them, so do not overwrite them #if install jwm or fvwm95 pupgets now... cp -f /root/.fvwm95rc /tmp/fvwm95rcBACKUP cp -f /root/.jwmrc /tmp/jwmrcBACKUP cp -f /root/.icewm/menu /tmp/icemenuBACKUP #cp -a ./$APKGNAME/* / #stupid thing objects '/etc is not a directory'. so... #cp -af ./$APKGNAME/* / 2> /dev/null #nup, not there yet... #problem if src is a file, dest is a link... dillo for example, /usr/local/bin/dillo #is a link to gtkmoz, so cp writes dillo file over gtkmoz. Removing package leaves #incorrect gtkmoz behind. so trying different copy options... cp-FULL -a --remove-destination ./$APKGNAME/* / 2> /dev/null cp-FULL -a --remove-destination ./$APKGNAME/etc/* /etc/ sync #now restore w.m. config files... cp -f /tmp/fvwm95rcBACKUP /root/.fvwm95rc cp -f /tmp/jwmrcBACKUP /root/.jwmrc cp -f /tmp/icemenuBACKUP /root/.icewm/menu if [ -f ./$APKGNAME/pinstall.sh ];then CURRPATH="`pwd`" cd / /pinstall.sh #execute post-install script. rm -f /pinstall.sh cd $CURRPATH fi if [ -d ./$APKGNAME ];then #dependency check code... dependcheck #function to check dependencies. rm -rf ./$APKGNAME if [ -s /tmp/missinglibs.txt ];then #v1.0.5 WARNLIB="WRITE THESE FILENAMES ON PAPER, THEN INSTALL THEM!" if [ ! "`cat /tmp/missinglibs.txt | grep "libqt"`" = "" ];then WARNLIB="PROBLEM: libqt is missing. This is a core library required by all Qt applications, such as Scribus, VYM, Cutecom, Qhacc, Opera. You must run PupGet package manager again and install the \"qt-3.3.4\" (or later version) package, then reboot Puppy. Note, the reboot is essential." fi if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#80ff80" -center -title "PupGet" "SUCCESS: $APKGNAME is installed! Note 1: To see any change to the menu, the window manager must be restarted. Note 2: If installed any library, X server, browser, you must reboot Puppy. HOWEVER, these dependencies required by this package are missing: `cat /tmp/missinglibs.txt` $WARNLIB" fi else if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#80ff80" -center -title "PupGet" "SUCCESS: $APKGNAME is installed! Note 1: To see any change to the menu, the window manager must be restarted. Note 2: If installed any library, X server, browser, you must reboot Puppy." fi fi else if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet" "ERROR: something went wrong. $APKGNAME not installed" fi RETSTATUS=1 fi rm -f ./$APKGNAME.tar.gz } #end installpkgfunc() #livepackages.txt is the list of packages that can be installed or removed... if [ ! -f $WKGDIR/livepackages.txt ];then touch livepackages.txt fi if [ -f $WKGDIR/alienpackages.txt ];then #IF2508 #v1.0.3 users may be installing alien packages, there is risk of alienpackages.txt getting #wrongly formatted... #correct format: "qhacc-3.3" "qhacc-3.3: Accounting" on "QT3APPS 3104K" \ #note, grep is looking for " \" but Ash firstly interpretes, then grep, so need ' \\\\'... OKLINES="`cat $WKGDIR/alienpackages.txt | cut -f 7 -d '"' | grep ' \\\\' | wc -l`" ALLLINES="`cat $WKGDIR/alienpackages.txt | wc -l`" if [ ! "$OKLINES" = "$ALLLINES" ];then if [ ! "$DISABLEDX" = "yes" ];then xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet package manager: ERROR" "There is a formatting error in $WKGDIR/alienpackages.txt Probably an alien package install script has appended a line to this file, but with incorrect format. You should be able to visually examine this file and determine the offending package. You should then be able to manually fix it, then inform the package creator that installation is faulty. -- this could be the case of an improperly design DotPup installer. Entries in alienpackages.txt should have this format: \"qhacc-3.3\" \"qhacc-3.3: Accounting\" on \"QT3APPS 3104K\" \\ An entry must be exactly like this, no extra spaces between fields, no more or less quotes, space followed by backslash on the end. No blank lines. Note, there must be a RETURN on the end of the last line (that is, the text editor cursor can be moved to below the last line) Press OK button to quit PupGet..." fi exit fi fi #IF2508 if [ "$COMMANDPKG" = "" ];then #v1.0.5 #xmessage -center -name "pupget" -bg "#C0ffC0" -title "PupGet package manager" -buttons "Install_or_remove_pkgs:10,Check_dependencies_of_installed_pkg:11,Install_alien_pkg:13,DotPup_install:12,QUIT:19" "Welcome to the PupGet package manager! PupGet allows you to install and remove packages. # #Note that PupGet only offers packages from the Unleashed package suite, but many #Puppy enthusiasts have contributed other packages that are available in what we call #DotPup format -- click the \"DotPup_install\" button for further information. # #Also, you may install (and later remove) any binary tarball (.tar.gz or .tar.bz2) #by clicking \"Install_alien_pkg\" button, but it must already be downloaded. #(developers may use this to test a pkg that is not yet in the Unleashed suite). # #Click a button to install, remove, or check dependencies..." #RETVAL=$? #v2.0.0 RETVAL="`echo "$DLG1" | gtkdialog2 --stdin | grep 'EXIT:' | cut -f 2 -d ':'`" [ ! "$RETVAL" ] && RETVAL=19 echo "RETVAL=$RETVAL" else #noninteractive, install or remove a pkg. RETVAL=10 fi case $RETVAL in 10) #continue script. PKGUNLEASHED="yes" ;; 11) #check dependencies. cp -f ./livepackages.txt /tmp/zippidoodah.txt if [ -f ./alienpackages.txt ];then cat ./alienpackages.txt >> /tmp/zippidoodah.txt fi PKGSONLIST="`cat /tmp/zippidoodah.txt | grep '" on "'`" if [ ! "$PKGSONLIST" = "" ];then rm -f /tmp/rettags.txt echo '#!/bin/sh' > /tmp/pkgdialog echo 'RETTAGS="`Xdialog --title "PupGet package manager: dependency check" --left --stdout --item-help --icon "/usr/local/lib/X11/pixmaps/packaging96.xpm" --no-cancel --no-tags --radiolist "Choose a package that you want to check its dependencies,\nthat is, that it has all required libraries and dependent\npackages installed..." 460x270+0+0 0 \' >> /tmp/pkgdialog echo "$PKGSONLIST" >> /tmp/pkgdialog echo ' `"' >> /tmp/pkgdialog echo 'if [ ! $? -eq 0 ];then' >> /tmp/pkgdialog echo ' exit' >> /tmp/pkgdialog echo 'fi' >> /tmp/pkgdialog echo 'echo "$RETTAGS" > /tmp/rettags.txt' >> /tmp/pkgdialog sync chmod 755 /tmp/pkgdialog /tmp/pkgdialog APKGNAME="`cat /tmp/rettags.txt 2> /dev/null`" if [ "$APKGNAME" = "" ];then exit fi dependcheck #function. if [ -s /tmp/missinglibs.txt ];then #v1.0.5 WARNLIB="WRITE THESE FILENAMES ON PAPER, THEN INSTALL THEM!" if [ ! "`cat /tmp/missinglibs.txt | grep "libqt"`" = "" ];then WARNLIB="PROBLEM: libqt is missing. This is a core library required by all Qt applications, such as Scribus, VYM, Cutecom, Qhacc. You must run PupGet package manager again and install the \"qt-3.3.4\" (or later version) package, then reboot Puppy. Note, the reboot is essential." fi if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: dependency check WARNING" "These dependencies required by $APKGNAME package are missing: `cat /tmp/missinglibs.txt` $WARNLIB" fi else if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: dependency check OKAY" "It seems that all the dependencies required for this package are installed" fi fi fi exit ;; 12) #exec mozilla http://www.puppylinux.org/wikka/DotPup exec dotpup ;; 13) #Alien_package MSG9="PupGet: Choose alien package" while [ 1 ];do ALIENFILE="`Xdialog --title "$MSG9" --stdout --no-buttons --fselect "/root/*" 0 0`" if [ ! $? -eq 0 ];then exit fi if [ -f $ALIENFILE ];then break fi MSG9="PupGet: TRY AGAIN, Choose alien package" done sync cp -af $ALIENFILE /root/.packages/ #copy, leave original. sync cd /root/.packages APKGNAME="`basename $ALIENFILE`" if [ ! "`echo "$APKGNAME" | grep --extended-regexp "\.tgz|\.tar\.gz"`" = "" ];then tar -zxf $APKGNAME APKGNAME="`echo "$APKGNAME" | sed -e 's/.tgz//g' | sed -e 's/.tar.gz//g'`" fi if [ ! "`echo "$APKGNAME" | grep --extended-regexp "\.tbz2|\.tar\.bz2"`" = "" ];then tar -jxf $APKGNAME APKGNAME="`echo "$APKGNAME" | sed -e 's/.tbz2//g' | sed -e 's/.tar.bz2//g'`" fi if [ ! -d ./$APKGNAME ];then if [ ! "$DISABLEDX" = "yes" ];then xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet: package expansion ERROR" "There was an error expanding package $APKGNAME. Either the file is corrupted, or has not expanded into its own directory with name of $APKGNAME/ (which is how most packages expand). You will have to go into /root/.packages/ directory and manually clean it up. This script will now exit..." fi exit fi APATTERN="s/.\/$APKGNAME//g" #need to find regular files and links separately... find ./$APKGNAME -type f -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' > ./$APKGNAME.files sync find ./$APKGNAME -type l -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' >> ./$APKGNAME.files sync #if [ ! "`cat ./$APKGNAME.files | cut -f 2 -d '/' | grep -v --extended-regexp "usr|etc|root"`" = "" ];then # rm -rf ./$APKGNAME # rm -f ./$APKGNAME* # xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet: package format ERROR" "Packages are only allowed to install into top-level directories #/usr, /etc and /root. This package wants to install elsewhere, #so aborting this script. The package is now deleted." # exit #fi echo -n "\"$APKGNAME\" \"$APKGNAME" >> ./alienpackages.txt echo ': no description" on "ALIENAPP" \' >> ./alienpackages.txt xmessage -center -name "pupget" -bg "#c0ffc0" -title "PupGet: Alien package install" -buttons "INSTALL:10,EXIT:20" "SO FAR OKAY! The alien package has been expanded in /root/.packages/$APKGNAME/ directory, and has passed some preliminary suitability tests, however there may be some special requirements. You may need to go into /root/.packages/$APKGNAME/ and manually install the package. NOTE, IT MUST BE A BINARY TARBALL, PUPPY CANNOT COMPILE!!! PupGet has created /root/.packages/$APKGNAME.files, where Puppy thinks the packages files are to be copied to, but for some packages this file may be incorrect, in which case delete it -- if it looks okay, you may later run PupGet to perform a dependency check on the package or uninstall the package. If $APKGNAME.files is incorrect, recommend that you edit it and make it correct, so that PupGet will be able to uninstall and check deps. Note, this package has been entered into /root/.packages/alienpackages.txt. I PROPOSE THAT ONE DAY THIS SECTION OF THE SRIPT WILL AUTOMATICALLY RECOGNISE SLACKWARE TARBALLS AND AUTOMATICALLY INSTALL THEM -- ANYONE INTERESTED? THE pupget SCRIPT IS IN /usr/sbin. Normally recommend that you click the EXIT button right now, however if you know the pkg format is okay (like it's an Unleashed package), click INSTALL..." if [ $? -eq 10 ];then #install #go ahead and install it... xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait..." & installpkgfunc #function call. killall xmessage fi exit ;; *) exit ;; esac if [ ! "$DISABLEDX" = "yes" ];then xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait..." & fi UNLEASHEDPKGS="`cat $WKGDIR/packages.txt`" #this is file from Unleashed. #livepackages.txt has all packages that were not installed by Unleashed... OFFPKGS="`echo "$UNLEASHEDPKGS" | grep -v '" on "' | grep -v '" unavailable "'`" #this updates livepackages.txt when packages.txt is updated... #code here adds any new "off" packages from packages.txt to livepackages.txt... REDUCELIST="$OFFPKGS" while [ ! "$REDUCELIST" = "" ];do HEAD1ST="`echo "$REDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" APKGNAME="\"$APKGNAME\"" REDUCELIST="`echo "$REDUCELIST" | grep -v "$APKGNAME"`" if [ "`cat $WKGDIR/livepackages.txt | grep "$APKGNAME"`" = "" ];then echo "$HEAD1ST" >> $WKGDIR/livepackages.txt fi done #...Note above, I had to back-slash the double-quotes, to be sure that grep found only the # pkg name in the first field of packages.txt. #...one thing though. this script is not going to be too happy if user changes iso 'flavours'. #we need some 'clash' checking... #if "on" in packages.txt and listed in livepackages.txt, then remove, but if installed then #need to uninstall it... (whew)... rm -f /tmp/forcepkgremove.txt ONPKGS="`echo "$UNLEASHEDPKGS" | grep -v '" off "' | grep -v '" unavailable "'`" REDUCELIST="$ONPKGS" while [ ! "$REDUCELIST" = "" ];do HEAD1ST="`echo "$REDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" APKGNAME="\"$APKGNAME\"" REDUCELIST="`echo "$REDUCELIST" | grep -v "$APKGNAME"`" #remove $APKGNAME line from livepackages.txt... #remove version number... NAMETITLE="`echo "$APKGNAME" | cut -f 1 -d "-"`" #format is \"name NAMETITLE="${NAMETITLE}\-" WRONGPKG="`cat $WKGDIR/livepackages.txt | grep "$NAMETITLE"`" if [ ! "$WRONGPKG" = "" ];then if [ ! "`echo "$WRONGPKG" | grep '" on "'`" = "" ];then #but, there's a problem, as this package is installed... echo "$WRONGPKG" >> /tmp/forcepkgremove.txt fi #now remove the line... cat $WKGDIR/livepackages.txt | grep -v "$NAMETITLE" > /tmp/livepackages.txt sync cp -f /tmp/livepackages.txt $WKGDIR/livepackages.txt #mv -f gives Busybox error! sync fi done if [ -f /tmp/forcepkgremove.txt ];then if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: PACKAGE CLASH" " WARNING: These packages were previously installed by PupGet: `cat /tmp/forcepkgremove.txt | cut -f 1 -d " " | tr "\n" " "` HOWEVER, they are also in the live-CD ISO (or usr_cram.fs in case of other installations). This is a clash, and this script will now force their removal. You may need to reboot for these packages on the live-CD to be reinstated. Note: the next 2-pane window will not show them, as they are now scheduled for automatic removal after the 2-pane window OK button is pressed. PLEASE DO NOT ABORT PupGet IN ANY FOLLOWING WINDOW -- PRESS OK BUTTON IN NEXT WINDOW AND ALLOW SCRIPT TO COMPLETE, SO THAT IT CAN REMOVE THESE OFFENDING PACKAGES -- ABORTING NOW WILL STUFF THINGS UP! Click OK to continue script..." fi fi #v1.0.3 need to do the same clash checking for alien packages. #i won't mess with above code, just duplicate it here... rm -f /tmp/forcealienpkgremove.txt ONPKGS="`echo "$UNLEASHEDPKGS" | grep -v '" off "' | grep -v '" unavailable "'`" REDUCELIST="$ONPKGS" while [ ! "$REDUCELIST" = "" ];do HEAD1ST="`echo "$REDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" APKGNAME="\"$APKGNAME\"" REDUCELIST="`echo "$REDUCELIST" | grep -v "$APKGNAME"`" #remove $APKGNAME line from alienpackages.txt... #remove version number... NAMETITLE="`echo "$APKGNAME" | cut -f 1 -d "-"`" #format is \"name NAMETITLE="${NAMETITLE}\-" WRONGPKG="`cat $WKGDIR/alienpackages.txt 2> /dev/null | grep "$NAMETITLE"`" if [ ! "$WRONGPKG" = "" ];then if [ ! "`echo "$WRONGPKG" | grep '" on "'`" = "" ];then #but, there's a problem, as this package is installed... echo "$WRONGPKG" >> /tmp/forcealienpkgremove.txt fi #now remove the line... cat $WKGDIR/alienpackages.txt 2> /dev/null | grep -v "$NAMETITLE" > /tmp/alienpackages.txt sync cp -f /tmp/alienpackages.txt $WKGDIR/alienpackages.txt #mv -f gives Busybox error! sync fi done if [ -f /tmp/forcealienpkgremove.txt ];then if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: PACKAGE CLASH" "WARNING: These alien packages were previously installed, either by PupGet, or by some other means registered with PupGet upon installation: `cat /tmp/forcealienpkgremove.txt | cut -f 1 -d " " | tr "\n" " "` HOWEVER, they are also in the live-CD ISO (or usr_cram.fs in case of other installations). This is a clash, and this script will now force their removal. You may need to reboot for these packages on the live-CD to be reinstated. Note: the next 2-pane window will not show them, as they are now scheduled for automatic removal after the 2-pane window OK button is pressed. PLEASE DO NOT ABORT PupGet IN ANY FOLLOWING WINDOW -- PRESS OK BUTTON IN NEXT WINDOW AND ALLOW SCRIPT TO COMPLETE, SO THAT IT CAN REMOVE THESE OFFENDING PACKAGES -- ABORTING NOW WILL STUFF THINGS UP! Click OK to continue script..." fi cat /tmp/forcealienpkgremove.txt >> /tmp/forcepkgremove.txt sync fi sort -u $WKGDIR/livepackages.txt > /tmp/livepackages.txt sync PACKAGESFND="`cat /tmp/livepackages.txt`" cp -f ./livepackages.txt /tmp/zippidoodah.txt sync if [ -f ./alienpackages.txt ];then #v1.0.3 problem, could have gimp-2.0.6 off in livepackages.txt but on in alienpackages.txt #we don't want both lines, we only want the last line... ALIENONPKGS="`cat ./alienpackages.txt | grep '" on "' | cut -f 2 -d '"'`" for ONEONALIEN in $ALIENONPKGS do FPATTERN="\"${ONEONALIEN}\" " cat /tmp/zippidoodah.txt | grep -v "$FPATTERN" > /tmp/templive.txt sync cp -f /tmp/templive.txt /tmp/zippidoodah.txt done sync cat ./alienpackages.txt >> /tmp/zippidoodah.txt fi sync ALLPKGSFND="`cat /tmp/zippidoodah.txt`" if [ ! "$DISABLEDX" = "yes" ];then killall xmessage fi if [ "$COMMANDPKG" = "" ];then #IF2508 v1.0.5 rm -f /tmp/rettags.txt echo '#!/bin/sh' > /tmp/pkgdialog echo 'RETTAGS="`Xdialog --title "PupGet package manager" --left --stdout --separator " " --item-help --icon "/usr/local/lib/X11/pixmaps/packaging96.xpm" --no-cancel --buildlist "Add or remove packages that will be in Puppy. For any packages that you choose to add,\nyou can choose whether to download the pkgs from the Internet or obtain them locally.\nHover mouse pointer over a package for further info. Packages are in groups:\nCore groups: CONSCORE, XLIBCORE, GTK1CORE, GTK2CORE, TCLCORE, QT3CORE, MMCORE\nAppl groups: CONSAPPS, [MM]XLIBAPPS, [MM]GTK1APPS, [MM]GTK2APPS, [MM]TCLAPPS, [MM]QT3APPS\nExample1: MMGTK2APPS pkg requires all CONSCORE, XLIBCORE, GTK2CORE, MMCORE pkgs installed.\nExample2: QT3APPS package requires all CONSCORE, XLIBCORE, QT3CORE pkgs installed.\nAny extra required pkg specified like this, for Gxine pkg: MMGTK2APPS +xine-1.0 900K\nNote: Only packages not in the live-CD are listed below. The official live-CD has most\nof the CORE groups installed. For the complete list, see /root/.packages/packages.txt." 780x540+0+0 0 \' >> /tmp/pkgdialog echo "$ALLPKGSFND" >> /tmp/pkgdialog echo ' `"' >> /tmp/pkgdialog echo 'if [ ! $? -eq 0 ];then' >> /tmp/pkgdialog echo ' exit' >> /tmp/pkgdialog echo 'fi' >> /tmp/pkgdialog echo 'echo "$RETTAGS" > /tmp/rettags.txt' >> /tmp/pkgdialog # ' #fix highlighting. sync chmod 755 /tmp/pkgdialog /tmp/pkgdialog else #v1.0.5 #noninteractive mode. COMMANDPKG has name of pkg to be added or removed. ALLONNAMES="`echo -n "$ALLPKGSFND" | grep '" on "' | cut -f 2 -d '"'`" if [ "`echo -n "$COMMANDPKG" | cut -b 1`" = '+' ];then ADDONENAME="`echo "$COMMANDPKG" | cut -b 2-99`" ALLONNAMES="$ALLONNAMES $ADDONENAME" fi if [ "`echo "$COMMANDPKG" | cut -b 1`" = '-' ];then REMONENAME="`echo "$COMMANDPKG" | cut -b 2-99`" ALLONNAMES="`echo -n "$ALLONNAMES" | grep -v "$REMONENAME"`" fi echo -n "$ALLONNAMES" | tr "\n" " " > /tmp/rettags.txt fi #IF2508 if [ ! -f /tmp/rettags.txt ];then exit fi echo "TEST: COMMANDPKG=$COMMANDPKG" #/tmp/rettags.txt has all the tags (package names) chosen to be in Puppy. #status field to "on", otherwise "off"... RETTAGS="`cat /tmp/rettags.txt`" echo -n "" > $WKGDIR/livepackages.txt REDUCELIST="$PACKAGESFND" #this is list from livepackages.txt while [ ! "$REDUCELIST" = "" ];do HEAD1ST="`echo "$REDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" QAPKGNAMEQ="\"${APKGNAME}\"" REDUCELIST="`echo "$REDUCELIST" | grep -v "$QAPKGNAMEQ"`" if [ "`cat /tmp/rettags.txt | grep "$APKGNAME"`" = "" ];then #make sure it is off... echo "$HEAD1ST" | sed -e 's/\" on \"/\" off \"/g' >> $WKGDIR/livepackages.txt else #make sure it is on... echo "$HEAD1ST" | sed -e 's/\" off \"/\" on \"/g' >> $WKGDIR/livepackages.txt fi done sync #...drop out here, $WKGDIR/livepackages.txt has the updated list of packages to be # installed or uninstalled. This list does not include packages in the live-CD. echo #now to find out which packages are to be installed or uninstalled... #WARNING: packages.txt must not have a ">" character in it! PKGSCHGD="`echo "$PACKAGESFND" | diff -B - $WKGDIR/livepackages.txt | grep -v "\-\-\-" | grep '>' | cut -b 3-256`" PKGS2ADD="`echo "$PKGSCHGD" | grep '" on "'`" PKGS2REM="`echo "$PKGSCHGD" | grep '" off "'`" if [ -f /tmp/forcepkgremove.txt ];then if [ "$PKGS2REM" = "" ];then PKGS2REM="`cat /tmp/forcepkgremove.txt`" else PKGS2REM="$PKGS2REM `cat /tmp/forcepkgremove.txt`" fi fi #also handle alien package removal... RETTAGS="`cat /tmp/rettags.txt`" if [ -f ./alienpackages.txt ];then REDUCELIST="`cat ./alienpackages.txt`" while [ ! "$REDUCELIST" = "" ];do HEAD1ST="`echo "$REDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" BPATTERN="\"${APKGNAME}\" " REDUCELIST="`echo "$REDUCELIST" | grep -v "$BPATTERN"`" if [ "`cat /tmp/rettags.txt | grep "$APKGNAME"`" = "" ];then if [ "$PKGS2REM" = "" ];then PKGS2REM="`cat ./alienpackages.txt | grep "$BPATTERN"`" else PKGS2REM="$PKGS2REM `cat ./alienpackages.txt | grep "$BPATTERN"`" fi #delete entry... cat ./alienpackages.txt | grep -v "$BPATTERN" > /tmp/alienpackages.txt sync cp -f /tmp/alienpackages.txt ./alienpackages.txt fi done sync fi #how to uninstall? #how to install? #the working directory is /root/.packages/, i think will expand a package here first, extract a filelist, #then move it to destination... if [ ! "$PKGS2REM" = "" ];then #v1.0.3 hiccup, see patch above, it is possible we can get duplicate entries here, if a pkg #is listed in both alienpackages.txt and livepackages.txt. use sort... PKGREMNAMES="`echo "$PKGS2REM" | cut -f 1 -d " " | sort -u | tr "\n" " "`" if [ ! "$DISABLEDX" = "yes" ];then xmessage -center -name "pupget" -bg "orange" "You have chosen to remove these packages from Puppy: $PKGREMNAMES Press OK button..." xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait..." & fi # #v1.0.6 if remove a w.m., leave its menu config file behind... # cp -f /root/.fvwm95rc /tmp/fvwm95rcBACKUP # cp -f /root/.jwmrc /tmp/jwmrcBACKUP # cp -f /root/.icewm/menu /tmp/icemenuBACKUP XREDUCELIST="$PKGS2REM" while [ ! "$XREDUCELIST" = "" ];do #WHILE-103A HEAD1ST="`echo "$XREDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" QAPKGNAMEQ="\"${APKGNAME}\"" XREDUCELIST="`echo "$XREDUCELIST" | grep -v "$QAPKGNAMEQ"`" #$APKGNAME.files has the file list for the package... if [ -f $WKGDIR/$APKGNAME.files ];then #103B #v1.0.6 do not remove w.m. menu config files... cat $WKGDIR/$APKGNAME.files | grep -v "\\.icewm/menu" | grep -v "\\.jwmrc" | grep -v "\\.fvwm95rc" > /tmp/removefileslist.txt sync cp -f /tmp/removefileslist.txt $WKGDIR/$APKGNAME.files for ONEFILE in `cat ./$APKGNAME.files` do ##do not delete from /usr, as unionfs may create a "deletion file" to hide ##an underlying file in usr_cram.fs. Delete from /root/.usr... #ONEFILE="`echo -n "$ONEFILE" | sed -e 's/\/usr\//\/root\/.usr\//g'`" #...v2.0.0 no, cannot do this in puppy2. #.files file may be malformed. check entry is a genuine file... if [ -e $ONEFILE ];then if [ ! -d $ONEFILE ];then #v2.0.0 if [ -f /initrd/pup_ro2$ONEFILE ];then #the problem is, deleting the file on the top layer places a ".wh" whiteout file, #that hides the original file. what we want is to remove the installed file, and #restore the original pristine file... cp -af /initrd/pup_ro2$ONEFILE $ONEFILE else rm -f $ONEFILE fi #v2.0.0 also, delete empty dirs... DELDIR="`dirname $ONEFILE`" [ "`ls -1 $DELDIR`" = "" ] && rmdir $DELDIR fi fi done if [ -f ./$APKGNAME.remove ];then ./$APKGNAME.remove fi if [ -f ./$APKGNAME.keyword ];then #code here to remove menu entries etc... #if it's a forced removal, due to same package existing in live-cd, don't want to #remove from menus... CPATTERN="\"${APKGNAME}\"" if [ "`cat /tmp/forcepkgremove.txt | grep "$CPATTERN"`" = "" ];then AKEYWORD="`cat ./$APKGNAME.keyword`" #v1.0.5 /usr/sbin/fixmenus /root \-$AKEYWORD fi fi rm -f ./$APKGNAME.* if [ ! "$DISABLEDX" = "yes" ];then xmessage -name "pupget" -bg "#80ff80" -center -title "PupGet" "SUCCESS: $APKGNAME is removed! Note: After exiting from PupGet, it is recommended that you reboot Puppy to fully remove all traces of the uninstalled package." fi sync fi #103B done #WHILE-103A # #v1.0.6 now restore w.m. config files... # cp -f /tmp/fvwm95rcBACKUP /root/.fvwm95rc # cp -f /tmp/jwmrcBACKUP /root/.jwmrc # cp -f /tmp/icemenuBACKUP /root/.icewm/menu if [ ! "$DISABLEDX" = "yes" ];then killall xmessage fi fi if [ ! "$PKGS2ADD" = "" ];then PKGADDNAMES="`echo "$PKGS2ADD" | cut -f 1 -d " " | tr "\n" " "`" STARTMSG="" BKCOLOR="orange" while [ 1 ];do xmessage -center -name "pupget" -bg "$BKCOLOR" -title "PupGet" -buttons "ibiblio.org:10,nluug.nl:11,Local:19" "${STARTMSG}You have chosen to install these packages in Puppy: $PKGADDNAMES Please connect to the Internet then press a button to choose download site. If you click on \"Local\" button, the packages must already be downloaded, that is, somewhere local." RETVAL=$? WWWSITE="" if [ $RETVAL -eq 10 ];then WWWSITE="ibiblio.org" fi if [ $RETVAL -eq 11 ];then WWWSITE="ftp.nluug.nl" fi if [ ! "$WWWSITE" = "" ];then ping -c 1 -q $WWWSITE if [ ! $? -eq 0 ];then #v1.0.5 GuestToo has suggested another test... if wget -t 2 -T 20 --waitretry=20 --spider -S $WWWSITE -o /dev/stdout | grep '200 OK' then echo "$WWWSITE is online" else BKCOLOR="#FF8080" STARTMSG="ERROR: $WWWSITE IS UNREACHABLE! ...are you connected to the Internet? ...maybe that site is down? Try another. " continue fi fi fi break done case $RETVAL in 10) #PKGSRC="ftp://ibiblio.org/pub/Linux/distributions/puppylinux/puppy-${RIGHTVER}/packages" PKGSRC="ftp://ibiblio.org/pub/Linux/distributions/puppylinux/pupget_packages-1" ;; 11) #PKGSRC="http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/puppy-${RIGHTVER}/packages" PKGSRC="http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/pupget_packages-1" ;; 19) #Local LOCALDIR="`Xdialog --title "PupGet: Choose local directory" --stdout --no-buttons --dselect "/root" 0 0`" if [ ! $? -eq 0 ];then exit fi sync KEEPGOING="no" for ONEFILE in `echo "$PKGS2ADD" | cut -f 2 -d '"' | tr "\n" " "` do cp -af ${LOCALDIR}/${ONEFILE}.tar.gz /root/.packages/ if [ ! $? -eq 0 ];then xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet: Local pkg error" " ERROR: file ${ONEFILE}.tar.gz is not in folder $LOCALDIR" else KEEPGOING="yes" fi sync done #keep going even if found one pkg... if [ "$KEEPGOING" = "no" ];then exit fi PKGSRC="." ;; *) exit ;; esac xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait... Note: If wget has connected to the remote site then become \"stuck\", just wait, as wget will keep retrying until download is successful." & XREDUCELIST="$PKGS2ADD" while [ ! "$XREDUCELIST" = "" ];do HEAD1ST="`echo "$XREDUCELIST" | head -n 1`" APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`" QAPKGNAMEQ="\"${APKGNAME}\"" XREDUCELIST="`echo "$XREDUCELIST" | grep -v "$QAPKGNAMEQ"`" if [ ! "$PKGSRC" = "." ];then rm -f ./${APKGNAME}.tar.gz #precaution. rxvt -name pupget -bg orange -geometry 80x10 -e wget $PKGSRC/${APKGNAME}.tar.gz fi sync RETSTATUS=0 if [ -f ./${APKGNAME}.tar.gz ];then if [ "`gzip --test --verbose ${APKGNAME}.tar.gz 2>&1 | grep "OK"`" = "" ];then RETSTATUS=1 else tar -zxf ./$APKGNAME.tar.gz if [ $? -eq 0 ];then APATTERN="s/.\/$APKGNAME//g" #a problem, if pkg has a symbolic link to an absolute path to a file, that is not yet #installed, it won't be included in the .files file... #so, instead of "-xtype f" will have two finds... #finds regular files only... find ./$APKGNAME -type f -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' > ./$APKGNAME.files sync #finds symbolic links only... find ./$APKGNAME -type l -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' >> ./$APKGNAME.files #this does actual instal... installpkgfunc #function call. else RETSTATUS=1 fi fi else RETSTATUS=1 fi if [ $RETSTATUS -eq 1 ];then xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet" "FAILURE: $APKGNAME.tar.gz was not downloaded successfully" rm -f ./${APKGNAME}.tar.gz 2> /dev/null #also need to turn "off" in livepackages.txt... #well, could just delete the line, as it will get added back in from packages.txt next #time run this script... DPATTERN="\"$APKGNAME\"" cat $WKGDIR/livepackages.txt | grep -v "$DPATTERN" > /tmp/livepackages.txt sync rm -f $WKGDIR/livepackages.txt mv /tmp/livepackages.txt $WKGDIR/livepackages.txt rm ${WKGDIR}/${APKGNAME}.* 2> /dev/null fi done sync killall xmessage fi ##END##