home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / pupget < prev    next >
Encoding:
Text File  |  2006-06-17  |  38.1 KB  |  981 lines

  1. #!/bin/sh
  2. #package manager for Puppy Linux.
  3. #(c) copyright 2005,2006 Barry Kauler www.puppylinux.com
  4.  
  5. #packages.txt is placed in /root/.packages by the createpuppy script in Unleashed.
  6. #this script can only install to /usr, /etc and /root, as these are all in /root
  7. #thus will persist. /bin, /sbin, /lib, etc will not persist.
  8. #therefore, the onus is on the createpuppy script to filter /root/.packages/packages.txt
  9. #to remove such packages from the list.
  10.  
  11. #v2.0.0
  12. DLG1="
  13.  <wtitle>PupGet package manager</wtitle>
  14.  <vbox>
  15.   <text><label>Welcome to the PupGet package manager!</label></text>
  16.   <hbox>
  17.    <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>
  18.    <vbox>
  19.     <button>
  20.      <input file>/usr/local/lib/X11/pixmaps/packaging48.xpm</input>
  21.      <action>EXIT:10</action>
  22.     </button>
  23.    </vbox>
  24.   </hbox>
  25.   <text><label>\" \"</label></text>
  26.   <hbox>
  27.    <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>
  28.    <vbox>
  29.     <button>
  30.      <input file>/usr/local/lib/X11/mini-icons/pupget.xpm</input>
  31.      <action>EXIT:13</action>
  32.     </button>
  33.    </vbox>
  34.   </hbox>
  35.  
  36.   <hbox>
  37.    <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>
  38.    <vbox>
  39.     <button>
  40.      <input file>/usr/local/lib/X11/mini-icons/package.xpm</input>
  41.      <action>EXIT:11</action>
  42.     </button>
  43.    </vbox>
  44.   </hbox>
  45.  
  46.   <hbox>
  47.    <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>
  48.    <vbox>
  49.     <button>
  50.      <input file>/usr/local/lib/X11/mini-icons/info16.xpm</input>
  51.      <action>/usr/local/bin/defaultbrowser http://www.puppylinux.org/wikka/DotPup &</action>
  52.     </button>
  53.    </vbox>
  54.   </hbox>
  55.   <button cancel></button>
  56.  </vbox>
  57. "
  58.  
  59. #v1.0.5
  60. COMMANDPKG=""
  61. DISABLEDX=""
  62. if [ "$1" ];then
  63.  COMMANDPKG="$1"
  64.  #want pupget script to be noninteractive.
  65.  #passed param is a pkg name preceded by a + to install pkg, - to uninstall pkg.
  66.  if [ "`echo -n "$COMMANDPKG" | cut -b 1`" = '-' ];then
  67.   RETVAL="`xmessage -center -timeout 1 "testing" 2>&1`"
  68.   if [ ! "`echo "$RETVAL" | grep "Error:"`" = "" ];then
  69.    #this situation only when uninstalling a pkg, so haven't bypassed all xmessages.
  70.    DISABLEDX="yes"
  71.   fi
  72.  fi
  73. fi
  74.  
  75. THISVER="`cat /etc/puppyversion`"
  76. DIGIT1="`echo "$THISVER" | cut -b 1`"
  77. DIGIT2="`echo "$THISVER" | cut -b 2`"
  78. DIGIT3="`echo "$THISVER" | cut -b 3`"
  79. RIGHTVER="${DIGIT1}.${DIGIT2}.${DIGIT3}"
  80.  
  81. #WKGDIR="`pwd`"
  82. WKGDIR="/root/.packages"
  83. cd /root/.packages
  84.  
  85.  
  86. dependcheck() {
  87.  echo -n "" > /tmp/missinglibs.txt
  88.  echo -n "" > /tmp/missinglibs0.txt
  89.   #v1.0.4 
  90.   #for openoffice, really need to add /usr/OpenOffice.org1.1.4/program to LD_LIBRARY_PATH,
  91.   #but cannot be bothered for now... nah, do something now...
  92.   if [ ! "`echo -n "$APKGNAME" | grep "openoffice"`" = "" ];then
  93.    #return #bypass dependency check.
  94.    if [ "`echo "$LD_LIBRARY_PATH" | grep "OpenOffice"`" = "" ];then
  95.     LD_LIBRARY_PATH="/usr/OpenOffice.org1.1.4/program:$LD_LIBRARY_PATH"
  96.     export LD_LIBRARY_PATH
  97.     #...need to generalise this code for different versions of openoffice.
  98.    fi
  99.   fi
  100.  #APATTERN="s/.\/$APKGNAME//g"
  101.  #cd $WKGDIR
  102.  #FNDFILES="`find ./$APKGNAME -type f | sed -e "$APATTERN" | tr "\n" " "`"
  103.  FNDFILES="`cat ./$APKGNAME.files`"
  104.  for ONEFILE in $FNDFILES
  105.  do
  106.   ISANEXEC="`file --brief $ONEFILE | grep --extended-regexp "LSB executable|shared object"`"
  107.   if [ ! "$ISANEXEC" = "" ];then
  108.    LDDRESULT="`ldd $ONEFILE`"
  109.    MISSINGLIBS="`echo "$LDDRESULT" | grep "not found" | cut -f 2 | cut -f 1 -d " " | tr "\n" " "`"
  110.    if [ ! "$MISSINGLIBS" = "" ];then
  111.     echo "File $ONEFILE has these missing library files:" >> /tmp/missinglibs.txt
  112.     echo " $MISSINGLIBS" >> /tmp/missinglibs.txt
  113.    fi
  114.   fi
  115.  done
  116.  sync
  117.  #an entry in livepackages.txt can also list any dependent packages...
  118.  #second field in comments-field has a comma-delimited list of dependencies...
  119.  BPATTERN="\"${APKGNAME}\" "
  120.  DEPENDPKGS="`cat ./livepackages.txt | grep "$BPATTERN" | cut -f 6 -d '"' | cut -f 2 -d " " | tr "," "\n" | grep "\+" | tr '+' '"'`"
  121.  if [ ! "$DEPENDPKGS" = "" ];then
  122.   cp -f ./packages.txt /tmp/tempzzz
  123.   cat ./livepackages.txt >> /tmp/tempzzz
  124. #  echo "Package $APKGNAME has these missing packages that it is dependent on:" >> /tmp/missinglibs.txt
  125.   for ADEPENDPKG in $DEPENDPKGS
  126.   do
  127.    BPATTERN="$ADEPENDPKG\" "
  128.    if [  "`cat /tmp/tempzzz | grep '" on "' | grep "$BPATTERN"`" = "" ];then
  129.     echo "This dependent package is missing: $ADEPENDPKG\" " >> /tmp/missinglibs.txt
  130.    fi
  131.   done
  132.  fi
  133. }
  134.  
  135.  
  136. installpkgfunc () {
  137.     if [ -f ./$APKGNAME/puninstall.sh ];then
  138.      mv ./$APKGNAME/puninstall.sh ./$APKGNAME.remove
  139.     fi
  140.     if [ -d ./$APKGNAME/root0 ];then
  141.      mv ./$APKGNAME/root0 ./$APKGNAME/root
  142.     fi
  143.     if [ -f ./$APKGNAME/keyword ];then
  144.      mv ./$APKGNAME/keyword ./$APKGNAME.keyword
  145.     fi
  146.     if [ -f ./$APKGNAME.keyword ];then
  147.      #code here to add menu entries etc...
  148.      AKEYWORD="`cat ./$APKGNAME.keyword | cut -f 1 -d " "`" #incmplete, as can have multi keywords.
  149.  
  150.      #v1.0.5
  151.      #if [ -f /root/.fvwm95rc ];then
  152.      # APATTERN="s/#+ \"$AKEYWORD/+ \"$AKEYWORD/g"
  153.      # cat /root/.fvwm95rc | sed -e "$APATTERN" > /tmp/fvwm95rctmp
  154.      # sync
  155.      # cp -f /tmp/fvwm95rctmp /root/.fvwm95rc #mv -f gives Busybox error!
  156.      #fi
  157.      ##JWM is more difficult...
  158.      #if [ -f /root/.jwmrc ];then
  159.      # NUMLINES=`wc -l /root/.jwmrc | tr -s " " | cut -f 2 -d " "`
  160.      # echo -n "" > /tmp/DOTjwmrc
  161.      # REDUCELIST="`cat /root/.jwmrc`"
  162.      # while [ ! $NUMLINES -eq 0 ];do
  163.      #  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  164.      #  NUMLINES=`expr $NUMLINES - 1`
  165.      #  REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`"
  166.      #  BPATTERN="label=\"${AKEYWORD}" #looking for format label="PackageName
  167.      #  if [ "`echo "$HEAD1ST" | grep "$BPATTERN"`" = "" ];then
  168.      #   echo "$HEAD1ST" >> /tmp/DOTjwmrc
  169.      #  else
  170.      #   echo "$HEAD1ST" | sed -e 's/<!-- //g' | sed -e 's/ -->//g' >> /tmp/DOTjwmrc
  171.      #  fi
  172.      #  sync
  173.      # done
  174.      # cp -f /tmp/DOTjwmrc /root/.jwmrc
  175.      #fi
  176.      ##also do the help index...
  177.      #if [ -f /usr/share/doc/index.html ];then
  178.      # NUMLINES=`wc -l /usr/share/doc/index.html | tr -s " " | cut -f 2 -d " "`
  179.      # echo -n "" > /tmp/DOCindex.html
  180.      # REDUCELIST="`cat /usr/share/doc/index.html`"
  181.      # while [ ! $NUMLINES -eq 0 ];do
  182.      #  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  183.      #  NUMLINES=`expr $NUMLINES - 1`
  184.      #  REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`"
  185.      #  BPATTERN=">${AKEYWORD}" #looking for format >PackageName
  186.      #  if [ "`echo "$HEAD1ST" | grep "$BPATTERN"`" = "" ];then
  187.      #   echo "$HEAD1ST" >> /tmp/DOCindex.html
  188.      #  else
  189.      #   echo "$HEAD1ST" | sed -e 's/<!-- //g' | sed -e 's/ -->//g' >> /tmp/DOCindex.html
  190.      #  fi
  191.      #  sync
  192.      # done
  193.      # cp -f /tmp/DOCindex.html /usr/share/doc/index.html
  194.      #fi
  195.  
  196.      #v1.0.5
  197.      /usr/sbin/fixmenus /root $AKEYWORD
  198.  
  199.     fi
  200.     #v1.0.2 problem, these images must be in .files file so can be uninstalled...
  201.     for ONEIMAGEFILE in `ls -1 ./$APKGNAME/*[0-9].xpm 2>/dev/null`
  202.     do
  203.      BASEONEIMAGE="`basename $ONEIMAGEFILE`"
  204.      echo "/usr/local/lib/X11/pixmaps/$BASEONEIMAGE" >> ./$APKGNAME.files
  205.     done
  206.     for ONEIMAGEFILE in `ls -1 ./$APKGNAME/*[0-9].png 2>/dev/null`
  207.     do
  208.      BASEONEIMAGE="`basename $ONEIMAGEFILE`"
  209.      echo "/usr/local/lib/X11/pixmaps/$BASEONEIMAGE" >> ./$APKGNAME.files
  210.     done
  211.     for ONEIMAGEFILE in `ls -1 ./$APKGNAME/*[^0-9].xpm 2>/dev/null`
  212.     do
  213.      BASEONEIMAGE="`basename $ONEIMAGEFILE`"
  214.      echo "/usr/local/lib/X11/mini-icons/$BASEONEIMAGE" >> ./$APKGNAME.files
  215.     done
  216.     sync
  217.     #...images.files is appended to the .files file further down.
  218.     #window and menu icons can also be in the top-level directory of the package...
  219.     mv ./$APKGNAME/*24.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null
  220.     mv ./$APKGNAME/*32.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null
  221.     mv ./$APKGNAME/*32.png /usr/local/lib/X11/pixmaps/ 2>/dev/null
  222.     mv ./$APKGNAME/*48.xpm /usr/local/lib/X11/pixmaps/ 2>/dev/null
  223.     mv ./$APKGNAME/*48.png /usr/local/lib/X11/pixmaps/ 2>/dev/null
  224.     mv ./$APKGNAME/*.xpm /usr/local/lib/X11/mini-icons/ 2>/dev/null
  225.     #now copy files to destination...
  226.      #v1.0.5
  227.      #problem if jwm or fvwm95 not installed by Unleashed. Unleashed createpuppy script
  228.      #installs .jwmrc and .fvwm95rc anyway and processes them, so do not overwrite them
  229.      #if install jwm or fvwm95 pupgets now...
  230.      cp -f /root/.fvwm95rc /tmp/fvwm95rcBACKUP
  231.      cp -f /root/.jwmrc /tmp/jwmrcBACKUP
  232.      cp -f /root/.icewm/menu /tmp/icemenuBACKUP
  233.     #cp -a ./$APKGNAME/* / #stupid thing objects '/etc is not a directory'. so...
  234.     #cp -af ./$APKGNAME/* / 2> /dev/null #nup, not there yet...
  235.     #problem if src is a file, dest is a link... dillo for example, /usr/local/bin/dillo
  236.     #is a link to gtkmoz, so cp writes dillo file over gtkmoz. Removing package leaves
  237.     #incorrect gtkmoz behind. so trying different copy options...
  238.     cp-FULL -a --remove-destination ./$APKGNAME/* / 2> /dev/null
  239.     cp-FULL -a --remove-destination ./$APKGNAME/etc/* /etc/
  240.     sync
  241.      #now restore w.m. config files...
  242.      cp -f /tmp/fvwm95rcBACKUP /root/.fvwm95rc
  243.      cp -f /tmp/jwmrcBACKUP /root/.jwmrc
  244.      cp -f /tmp/icemenuBACKUP /root/.icewm/menu
  245.     if [ -f ./$APKGNAME/pinstall.sh ];then
  246.      CURRPATH="`pwd`"
  247.      cd /
  248.      /pinstall.sh #execute post-install script.
  249.      rm -f /pinstall.sh
  250.      cd $CURRPATH
  251.     fi
  252.     if [ -d ./$APKGNAME ];then
  253.      #dependency check code...
  254.      dependcheck #function to check dependencies.
  255.      rm -rf ./$APKGNAME
  256.      if [ -s /tmp/missinglibs.txt ];then
  257.       #v1.0.5
  258.       WARNLIB="WRITE THESE FILENAMES ON PAPER, THEN INSTALL THEM!"
  259.       if [ ! "`cat /tmp/missinglibs.txt | grep "libqt"`" = "" ];then
  260.        WARNLIB="PROBLEM: libqt is missing. This is a core library required by all Qt
  261.            applications, such as Scribus, VYM, Cutecom, Qhacc, Opera.
  262.            You must run PupGet package manager again and install the
  263.            \"qt-3.3.4\" (or later version) package, then reboot Puppy.
  264.            Note, the reboot is essential."
  265.       fi
  266.       if [ ! "$DISABLEDX" = "yes" ];then
  267.        xmessage -name "pupget" -bg "#80ff80" -center -title "PupGet" "SUCCESS: $APKGNAME is installed!
  268. Note 1: To see any change to the menu, the window manager must be restarted.
  269. Note 2: If installed any library, X server, browser, you must reboot Puppy.
  270.  
  271. HOWEVER, these dependencies required by this package are missing:
  272. `cat /tmp/missinglibs.txt`
  273.  
  274. $WARNLIB"
  275.       fi
  276.      else
  277.       if [ ! "$DISABLEDX" = "yes" ];then
  278.        xmessage -name "pupget" -bg "#80ff80" -center -title "PupGet" "SUCCESS: $APKGNAME is installed!
  279. Note 1: To see any change to the menu, the window manager must be restarted.
  280. Note 2: If installed any library, X server, browser, you must reboot Puppy."
  281.       fi
  282.      fi
  283.     else
  284.      if [ ! "$DISABLEDX" = "yes" ];then
  285.       xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet" "ERROR: something went wrong. $APKGNAME not installed"
  286.      fi
  287.      RETSTATUS=1
  288.     fi
  289.     rm -f ./$APKGNAME.tar.gz
  290. } #end installpkgfunc()
  291.  
  292.  
  293. #livepackages.txt is the list of packages that can be installed or removed...
  294. if [ ! -f $WKGDIR/livepackages.txt ];then
  295.  touch livepackages.txt
  296. fi
  297.  
  298. if [ -f $WKGDIR/alienpackages.txt ];then #IF2508
  299. #v1.0.3 users may be installing alien packages, there is risk of alienpackages.txt getting
  300. #wrongly formatted...
  301. #correct format: "qhacc-3.3" "qhacc-3.3: Accounting" on "QT3APPS 3104K" \
  302. #note, grep is looking for " \" but Ash firstly interpretes, then grep, so need ' \\\\'...
  303. OKLINES="`cat $WKGDIR/alienpackages.txt | cut -f 7 -d '"' | grep ' \\\\' | wc -l`"
  304. ALLLINES="`cat $WKGDIR/alienpackages.txt | wc -l`"
  305. if [ ! "$OKLINES" = "$ALLLINES" ];then
  306.  if [ ! "$DISABLEDX" = "yes" ];then
  307.   xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet package manager: ERROR" "There is a formatting error in $WKGDIR/alienpackages.txt
  308. Probably an alien package install script has appended a line to this file,
  309. but with incorrect format. You should be able to visually examine this file
  310. and determine the offending package. You should then be able to manually fix
  311. it, then inform the package creator that installation is faulty.
  312. -- this could be the case of an improperly design DotPup installer.
  313.  
  314. Entries in alienpackages.txt should have this format:
  315. \"qhacc-3.3\" \"qhacc-3.3: Accounting\" on \"QT3APPS 3104K\" \\
  316. An entry must be exactly like this, no extra spaces between fields, no more
  317. or less quotes, space followed by backslash on the end. No blank lines.
  318. Note, there must be a RETURN on the end of the last line (that is, the
  319. text editor cursor can be moved to below the last line)
  320.  
  321. Press OK button to quit PupGet..."
  322.  fi
  323.  exit
  324. fi
  325. fi #IF2508
  326.  
  327. if [ "$COMMANDPKG" = "" ];then #v1.0.5
  328.  
  329. #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.
  330. #
  331. #Note that PupGet only offers packages from the Unleashed package suite, but many
  332. #Puppy enthusiasts have contributed other packages that are available in what we call
  333. #DotPup format -- click the \"DotPup_install\" button for further information.
  334. #
  335. #Also, you may install (and later remove) any binary tarball (.tar.gz or .tar.bz2)
  336. #by clicking \"Install_alien_pkg\" button, but it must already be downloaded.
  337. #(developers may use this to test a pkg that is not yet in the Unleashed suite).
  338. #
  339. #Click a button to install, remove, or check dependencies..."
  340. #RETVAL=$?
  341.  
  342.  #v2.0.0
  343.  RETVAL="`echo "$DLG1" | gtkdialog2 --stdin | grep 'EXIT:' | cut -f 2 -d ':'`"
  344.  [ ! "$RETVAL" ] && RETVAL=19
  345.  echo "RETVAL=$RETVAL"
  346.  
  347. else
  348.  #noninteractive, install or remove a pkg.
  349.  RETVAL=10
  350. fi
  351.  
  352. case $RETVAL in
  353.  10) #continue script.
  354.   PKGUNLEASHED="yes"
  355.   ;;
  356.  11) #check dependencies.
  357.   cp -f ./livepackages.txt /tmp/zippidoodah.txt
  358.   if [ -f ./alienpackages.txt ];then
  359.    cat ./alienpackages.txt >> /tmp/zippidoodah.txt
  360.   fi
  361.   PKGSONLIST="`cat /tmp/zippidoodah.txt | grep '" on "'`"
  362.   if [ ! "$PKGSONLIST" = "" ];then
  363.    rm -f /tmp/rettags.txt
  364.    echo '#!/bin/sh' > /tmp/pkgdialog
  365.    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
  366.    echo "$PKGSONLIST" >> /tmp/pkgdialog
  367.    echo ' `"' >> /tmp/pkgdialog
  368.    echo 'if [ ! $? -eq 0 ];then' >> /tmp/pkgdialog
  369.    echo ' exit'  >> /tmp/pkgdialog
  370.    echo 'fi' >> /tmp/pkgdialog
  371.    echo 'echo "$RETTAGS" > /tmp/rettags.txt' >> /tmp/pkgdialog
  372.    sync
  373.    chmod 755 /tmp/pkgdialog
  374.    /tmp/pkgdialog
  375.    APKGNAME="`cat /tmp/rettags.txt 2> /dev/null`"
  376.    if [ "$APKGNAME" = "" ];then
  377.     exit
  378.    fi
  379.    dependcheck #function.
  380.    if [ -s /tmp/missinglibs.txt ];then
  381.     #v1.0.5
  382.     WARNLIB="WRITE THESE FILENAMES ON PAPER, THEN INSTALL THEM!"
  383.     if [ ! "`cat /tmp/missinglibs.txt | grep "libqt"`" = "" ];then
  384.      WARNLIB="PROBLEM: libqt is missing. This is a core library required by all Qt
  385.          applications, such as Scribus, VYM, Cutecom, Qhacc.
  386.          You must run PupGet package manager again and install the
  387.          \"qt-3.3.4\" (or later version) package, then reboot Puppy.
  388.          Note, the reboot is essential."
  389.     fi
  390.     if [ ! "$DISABLEDX" = "yes" ];then
  391.      xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: dependency check WARNING" "These dependencies required by $APKGNAME package are missing:
  392. `cat /tmp/missinglibs.txt`
  393.  
  394. $WARNLIB"
  395.     fi
  396.    else
  397.     if [ ! "$DISABLEDX" = "yes" ];then
  398.      xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: dependency check OKAY" "It seems that all the dependencies required for this package are installed"
  399.     fi
  400.    fi
  401.   fi
  402.   exit
  403.   ;;
  404.  12)
  405.   #exec mozilla http://www.puppylinux.org/wikka/DotPup
  406.   exec dotpup
  407.   ;;
  408.  13) #Alien_package
  409.   MSG9="PupGet: Choose alien package"
  410.   while [ 1 ];do
  411.    ALIENFILE="`Xdialog --title "$MSG9" --stdout --no-buttons --fselect "/root/*" 0 0`"
  412.    if [ ! $? -eq 0 ];then
  413.     exit
  414.    fi
  415.    if [ -f $ALIENFILE ];then
  416.     break
  417.    fi
  418.    MSG9="PupGet: TRY AGAIN, Choose alien package"
  419.   done
  420.   sync
  421.   cp -af $ALIENFILE /root/.packages/ #copy, leave original.
  422.   sync
  423.   cd /root/.packages
  424.   APKGNAME="`basename $ALIENFILE`"
  425.   if [ ! "`echo "$APKGNAME" | grep --extended-regexp "\.tgz|\.tar\.gz"`" = "" ];then
  426.    tar -zxf $APKGNAME
  427.    APKGNAME="`echo "$APKGNAME" | sed -e 's/.tgz//g' | sed -e 's/.tar.gz//g'`"
  428.   fi
  429.   if [ ! "`echo "$APKGNAME" | grep --extended-regexp "\.tbz2|\.tar\.bz2"`" = "" ];then
  430.    tar -jxf $APKGNAME
  431.    APKGNAME="`echo "$APKGNAME" | sed -e 's/.tbz2//g' | sed -e 's/.tar.bz2//g'`"
  432.   fi
  433.   if [ ! -d ./$APKGNAME ];then
  434.   if [ ! "$DISABLEDX" = "yes" ];then
  435.    xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet: package expansion ERROR" "There was an error expanding package $APKGNAME.
  436. Either the file is corrupted, or has not expanded into its own directory with
  437. name of $APKGNAME/ (which is how most packages expand).
  438. You will have to go into /root/.packages/ directory and manually clean it up.
  439.  
  440. This script will now exit..."
  441.    fi
  442.    exit
  443.   fi
  444.   APATTERN="s/.\/$APKGNAME//g"
  445.   #need to find regular files and links separately...
  446.   find ./$APKGNAME -type f -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' > ./$APKGNAME.files
  447.   sync
  448.   find ./$APKGNAME -type l -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' >> ./$APKGNAME.files
  449.   sync
  450.   #if [ ! "`cat ./$APKGNAME.files | cut -f 2 -d '/' | grep -v --extended-regexp "usr|etc|root"`" = "" ];then
  451.   # rm -rf ./$APKGNAME
  452.   # rm -f ./$APKGNAME*
  453.   #  xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet: package format ERROR" "Packages are only allowed to install into top-level directories
  454. #/usr, /etc and /root. This package wants to install elsewhere,
  455. #so aborting this script. The package is now deleted."
  456.   # exit
  457.   #fi
  458.   echo -n "\"$APKGNAME\" \"$APKGNAME" >> ./alienpackages.txt
  459.   echo ': no description" on "ALIENAPP" \' >> ./alienpackages.txt
  460.   xmessage -center -name "pupget" -bg "#c0ffc0" -title "PupGet: Alien package install" -buttons "INSTALL:10,EXIT:20" "SO FAR OKAY!
  461. The alien package has been expanded in /root/.packages/$APKGNAME/
  462. directory, and has passed some preliminary suitability tests, however
  463. there may be some special requirements. You may need to go into 
  464. /root/.packages/$APKGNAME/ and manually install the package.
  465. NOTE, IT MUST BE A BINARY TARBALL, PUPPY CANNOT COMPILE!!!
  466. PupGet has created /root/.packages/$APKGNAME.files, where Puppy thinks
  467. the packages files are to be copied to, but for some packages this
  468. file may be incorrect, in which case delete it -- if it looks okay, you
  469. may later run PupGet to perform a dependency check on the package or
  470. uninstall the package.
  471. If $APKGNAME.files is incorrect, recommend that you edit it and make
  472. it correct, so that PupGet will be able to uninstall and check deps.
  473. Note, this package has been entered into /root/.packages/alienpackages.txt.
  474. I PROPOSE THAT ONE DAY THIS SECTION OF THE SRIPT WILL AUTOMATICALLY
  475. RECOGNISE SLACKWARE TARBALLS AND AUTOMATICALLY INSTALL THEM
  476. -- ANYONE INTERESTED? THE pupget SCRIPT IS IN /usr/sbin.
  477.  
  478. Normally recommend that you click the EXIT button right now, however if you
  479. know the pkg format is okay (like it's an Unleashed package), click INSTALL..."
  480.   if [ $? -eq 10 ];then #install
  481.    #go ahead and install it...
  482.    xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait..." &
  483.    installpkgfunc #function call.
  484.    killall xmessage
  485.   fi
  486.   exit
  487.   ;;
  488.  *)
  489.   exit
  490.   ;;
  491. esac
  492.  
  493. if [ ! "$DISABLEDX" = "yes" ];then
  494.  xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait..." &
  495. fi
  496.  
  497. UNLEASHEDPKGS="`cat $WKGDIR/packages.txt`" #this is file from Unleashed.
  498.  
  499. #livepackages.txt has all packages that were not installed by Unleashed...
  500. OFFPKGS="`echo "$UNLEASHEDPKGS" | grep -v '" on "' | grep -v '" unavailable "'`"
  501.  
  502. #this updates livepackages.txt when packages.txt is updated...
  503. #code here adds any new "off" packages from packages.txt to livepackages.txt...
  504. REDUCELIST="$OFFPKGS"
  505. while [ ! "$REDUCELIST" = "" ];do
  506.  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  507.  APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  508.  APKGNAME="\"$APKGNAME\""
  509.  REDUCELIST="`echo "$REDUCELIST" | grep -v "$APKGNAME"`"
  510.  if [ "`cat $WKGDIR/livepackages.txt | grep "$APKGNAME"`" = "" ];then
  511.   echo "$HEAD1ST" >> $WKGDIR/livepackages.txt
  512.  fi
  513. done
  514.  
  515. #...Note above, I had to back-slash the double-quotes, to be sure that grep found only the
  516. #   pkg name in the first field of packages.txt.
  517.  
  518. #...one thing though. this script is not going to be too happy if user changes iso 'flavours'.
  519. #we need some 'clash' checking...
  520. #if "on" in packages.txt and listed in livepackages.txt, then remove, but if installed then
  521. #need to uninstall it... (whew)...
  522. rm -f /tmp/forcepkgremove.txt
  523. ONPKGS="`echo "$UNLEASHEDPKGS" | grep -v '" off "' | grep -v '" unavailable "'`"
  524. REDUCELIST="$ONPKGS"
  525. while [ ! "$REDUCELIST" = "" ];do
  526.  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  527.  APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  528.  APKGNAME="\"$APKGNAME\""
  529.  REDUCELIST="`echo "$REDUCELIST" | grep -v "$APKGNAME"`"
  530.  #remove $APKGNAME line from livepackages.txt...
  531.  #remove version number...
  532.  NAMETITLE="`echo "$APKGNAME" | cut -f 1 -d "-"`" #format is \"name
  533.  NAMETITLE="${NAMETITLE}\-"
  534.  WRONGPKG="`cat $WKGDIR/livepackages.txt | grep "$NAMETITLE"`"
  535.  if [ ! "$WRONGPKG" = "" ];then
  536.   if [ ! "`echo "$WRONGPKG" | grep '" on "'`" = "" ];then
  537.    #but, there's a problem, as this package is installed...
  538.    echo "$WRONGPKG" >> /tmp/forcepkgremove.txt
  539.   fi
  540.   #now remove the line...
  541.   cat $WKGDIR/livepackages.txt | grep -v "$NAMETITLE" > /tmp/livepackages.txt
  542.   sync
  543.   cp -f /tmp/livepackages.txt $WKGDIR/livepackages.txt #mv -f gives Busybox error!
  544.   sync
  545.  fi
  546. done
  547. if [ -f /tmp/forcepkgremove.txt ];then
  548.  if [ ! "$DISABLEDX" = "yes" ];then
  549.   xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: PACKAGE CLASH" "
  550. WARNING: These packages were previously installed by PupGet:
  551. `cat /tmp/forcepkgremove.txt | cut -f 1 -d " " | tr "\n" " "`
  552.  
  553. HOWEVER, they are also in the live-CD ISO (or usr_cram.fs in case
  554. of other installations). This is a clash, and this script will now
  555. force their removal. You may need to reboot for these packages on
  556. the live-CD to be reinstated.
  557. Note: the next 2-pane window will not show them, as they are now
  558.       scheduled for automatic removal after the 2-pane window OK
  559.       button is pressed. PLEASE DO NOT ABORT PupGet IN ANY FOLLOWING
  560.       WINDOW -- PRESS OK BUTTON IN NEXT WINDOW AND ALLOW SCRIPT TO
  561.       COMPLETE, SO THAT IT CAN REMOVE THESE OFFENDING PACKAGES --
  562.       ABORTING NOW WILL STUFF THINGS UP!
  563.  
  564. Click OK to continue script..."
  565.  fi
  566. fi
  567.  
  568. #v1.0.3 need to do the same clash checking for alien packages.
  569. #i won't mess with above code, just duplicate it here...
  570. rm -f /tmp/forcealienpkgremove.txt
  571. ONPKGS="`echo "$UNLEASHEDPKGS" | grep -v '" off "' | grep -v '" unavailable "'`"
  572. REDUCELIST="$ONPKGS"
  573. while [ ! "$REDUCELIST" = "" ];do
  574.  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  575.  APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  576.  APKGNAME="\"$APKGNAME\""
  577.  REDUCELIST="`echo "$REDUCELIST" | grep -v "$APKGNAME"`"
  578.  #remove $APKGNAME line from alienpackages.txt...
  579.  #remove version number...
  580.  NAMETITLE="`echo "$APKGNAME" | cut -f 1 -d "-"`" #format is \"name
  581.  NAMETITLE="${NAMETITLE}\-"
  582.  WRONGPKG="`cat $WKGDIR/alienpackages.txt 2> /dev/null | grep "$NAMETITLE"`"
  583.  if [ ! "$WRONGPKG" = "" ];then
  584.   if [ ! "`echo "$WRONGPKG" | grep '" on "'`" = "" ];then
  585.    #but, there's a problem, as this package is installed...
  586.    echo "$WRONGPKG" >> /tmp/forcealienpkgremove.txt
  587.   fi
  588.   #now remove the line...
  589.   cat $WKGDIR/alienpackages.txt 2> /dev/null | grep -v "$NAMETITLE" > /tmp/alienpackages.txt
  590.   sync
  591.   cp -f /tmp/alienpackages.txt $WKGDIR/alienpackages.txt #mv -f gives Busybox error!
  592.   sync
  593.  fi
  594. done
  595. if [ -f /tmp/forcealienpkgremove.txt ];then
  596.  if [ ! "$DISABLEDX" = "yes" ];then
  597.   xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet: PACKAGE CLASH" "WARNING: These alien packages were previously installed, either by PupGet,
  598. or by some other means registered with PupGet upon installation:
  599. `cat /tmp/forcealienpkgremove.txt | cut -f 1 -d " " | tr "\n" " "`
  600.  
  601. HOWEVER, they are also in the live-CD ISO (or usr_cram.fs in case
  602. of other installations). This is a clash, and this script will now
  603. force their removal. You may need to reboot for these packages on
  604. the live-CD to be reinstated.
  605. Note: the next 2-pane window will not show them, as they are now
  606.       scheduled for automatic removal after the 2-pane window OK
  607.       button is pressed. PLEASE DO NOT ABORT PupGet IN ANY FOLLOWING
  608.       WINDOW -- PRESS OK BUTTON IN NEXT WINDOW AND ALLOW SCRIPT TO
  609.       COMPLETE, SO THAT IT CAN REMOVE THESE OFFENDING PACKAGES --
  610.       ABORTING NOW WILL STUFF THINGS UP!
  611.  
  612. Click OK to continue script..."
  613.  fi
  614.  cat /tmp/forcealienpkgremove.txt >> /tmp/forcepkgremove.txt
  615.  sync
  616. fi
  617.  
  618.  
  619. sort -u $WKGDIR/livepackages.txt > /tmp/livepackages.txt
  620. sync
  621. PACKAGESFND="`cat /tmp/livepackages.txt`"
  622.  
  623. cp -f ./livepackages.txt /tmp/zippidoodah.txt
  624. sync
  625. if [ -f ./alienpackages.txt ];then
  626.  #v1.0.3 problem, could have gimp-2.0.6 off in livepackages.txt but on in alienpackages.txt
  627.  #we don't want both lines, we only want the last line...
  628.  ALIENONPKGS="`cat ./alienpackages.txt | grep '" on "' | cut -f 2 -d '"'`"
  629.  for ONEONALIEN in $ALIENONPKGS
  630.  do
  631.   FPATTERN="\"${ONEONALIEN}\" "
  632.   cat /tmp/zippidoodah.txt | grep -v "$FPATTERN" > /tmp/templive.txt
  633.   sync
  634.   cp -f /tmp/templive.txt /tmp/zippidoodah.txt
  635.  done
  636.  sync
  637.  cat ./alienpackages.txt >> /tmp/zippidoodah.txt
  638. fi
  639. sync
  640.  
  641. ALLPKGSFND="`cat /tmp/zippidoodah.txt`"
  642.  
  643. if [ ! "$DISABLEDX" = "yes" ];then
  644.  killall xmessage
  645. fi
  646.  
  647. if [ "$COMMANDPKG" = "" ];then #IF2508 v1.0.5 
  648. rm -f /tmp/rettags.txt
  649. echo '#!/bin/sh' > /tmp/pkgdialog
  650. 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
  651. echo "$ALLPKGSFND" >> /tmp/pkgdialog
  652. echo ' `"' >> /tmp/pkgdialog
  653. echo 'if [ ! $? -eq 0 ];then' >> /tmp/pkgdialog
  654. echo ' exit'  >> /tmp/pkgdialog
  655. echo 'fi' >> /tmp/pkgdialog
  656. echo 'echo "$RETTAGS" > /tmp/rettags.txt' >> /tmp/pkgdialog
  657.  
  658. # ' #fix highlighting.
  659. sync
  660. chmod 755 /tmp/pkgdialog
  661. /tmp/pkgdialog
  662. else #v1.0.5
  663.  #noninteractive mode. COMMANDPKG has name of pkg to be added or removed.
  664.  ALLONNAMES="`echo -n "$ALLPKGSFND" | grep '" on "' | cut -f 2 -d '"'`"
  665.  if [ "`echo -n "$COMMANDPKG" | cut -b 1`" = '+' ];then
  666.   ADDONENAME="`echo "$COMMANDPKG" | cut -b 2-99`"
  667.   ALLONNAMES="$ALLONNAMES $ADDONENAME"
  668.  fi
  669.  if [ "`echo "$COMMANDPKG" | cut -b 1`" = '-' ];then
  670.   REMONENAME="`echo "$COMMANDPKG" | cut -b 2-99`"
  671.   ALLONNAMES="`echo -n "$ALLONNAMES" | grep -v "$REMONENAME"`"
  672.  fi
  673.  echo -n "$ALLONNAMES" | tr "\n" " " > /tmp/rettags.txt
  674. fi #IF2508
  675.  
  676. if [ ! -f /tmp/rettags.txt ];then
  677.  exit
  678. fi
  679.  
  680.  
  681. echo "TEST: COMMANDPKG=$COMMANDPKG"
  682.  
  683.  
  684. #/tmp/rettags.txt has all the tags (package names) chosen to be in Puppy.
  685. #status field to "on", otherwise "off"...
  686. RETTAGS="`cat /tmp/rettags.txt`"
  687. echo -n "" > $WKGDIR/livepackages.txt
  688. REDUCELIST="$PACKAGESFND"   #this is list from livepackages.txt
  689. while [ ! "$REDUCELIST" = "" ];do
  690.  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  691.  APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  692.  QAPKGNAMEQ="\"${APKGNAME}\""
  693.  REDUCELIST="`echo "$REDUCELIST" | grep -v "$QAPKGNAMEQ"`"
  694.  if [ "`cat /tmp/rettags.txt | grep "$APKGNAME"`" = "" ];then
  695.   #make sure it is off...
  696.   echo "$HEAD1ST" | sed -e 's/\" on \"/\" off \"/g' >> $WKGDIR/livepackages.txt
  697.  else
  698.   #make sure it is on...
  699.   echo "$HEAD1ST" | sed -e 's/\" off \"/\" on \"/g' >> $WKGDIR/livepackages.txt
  700.  fi
  701. done
  702. sync
  703. #...drop out here, $WKGDIR/livepackages.txt has the updated list of packages to be
  704. #   installed or uninstalled. This list does not include packages in the live-CD.
  705. echo
  706. #now to find out which packages are to be installed or uninstalled...
  707. #WARNING: packages.txt must not have a ">" character in it!
  708. PKGSCHGD="`echo "$PACKAGESFND" | diff -B - $WKGDIR/livepackages.txt | grep -v "\-\-\-" | grep '>' | cut -b 3-256`"
  709. PKGS2ADD="`echo "$PKGSCHGD" | grep '" on "'`"
  710. PKGS2REM="`echo "$PKGSCHGD" | grep '" off "'`"
  711.  
  712. if [ -f /tmp/forcepkgremove.txt ];then
  713.  if [ "$PKGS2REM" = "" ];then
  714.   PKGS2REM="`cat /tmp/forcepkgremove.txt`"
  715.  else
  716.   PKGS2REM="$PKGS2REM
  717. `cat /tmp/forcepkgremove.txt`"
  718.  fi
  719. fi
  720.  
  721. #also handle alien package removal...
  722. RETTAGS="`cat /tmp/rettags.txt`"
  723. if [ -f ./alienpackages.txt ];then
  724.  REDUCELIST="`cat ./alienpackages.txt`"
  725.  while [ ! "$REDUCELIST" = "" ];do
  726.   HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  727.   APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  728.   BPATTERN="\"${APKGNAME}\" "
  729.   REDUCELIST="`echo "$REDUCELIST" | grep -v "$BPATTERN"`"
  730.   if [ "`cat /tmp/rettags.txt | grep "$APKGNAME"`" = "" ];then
  731.    if [ "$PKGS2REM" = "" ];then
  732.     PKGS2REM="`cat ./alienpackages.txt | grep "$BPATTERN"`"
  733.    else
  734.     PKGS2REM="$PKGS2REM
  735. `cat ./alienpackages.txt | grep "$BPATTERN"`"
  736.    fi
  737.    #delete entry...
  738.    cat ./alienpackages.txt | grep -v "$BPATTERN" > /tmp/alienpackages.txt
  739.    sync
  740.    cp -f /tmp/alienpackages.txt ./alienpackages.txt
  741.   fi
  742.  done
  743.  sync
  744. fi
  745.  
  746. #how to uninstall?
  747. #how to install?
  748. #the working directory is /root/.packages/, i think will expand a package here first, extract a filelist,
  749. #then move it to destination...
  750.  
  751.  
  752. if [ ! "$PKGS2REM" = "" ];then
  753.  #v1.0.3 hiccup, see patch above, it is possible we can get duplicate entries here, if a pkg
  754.  #is listed in both alienpackages.txt and livepackages.txt. use sort...
  755.  PKGREMNAMES="`echo "$PKGS2REM" | cut -f 1 -d " " | sort -u | tr "\n" " "`"
  756.  if [ ! "$DISABLEDX" = "yes" ];then
  757.  xmessage -center -name "pupget" -bg "orange" "You have chosen to remove these packages from Puppy:
  758. $PKGREMNAMES
  759.  
  760. Press OK button..."
  761.   xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait..." &
  762.  fi
  763.  
  764. # #v1.0.6 if remove a w.m., leave its menu config file behind...
  765. #     cp -f /root/.fvwm95rc /tmp/fvwm95rcBACKUP
  766. #     cp -f /root/.jwmrc /tmp/jwmrcBACKUP
  767. #     cp -f /root/.icewm/menu /tmp/icemenuBACKUP
  768.  
  769.  XREDUCELIST="$PKGS2REM"
  770.  while [ ! "$XREDUCELIST" = "" ];do #WHILE-103A
  771.   HEAD1ST="`echo "$XREDUCELIST" | head -n 1`"
  772.   APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  773.   QAPKGNAMEQ="\"${APKGNAME}\""
  774.   XREDUCELIST="`echo "$XREDUCELIST" | grep -v "$QAPKGNAMEQ"`"
  775.   #$APKGNAME.files has the file list for the package...
  776.   if [ -f $WKGDIR/$APKGNAME.files ];then #103B
  777.  
  778.    #v1.0.6 do not remove w.m. menu config files...
  779.    cat $WKGDIR/$APKGNAME.files | grep -v "\\.icewm/menu" | grep -v "\\.jwmrc" | grep -v "\\.fvwm95rc" > /tmp/removefileslist.txt
  780.    sync
  781.    cp -f /tmp/removefileslist.txt $WKGDIR/$APKGNAME.files
  782.  
  783.    for ONEFILE in `cat ./$APKGNAME.files`
  784.    do
  785.     ##do not delete from /usr, as unionfs may create a "deletion file" to hide
  786.     ##an underlying file in usr_cram.fs. Delete from /root/.usr...
  787.     #ONEFILE="`echo -n "$ONEFILE" | sed -e 's/\/usr\//\/root\/.usr\//g'`"
  788.     #...v2.0.0 no, cannot do this in puppy2.
  789.     #.files file may be malformed. check entry is a genuine file...
  790.     if [ -e $ONEFILE ];then
  791.      if [ ! -d $ONEFILE ];then
  792.       #v2.0.0
  793.       if [ -f /initrd/pup_ro2$ONEFILE ];then
  794.        #the problem is, deleting the file on the top layer places a ".wh" whiteout file,
  795.        #that hides the original file. what we want is to remove the installed file, and
  796.        #restore the original pristine file...
  797.        cp -af /initrd/pup_ro2$ONEFILE $ONEFILE
  798.       else
  799.        rm -f $ONEFILE
  800.       fi
  801.       #v2.0.0 also, delete empty dirs...
  802.       DELDIR="`dirname $ONEFILE`"
  803.       [ "`ls -1 $DELDIR`" = "" ] && rmdir $DELDIR
  804.      fi
  805.     fi
  806.    done
  807.    if [ -f ./$APKGNAME.remove ];then
  808.     ./$APKGNAME.remove
  809.    fi
  810.    if [ -f ./$APKGNAME.keyword ];then
  811.     #code here to remove menu entries etc...
  812.     #if it's a forced removal, due to same package existing in live-cd, don't want to
  813.     #remove from menus...
  814.     CPATTERN="\"${APKGNAME}\""
  815.     if [ "`cat /tmp/forcepkgremove.txt | grep "$CPATTERN"`" = "" ];then
  816.       AKEYWORD="`cat ./$APKGNAME.keyword`"
  817.  
  818.       #v1.0.5
  819.       /usr/sbin/fixmenus /root \-$AKEYWORD
  820.  
  821.     fi
  822.    fi
  823.    rm -f ./$APKGNAME.*
  824.    if [ ! "$DISABLEDX" = "yes" ];then
  825.     xmessage -name "pupget" -bg "#80ff80" -center -title "PupGet" "SUCCESS: $APKGNAME is removed!
  826.  
  827. Note: After exiting from PupGet, it is recommended that you reboot
  828.       Puppy to fully remove all traces of the uninstalled package."
  829.    fi
  830.    sync
  831.   fi #103B
  832.  done #WHILE-103A
  833.  
  834. # #v1.0.6 now restore w.m. config files...
  835. #     cp -f /tmp/fvwm95rcBACKUP /root/.fvwm95rc
  836. #     cp -f /tmp/jwmrcBACKUP /root/.jwmrc
  837. #     cp -f /tmp/icemenuBACKUP /root/.icewm/menu
  838.  
  839.  if [ ! "$DISABLEDX" = "yes" ];then
  840.   killall xmessage
  841.  fi
  842. fi
  843.  
  844.  
  845. if [ ! "$PKGS2ADD" = "" ];then
  846.  PKGADDNAMES="`echo "$PKGS2ADD" | cut -f 1 -d " " | tr "\n" " "`"
  847.  STARTMSG=""
  848.  BKCOLOR="orange"
  849.  while [ 1 ];do
  850.   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:
  851. $PKGADDNAMES
  852.  
  853. Please connect to the Internet then press a button to choose download site.
  854. If you click on \"Local\" button, the packages must already be downloaded,
  855. that is, somewhere local."
  856.   RETVAL=$?
  857.   WWWSITE=""
  858.   if [ $RETVAL -eq 10 ];then
  859.    WWWSITE="ibiblio.org"
  860.   fi
  861.   if [ $RETVAL -eq 11 ];then
  862.    WWWSITE="ftp.nluug.nl"
  863.   fi
  864.   if [ ! "$WWWSITE" = "" ];then
  865.     ping -c 1 -q $WWWSITE
  866.     if [ ! $? -eq 0 ];then
  867.      #v1.0.5 GuestToo has suggested another test...
  868.      if wget -t 2 -T 20 --waitretry=20 --spider -S $WWWSITE -o /dev/stdout | grep '200 OK'
  869.      then
  870.       echo "$WWWSITE is online"
  871.      else
  872.       BKCOLOR="#FF8080"
  873.       STARTMSG="ERROR: $WWWSITE IS UNREACHABLE!
  874. ...are you connected to the Internet?
  875. ...maybe that site is down? Try another.
  876.  
  877. "
  878.       continue
  879.      fi
  880.     fi
  881.   fi
  882.   break
  883.  done
  884.  case $RETVAL in
  885.  10)
  886.   #PKGSRC="ftp://ibiblio.org/pub/Linux/distributions/puppylinux/puppy-${RIGHTVER}/packages"
  887.   PKGSRC="ftp://ibiblio.org/pub/Linux/distributions/puppylinux/pupget_packages-1"
  888.   ;;
  889.  11)
  890.   #PKGSRC="http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/puppy-${RIGHTVER}/packages"
  891.   PKGSRC="http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/pupget_packages-1"
  892.   ;;
  893.  19) #Local
  894.   LOCALDIR="`Xdialog --title "PupGet: Choose local directory" --stdout --no-buttons --dselect "/root" 0 0`"
  895.   if [ ! $? -eq 0 ];then
  896.    exit
  897.   fi
  898.   sync
  899.   KEEPGOING="no"
  900.   for ONEFILE in `echo "$PKGS2ADD" | cut -f 2 -d '"' | tr "\n" " "`
  901.   do
  902.    cp -af ${LOCALDIR}/${ONEFILE}.tar.gz /root/.packages/
  903.    if [ ! $? -eq 0 ];then
  904.     xmessage -center -name "pupget" -bg "#ff8080" -title "PupGet: Local pkg error" "
  905. ERROR: file ${ONEFILE}.tar.gz is not in folder $LOCALDIR"
  906.    else
  907.     KEEPGOING="yes"
  908.    fi
  909.    sync
  910.   done
  911.   #keep going even if found one pkg...
  912.   if [ "$KEEPGOING" = "no" ];then
  913.    exit
  914.   fi
  915.   PKGSRC="."
  916.   ;;
  917.  *)
  918.   exit
  919.   ;;
  920.  esac
  921.   
  922.  xmessage -center -bg "orange" -title "PupGet" -buttons "" "Processing, please wait...
  923. Note: If wget has connected to the remote site then become \"stuck\",
  924.       just wait, as wget will keep retrying until download is successful." &
  925.  
  926.  XREDUCELIST="$PKGS2ADD"
  927.  while [ ! "$XREDUCELIST" = "" ];do
  928.   HEAD1ST="`echo "$XREDUCELIST" | head -n 1`"
  929.   APKGNAME="`echo "$HEAD1ST" | cut -f 2 -d '"'`"
  930.   QAPKGNAMEQ="\"${APKGNAME}\""
  931.   XREDUCELIST="`echo "$XREDUCELIST" | grep -v "$QAPKGNAMEQ"`"
  932.   if [ ! "$PKGSRC" = "." ];then
  933.    rm -f ./${APKGNAME}.tar.gz #precaution.
  934.    rxvt -name pupget -bg orange -geometry 80x10 -e wget $PKGSRC/${APKGNAME}.tar.gz
  935.   fi
  936.   sync
  937.   RETSTATUS=0
  938.   if [ -f ./${APKGNAME}.tar.gz ];then
  939.    if [ "`gzip --test --verbose ${APKGNAME}.tar.gz 2>&1 | grep "OK"`" = "" ];then
  940.     RETSTATUS=1
  941.    else
  942.     tar -zxf ./$APKGNAME.tar.gz
  943.     if [ $? -eq 0 ];then
  944.      APATTERN="s/.\/$APKGNAME//g"
  945.      #a problem, if pkg has a symbolic link to an absolute path to a file, that is not yet
  946.      #installed, it won't be included in the .files file...
  947.      #so, instead of "-xtype f" will have two finds...
  948.      #finds regular files only...
  949.      find ./$APKGNAME -type f -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' > ./$APKGNAME.files
  950.      sync
  951.      #finds symbolic links only...
  952.      find ./$APKGNAME -type l -mount -mindepth 2 | sed -e "$APATTERN" | sed -e 's/\/root0\//\/root\//g' >> ./$APKGNAME.files
  953.      #this does actual instal...
  954.      installpkgfunc #function call.
  955.     else
  956.      RETSTATUS=1
  957.     fi
  958.    fi
  959.   else
  960.    RETSTATUS=1
  961.   fi
  962.   if [ $RETSTATUS -eq 1 ];then
  963.     xmessage -name "pupget" -bg "#ff8080" -center -title "PupGet" "FAILURE: $APKGNAME.tar.gz was not downloaded successfully"
  964.     rm -f ./${APKGNAME}.tar.gz 2> /dev/null
  965.     #also need to turn "off" in livepackages.txt...
  966.     #well, could just delete the line, as it will get added back in from packages.txt next
  967.     #time run this script...
  968.     DPATTERN="\"$APKGNAME\""
  969.     cat $WKGDIR/livepackages.txt | grep -v "$DPATTERN" > /tmp/livepackages.txt
  970.     sync
  971.     rm -f $WKGDIR/livepackages.txt
  972.     mv /tmp/livepackages.txt $WKGDIR/livepackages.txt
  973.     rm ${WKGDIR}/${APKGNAME}.* 2> /dev/null
  974.   fi
  975.  done
  976.  sync
  977.  killall xmessage
  978. fi
  979.  
  980. ##END##
  981.