s243a

/usr/local/petget/installpreview.sh

Feb 15th, 2020
1,668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 20.94 KB | None | 0 0
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2009, puppylinux.com
  3. #2009 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html).
  4. #called from pkg_chooser.sh
  5. #package to be previewed prior to installation is TREE1 -- inherited from parent.
  6. #/tmp/petget_proc/petget/current-repo-triad has the repository that installing from.
  7. #101221 yaf-splash fix.
  8. #120101 01micko: jwm >=547 has -reload, no screen flicker.
  9. #120116 rev. 514 introduced icon rendering method which broke -reload at 547. fixed at rev. 574.
  10. #120203 BK: internationalized.
  11. #120504 if no pkgs in category, then when click in window in main dlg, comes here with TREE1="".
  12. #120504 select correct repo when have chosen a pkg from multiple-repo list.
  13. #120604 fix for prepended icons field.
  14. #120811 category field now supports sub-category |category;subcategory|, use as icon in ppm main window.
  15. #120827 if pkg already installed, do not examine dependencies (doesn't work).
  16. #120903 ubuntu, have lots pkgs installed, check_deps.sh takes ages, remove for now, need to rewrite in C.
  17. #120904 "examine dependencies" button did not create any /tmp/petget_proc/petget_missing_dbentries-*, workaround.
  18. #120905 better advice if too many deps. 120907 revert.
  19. #120907 max frames increase 5 to 10. Note, precise puppy gave 72 deps for vlc, which would require 10 frames.
  20. #130511 popup warning if a dep in devx but devx not loaded.
  21.  
  22. . /etc/rc.d/functions_x
  23.  
  24. [ "$(cat /var/local/petget/nt_category 2>/dev/null)" != "true" ] && \
  25.  [ -f /tmp/petget_proc/install_quietly ] && set -x
  26.  #; mkdir -p /tmp/petget_proc/PPM_LOGs ; NAME=$(basename "$0"); exec 1>> /tmp/petget_proc/PPM_LOGs/"$NAME".log 2>&1
  27.  
  28. export TEXTDOMAIN=petget___installpreview.sh
  29. export OUTPUT_CHARSET=UTF-8
  30.  
  31. [ "$TREE1" = "" ] && exit #120504 nothing to install.
  32.  
  33. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  34. . /root/.packages/DISTRO_PKGS_SPECS
  35.  
  36. if [ ! -f /tmp/petget_proc/install_quietly ]; then
  37.  . /usr/lib/gtkdialog/box_splash -close never -text "$(gettext 'Please wait, processing package database files...')" &
  38.  X1PID=$!
  39. fi
  40.  
  41. #ex: TREE1=abiword-1.2.4 (first field in database entry).
  42. DB_FILE=Packages-`cat /tmp/petget_proc/petget/current-repo-triad` #ex: Packages-slackware-12.2-official
  43. tPATTERN='^'"$TREE1"'|'
  44.  
  45. #120827 'examine dependencies' button does not work if pkg already installed...
  46. EXAMDEPSFLAG='yes'
  47. ttPTN='^'"$TREE1"'|.*ALREADY INSTALLED'
  48. if [ "`grep "$ttPTN" /tmp/petget_proc/petget/filterpkgs.results.post`" != "" ];then #created by postfilterpkgs.sh
  49.  EXAMDEPSFLAG='no'
  50. fi
  51.  
  52. #120504 if findnames.sh searched multiple repos, /tmp/petget_proc/petget/current-repo-triad (set in pkg_chooser.sh) might be wrong...
  53. [ -f /tmp/petget_proc/petget/current-repo-triad.previous ] && rm -f /tmp/petget_proc/petget/current-repo-triad.previous
  54. if [ -f /tmp/petget_proc/petget/filterpkgs.results.post ];then
  55.   ALTSEARCHREPO="$(grep "$tPATTERN" /tmp/petget_proc/petget/filterpkgs.results.post | grep '|\[' | cut -f 2 -d '[' | cut -f 1 -d ']')"
  56.  [ "$ALTSEARCHREPO" ] && DB_FILE="Packages-${ALTSEARCHREPO}"
  57.  #hmmm, other scripts, ex dependencies.sh, will need to have this correct...
  58.  if [ "$ALTSEARCHREPO" ];then
  59.   mv -f /tmp/petget_proc/petget/current-repo-triad /tmp/petget_proc/petget/current-repo-triad.previous #need to restore old one before exit this script.
  60.   echo -n "$ALTSEARCHREPO" > /tmp/petget_proc/petget/current-repo-triad
  61.  fi
  62. fi
  63.  
  64. rm -f /tmp/petget_proc/petget_missing_dbentries-* 2>/dev/null
  65.  
  66. DB_ENTRY="`grep "$tPATTERN" /root/.packages/$DB_FILE | head -n 1`"
  67. #line format: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|
  68. #optionally on the end: compileddistro|compiledrelease|repo| (fields 11,12,13)
  69.  
  70. IFS="|" read F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 etc <<< "$DB_ENTRY"
  71.  
  72. DB_pkgname="$F1"
  73. DB_nameonly="$F2"
  74. DB_version="$F3"
  75. DB_pkgrelease="$F4"
  76. DB_category="$F5"
  77. DB_size="$F6"
  78. DB_path="$F7"
  79. DB_fullfilename="$F8"
  80. DB_dependencies="$F9"
  81. DB_description="$F10"
  82.  
  83. [ "$DB_description" = "" ] && DB_description="$(gettext 'no description available')"
  84.  
  85. SIZEFREEM=$(fx_personal_storage_free_mb)
  86. SIZEFREEK=$(( $SIZEFREEM * 1024))
  87.  
  88. if [ $DB_size ];then
  89.  SIZEMK="`echo -n "$DB_size" | rev | cut -c 1`"
  90.  SIZEVAL=${DB_size%[A-Z]} #remove suffix: K M B .. etc
  91.  SIZEINFO="<text><label>$(gettext 'SIZE:') ${SIZEVAL}${SIZEMK}B. $(gettext 'The amount of free space that you have for installation is') ${SIZEFREEM}MB.</label></text>"
  92.  SIZEVALz=$(( $SIZEVAL / 3))
  93.  SIZEVALz=$(( $SIZEVAL + $SIZEVALz ))
  94.  SIZEVALx2=$(( $SIZEVALz + 10000 ))
  95.  if [ $SIZEVALx2 -ge $SIZEFREEK ];then
  96.   MSGWARN1="${SIZEINFO}<text use-markup=\"true\"><label>\"<b>$(gettext "A general rule-of-thumb is that the free space should be at least the original-package-size plus installed-package-size plus 10MB to allow for sufficient working space during and after installation. It does not look to good, so you had better click the 'Cancel' button")</b> -- $(gettext "note, if you are running Puppy in a mode that has a 'pupsave' file, then the Utility menu has an entry 'Resize personal storage file' that should solve the problem.")\"</label></text>"
  97.  else
  98.   MSGWARN1="${SIZEINFO}<text use-markup=\"true\"><label>\"<b>$(gettext "...free space looks ok, so click 'Install' button:")</b>\"</label></text>"
  99.  fi
  100. else
  101.  MSGWARN1="<text use-markup=\"true\"><label>\"<b>$(gettext 'Unfortunately the provider of the package database has not supplied the size of this package when installed. If you are able to see the size of the compressed package, multiple that by 3 to get the approximate installed size. The free available space, which is') ${SIZEFREEM}MB (${SIZEFREEK}KB), $(gettext 'should be at least 4 times greater.')</b>\"</label></text>"
  102. fi
  103.  
  104.  
  105. #find missing dependencies...
  106. if [ "$DB_dependencies" = "" ];then
  107.  DEPINFO="<text><label>$(gettext 'It seems that all dependencies are already installed. Sometimes though, the dependency information in the database is incomplete, however a check for presence of needed shared libraries will be done after installation.')</label></text>"
  108. else
  109.  
  110.  #find all missing pkgs...
  111.  /usr/local/petget/findmissingpkgs.sh "$DB_dependencies"
  112.  #...returns /tmp/petget_proc/petget_installed_patterns_all, /tmp/petget_proc/petget_pkg_deps_patterns, /tmp/petget_proc/petget_missingpkgs_patterns
  113.  MISSINGDEPS_PATTERNS="`cat /tmp/petget_proc/petget_missingpkgs_patterns`"
  114.  #/tmp/petget_proc/petget_missingpkgs_patterns has a list of missing dependencies, format ex:
  115.  #|kdebase|
  116.  #|kdelibs|
  117.  #|mesa|
  118.  #|qt|
  119.  
  120.  DEPBUTTON=""
  121.  ONLYMSG=""
  122.  if [ "$MISSINGDEPS_PATTERNS" = "" ];then
  123.   DEPINFO="<text><label>$(gettext 'It seems that all dependencies are already installed. Sometimes though, the dependency information in the database is incomplete, however a check for presence of needed shared libraries will be done after installation.')</label></text>"
  124.   EXAMDEPSFLAG=no
  125.  else
  126.   EXAMDEPSFLAG=yes
  127.  fi
  128. fi
  129.  
  130. [ ! -f /tmp/petget_proc/install_quietly ] && kill $X1PID || echo
  131.  
  132. if [ ! -f /tmp/petget_proc/install_quietly ] ; then
  133.  if [ "$EXAMDEPSFLAG" = "yes" ] ; then
  134.    EXIT=BUTTON_EXAMINE_DEPS
  135.  else
  136.    export PREVIEW_DIALOG='
  137. <window title="'$(gettext 'Package Manager: preinstall')'" icon-name="gtk-about">
  138. <vbox space-expand="true" space-fill="true">
  139. <frame>
  140.  <text space-expand="true" space-fill="true" use-markup="true"><label>"'$(gettext 'PKG to install:')' <b>'${TREE1}'</b>."</label></text>
  141.  <text space-expand="true" space-fill="true" use-markup="true"><label>"'$(gettext 'Description: ')'<b>'${DB_description}'</b>"</label></text>
  142.  '${DEPINFO}'
  143.  '${MSGWARN1}'
  144.  <hbox space-expand="true" space-fill="true">
  145.   <text space-expand="true" space-fill="true"><label>"'$(gettext 'More info.. such as what it is for and the dependencies...')'"</label></text>
  146.   <button>
  147.     '$(/usr/lib/gtkdialog/xml_button-icon internet.svg big)'
  148.     <action>/usr/local/petget/fetchinfo.sh '${TREE1}' & </action>
  149.   </button>
  150.  </hbox>
  151. </frame>
  152.  
  153. <hbox>
  154.  '${DEPBUTTON}'
  155.  <button>
  156.   <input file stock=\"gtk-go-down\"></input>
  157.   <label>'$(gettext 'Install')' PKG '${ONLYMSG}'</label>
  158.   <action>echo "'${TREE1}'" > /tmp/petget_proc/petget_installpreview_pkgname</action>
  159.   <action type="exit">BUTTON_INSTALL</action>
  160.  </button>
  161.  <button>
  162.   <input file stock=\"gtk-go-down\"></input>
  163.   <label>'$(gettext 'Download-only')'</label>
  164.   <action type="exit">BUTTON_PKGS_DOWNLOADONLY</action>
  165.  </button>
  166.  <button cancel></button>
  167. </hbox>
  168. </vbox>
  169. </window>
  170. '
  171.   RETPARAMS="`gtkdialog --center --program=PREVIEW_DIALOG`"
  172.  fi
  173. else
  174.  if [ -f /tmp/petget_proc/download_only_pet_quietly ]; then
  175.   RETPARAMS='EXIT="BUTTON_PKGS_DOWNLOADONLY"'
  176.  elif [ "$MISSINGDEPS_PATTERNS" != "" ];then
  177.   RETPARAMS='EXIT="BUTTON_EXAMINE_DEPS"'
  178.  elif [ -f /tmp/petget_proc/download_pets_quietly ]; then
  179.   RETPARAMS='EXIT="BUTTON_PKGS_DOWNLOADONLY"'
  180.  else
  181.   RETPARAMS='EXIT="BUTTON_INSTALL"'
  182.  fi
  183. fi
  184.  
  185. eval "$RETPARAMS"
  186. case $EXIT in abort|Cancel)
  187.     exit 100 ;;
  188. esac
  189.  
  190. if [ "$EXIT" != "BUTTON_INSTALL" -a "$EXIT" != "BUTTON_EXAMINE_DEPS" -a "$EXIT" != "BUTTON_PKGS_DOWNLOADONLY" ];then
  191.  [ -f /tmp/petget_proc/petget/current-repo-triad.previous ] && mv -f /tmp/petget_proc/petget/current-repo-triad.previous /tmp/petget_proc/petget/current-repo-triad
  192.  exit
  193. fi
  194.  
  195. #DB_ENTRY has the database entry of the main package that we want to install.
  196. #DB_FILE has the name of the database file that has the main entry, ex: Packages-slackware-12.2-slacky
  197. if [ "$EXAMDEPSFLAG" = "yes" ] ; then
  198.  /usr/local/petget/dependencies.sh
  199.  [ $? -ne 0 ] && exec /usr/local/petget/installpreview.sh #reenter.
  200.  #returns with /tmp/petget_proc/petget_missing_dbentries-* has the database entries of missing deps.
  201.  #the '*' on the end is the repo-file name, ex: Packages-slackware-12.2-slacky
  202.  
  203.  #120904
  204.  FNDMISSINGDBENTRYFILE="`ls -1 /tmp/petget_proc/petget_missing_dbentries-* 2>/dev/null`"
  205.  if [ "$FNDMISSINGDBENTRYFILE" = "" -a ! -f /tmp/petget_proc/install_quietly ];then
  206.   . pupdialog --title "$(gettext 'PPM: examine dependencies')" --background LightYellow --msgbox "$(gettext 'There seem to be no missing dependencies.')
  207.  
  208. $(gettext 'Note: if the previous window indicated that there are missing dependencies, they were not found. Sometimes, a package database lists a dependency that does not actually exist anymore and is not required.')" 0 0
  209.   exec /usr/local/petget/installpreview.sh #reenter.
  210.  fi
  211.  
  212.  #130511 popup warning if a dep in devx but devx not loaded...
  213.  if ! which gcc; then
  214.   NEEDGCC="$(cat /tmp/petget_proc/petget_missing_dbentries-* | grep -E '\|gcc\||\|gcc_dev_DEV\|' | cut -f 1 -d '|')"
  215.   if [ "$NEEDGCC" ];then
  216.    rm -f /tmp/petget_proc/petget_installed_patterns_system #see pkg_chooser.sh
  217.    #create a separate process for the popup, with delay...
  218.    DEVXNAME="devx_${DISTRO_FILE_PREFIX}_${DISTRO_VERSION}.sfs"
  219.    echo "#!/bin/sh
  220. sleep 3
  221. . pupdialog --background pink --colors --ok-label \"$(gettext 'OK')\" --backtitle \"$(gettext 'WARNING: devx not installed')\" --msgbox \"$(gettext 'Package:')  \Zb${TREE1}\ZB
  222. $(gettext "This package has dependencies that are in the 'devx' SFS file, which is Puppy's C/C++/Vala/Genie/BaCon mega-package, a complete compiling environment.")
  223.  
  224. $(gettext 'The devx file is named:') \Zb${DEVXNAME}\ZB
  225.  
  226. $(gettext "Please cancel installation, close the Puppy Package Manager, then click the \Zbinstall\ZB icon on the desktop and install the devx SFS file first.")\" 0 0" > /tmp/petget_proc/petget_devx_popup.sh #'geany
  227.    chmod 755 /tmp/petget_proc/petget_devx_popup.sh
  228.    /tmp/petget_proc/petget_devx_popup.sh &
  229.   fi
  230.  fi
  231.  
  232.  #compose pkgs into checkboxes...
  233.  MAIN_REPO="`echo "$DB_FILE" | cut -f 2-9 -d '-'`"
  234.  MAINPKG_NAME="`echo "$DB_ENTRY" | cut -f 1 -d '|'`"
  235.  MAINPKG_SIZE="`echo "$DB_ENTRY" | cut -f 6 -d '|'`"
  236.  MAINPKG_DESCR="`echo "$DB_ENTRY" | cut -f 10 -d '|'`"
  237.  MAIN_CHK="<checkbox><default>true</default><label>${MAINPKG_NAME} SIZE: ${MAINPKG_SIZE}B [${MAINPKG_DESCR}]</label><variable>CHECK_PKG_${MAIN_REPO}_${MAINPKG_NAME}</variable></checkbox>"
  238.  INSTALLEDSIZEK=0
  239.  [ "$MAINPKG_SIZE" != "" ] && INSTALLEDSIZEK=${INSTALLEDSIZEK%[A-Z]} #remove suffix: K M B .. etc
  240.  
  241.  echo -n "" > /tmp/petget_proc/petget_moreframes
  242.  DEP_CNT=0
  243.  ONEREPO=""
  244.  for ONEDEPSLIST in `ls -1 /tmp/petget_proc/petget_missing_dbentries-*`
  245.  do
  246.   ONEREPO_PREV="$ONEREPO"
  247.   ONEREPO="`echo "$ONEDEPSLIST" | grep -o 'Packages.*' | sed -e 's%Packages\\-%%'`"
  248.   DEP_CNT=0
  249.   while IFS="|" read F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 ETC
  250.   do
  251.    DEP_NAME=$F1
  252.    DEP_SIZE=$F6
  253.    DEP_DESCR=$F10
  254.    DEP_CNT=$(( $DEP_CNT + 1))
  255.    if [ $DEP_CNT -gt 100 ] ; then
  256.       echo -n "<text use-markup=\"true\"><label>\"<b>$(gettext 'SORRY! Too many dependencies, list truncated. Suggest click Cancel button and install some deps first.')</b>\"</label></text>" >> /tmp/petget_proc/petget_moreframes #120907
  257.       break
  258.    else
  259.       echo -n "<checkbox><default>true</default><label>${DEP_NAME} SIZE: ${DEP_SIZE}B  [${DEP_DESCR}]</label><variable>CHECK_PKG_${ONEREPO}_${DEP_NAME}</variable></checkbox>" >> /tmp/petget_proc/petget_moreframes
  260.    fi
  261.    ADDSIZEK=0
  262.    [ "$DEP_SIZE" != "" ] && ADDSIZEK=${DEP_SIZE%[A-Z]} #remove suffix: K M B .. etc
  263.    INSTALLEDSIZEK=$(echo "$INSTALLEDSIZEK + $ADDSIZEK" | bc )
  264.    echo "$INSTALLEDSIZEK" > /tmp/petget_proc/petget_installedsizek
  265.   done < $ONEDEPSLIST
  266.   INSTALLEDSIZEK=`cat /tmp/petget_proc/petget_installedsizek`
  267.  done
  268.  MOREFRAMES="`cat /tmp/petget_proc/petget_moreframes`"
  269.  
  270.  INSTALLEDSIZEM=$(echo "$INSTALLEDSIZEK / 1024" | bc)
  271.  MSGWARN2="$(gettext "If that looks OK, click the 'Install' button...")"
  272.  testSIZEK=$(echo "$INSTALLEDSIZEK / 3" | bc )
  273.  testSIZEK=$(echo "$INSTALLEDSIZEK + $testSIZEK" | bc)
  274.  testSIZEK=$(echo "$testSIZEK + 8000" | bc)
  275.  testSIZEK=$(printf "%.0f\n" $testSIZEK) #https://bits.mdminhazulhaque.io/linux/round-number-in-bash-script.html
  276.  [ $testSIZEK -gt $SIZEFREEK ] && MSGWARN2="$(gettext "Not too good! recommend that you make more space before installing -- see 'Resize personal storage file' in the 'Utility' menu.")"
  277. if [ ! -f /tmp/petget_proc/install_quietly ]; then
  278.  export DEPS_DIALOG="<window title=\"$(gettext 'Puppy Package Manager: dependencies')\" icon-name=\"gtk-about\">
  279. <vbox>
  280.  
  281. <frame REPOSITORY: ${MAIN_REPO}>
  282.  ${MAIN_CHK}
  283. </frame>
  284. <frame Dependencies>
  285. <hbox space-expand=\"true\" space-fill=\"true\">
  286.  <vbox scrollable=\"true\" shadow-type=\"0\" border-width=\"10\" space-expand=\"true\" space-fill=\"true\">
  287.    ${MOREFRAMES}
  288.  </vbox>
  289. </hbox>
  290. </frame>
  291.  
  292. <hbox>
  293.   <text space-expand=\"true\" space-fill=\"true\"><label>Number of missing depedencies: $DEP_CNT</label></text>
  294.   <button space-expand=\"true\" space-fill=\"false\">
  295.    <input file stock=\"gtk-dialog-info\"></input>
  296.    <label>$(gettext 'View hierarchy of dependencies')</label>
  297.    <action>/usr/local/bin/defaulttextviewer /tmp/petget_proc/petget_deps_visualtreelog & </action>
  298.   </button>
  299. </hbox>
  300.  
  301. <frame>
  302.  <hbox space-expand=\"true\" space-fill=\"true\">
  303.   <text space-expand=\"true\" space-fill=\"true\"><label>$(gettext "Sometimes Puppy's automatic dependency checking comes up with a list that may include packages that don't really need to be installed, if you spot one that does not need to be installed, then un-tick it.")</label></text>
  304.  </hbox>
  305.  <hbox space-expand=\"true\" space-fill=\"true\">
  306.   <text use-markup=\"true\"><label>\"<b>$(gettext 'If all of the above packages are selected, the total installed size will be') ${INSTALLEDSIZEM}MB. $(gettext 'Free space:') ${SIZEFREEM}MB. ${MSGWARN2}</b>\"</label></text>
  307.  </hbox>
  308. </frame>
  309.  
  310. <hbox space-expand=\"true\" space-fill=\"true\">
  311.  <button>
  312.   <input file stock=\"gtk-go-down\"></input>
  313.   <label>$(gettext 'DOWNLOAD ONLY')</label>
  314.   <action type=\"exit\">BUTTON_PKGS_DOWNLOADONLY</action>
  315.  </button>
  316.  <button>
  317.   <input file stock=\"gtk-go-down\"></input>
  318.   <label>$(gettext 'INSTALL selected pkgs')</label>
  319.   <action type=\"exit\">BUTTON_PKGS_INSTALL</action>
  320.  </button>
  321.  <button cancel></button>
  322. </hbox>
  323. </vbox>
  324. </window>
  325. "
  326.  RETPARAMS="`gtkdialog --center --program=DEPS_DIALOG`"
  327.  eval "$RETPARAMS"
  328.  case $EXIT in abort|Cancel)
  329.     exit 100 ;;
  330.  esac
  331.  
  332. else
  333.  if [ ! -f /tmp/petget_proc/download_pets_quietly ]; then
  334.  xEXIT="BUTTON_PKGS_INSTALL"
  335.  else
  336.  xEXIT="BUTTON_PKGS_DOWNLOADONLY"
  337.  fi
  338.   DEPS_TOINSTALL=$(sed 's/<variable>/\n/g' /tmp/petget_proc/petget_moreframes \
  339.    |grep ^CHECK_PKG_ | cut -f1 -d '<' | sed 's/$/=\"true\"/')
  340.   PKG_TOINSTALL=CHECK_PKG_${MAIN_REPO}_${MAINPKG_NAME}="true"
  341.   RETPARAMS="$DEPS_TOINSTALL
  342. $PKG_TOINSTALL
  343. EXIT=$xEXIT"
  344.   [ "$DEPS_TOINSTALL" != "" ] && echo "$DEPS_TOINSTALL"  | cut -f 1 -d '=' \
  345.    | cut -f 4-10 -d '_'  >> /tmp/petget_proc/pkgs_to_install_done
  346.   rm -f /tmp/petget_proc/petget_moreframes
  347. fi
  348.  
  349.  #example if 'Install' button clicked:
  350.  #CHECK_PKG_slackware-12.2-official_libtermcap-1.2.3="true"
  351.  #CHECK_PKG_slackware-12.2-official_pygtk-2.12.1="true"
  352.  #CHECK_PKG_slackware-12.2-slacky_beagle-0.3.9="true"
  353.  #CHECK_PKG_slackware-12.2-slacky_libgdiplus-2.0="true"
  354.  #CHECK_PKG_slackware-12.2-slacky_libgdiplus-2.2="true"
  355.  #CHECK_PKG_slackware-12.2-slacky_mono-2.2="true"
  356.  #CHECK_PKG_slackware-12.2-slacky_monodoc-2.0="true"
  357.  #EXIT="BUTTON_PKGS_INSTALL"
  358.  
  359.  if [ "`echo "$RETPARAMS" | grep '^EXIT' | grep -E 'BUTTON_PKGS_INSTALL|BUTTON_PKGS_DOWNLOADONLY'`" != "" ];then
  360.   #remove any unticked pkgs from the list...
  361.   for ONECHK in `echo "$RETPARAMS" | grep '^CHECK_PKG_' | grep '"false"' | tr '\n' ' '`
  362.   do
  363.    ONEREPO="`echo -n "$ONECHK" | cut -f 1 -d '=' | cut -f 3 -d '_'`" #ex: slackware-12.2-slacky
  364.    ONEPKG="`echo -n "$ONECHK" | cut -f 1 -d '=' | cut -f 4-9 -d '_'`"  #ex: libtermcap-1.2.3
  365.    opPATTERN='^'"$ONEPKG"'|'
  366.    grep -v "$opPATTERN" /tmp/petget_proc/petget_missing_dbentries-Packages-${ONEREPO} > /tmp/petget_proc/petget_tmp
  367.    mv -f /tmp/petget_proc/petget_tmp /tmp/petget_proc/petget_missing_dbentries-Packages-${ONEREPO}
  368.   done
  369.  else
  370.   [ -f /tmp/petget_proc/petget/current-repo-triad.previous ] && mv -f /tmp/petget_proc/petget/current-repo-triad.previous /tmp/petget_proc/petget/current-repo-triad #120504
  371.   exit
  372.  fi
  373. fi
  374. #come here, want to install pkg(s)...
  375.  
  376. #DB_ENTRY has the database entry of the main package that we want to install.
  377. #DB_FILE has the name of the database file that has the main entry, ex: Packages-slackware-12.2-slacky
  378. #TREE1 is name of main pkg, ex: abiword-1.2.3
  379.  
  380. #check to see if main pkg entry already in install-lists...
  381. touch /tmp/petget_proc/petget_missing_dbentries-${DB_FILE} #create if doesn't exist.
  382. mPATTERN='^'"$TREE1"'|'
  383. if [ "`grep "$mPATTERN" /tmp/petget_proc/petget_missing_dbentries-${DB_FILE}`" = "" ];then
  384.  echo "$DB_ENTRY" >> /tmp/petget_proc/petget_missing_dbentries-${DB_FILE}
  385. fi
  386.  
  387. #now do the actual install...
  388. PASSEDPRM=""
  389. if [ -f /tmp/petget_proc/download_only_pet_quietly ]; then
  390.   PASSEDPRM="DOWNLOADONLY"
  391.   touch /tmp/petget_proc/manual_pkg_download
  392. fi
  393. /usr/local/petget/downloadpkgs.sh $PASSEDPRM
  394. if [ $? -ne 0 ];then
  395.  if [ -f /tmp/petget_proc/petget/current-repo-triad.previous ] ; then
  396.    mv -f /tmp/petget_proc/petget/current-repo-triad.previous /tmp/petget_proc/petget/current-repo-triad #120504
  397.  fi
  398.  exit 1
  399. fi
  400. [ "$PASSEDPRM" = "DOWNLOADONLY" ] && exit
  401.  
  402. if [ -f /tmp/petget_proc/install_pets_quietly ]; then
  403.  LEFT=$(cat /tmp/petget_proc/pkgs_left_to_install | wc -l)
  404.  [ "$LEFT" -le 1 ] && UPDATE_MENUS=yes
  405. else
  406.   UPDATE_MENUS=yes
  407. fi
  408.  
  409. if [ "$UPDATE_MENUS" = "yes" ]; then
  410. INSTALLEDCAT="menu" #any string.
  411. [ "`cat /tmp/petget_proc/petget-installed-pkgs-log | grep -o 'CATEGORY' | grep -v 'none'`" = "" ] && INSTALLEDCAT="none"
  412. RESTARTMSG="$(gettext 'Please wait, updating help page and menu...')"
  413. [ "$INSTALLEDCAT" = "none" ] &&  RESTARTMSG="$(gettext 'Please wait, updating help page...')"
  414.  if [ ! -f /tmp/petget_proc/install_quietly ]; then
  415.   /usr/lib/gtkdialog/box_splash -text "${RESTARTMSG}" &
  416.   X3PID=$!
  417.  fi
  418. fi
  419.  
  420. #w091019 update image cache...
  421. iUPDATE='no'
  422. for iONE in `cat /tmp/petget_proc/petget_missing_dbentries-* | cut -f 1 -d '|' | tr '\n' ' '`
  423. do
  424.  if [ -f /root/.packages/${iONE}.files ]; then
  425.   [ "`grep 'usr/share/icons/hicolor' /root/.packages/${iONE}.files`" != "" ] \
  426.    && echo yes >> /tmp/petget_proc/iUPDATE
  427.  fi
  428. done
  429. if [ "$UPDATE_MENUS" = "yes" ]; then
  430.  if [ "$(grep yes /tmp/petget_proc/iUPDATE)" != "" ]; then \
  431.   gtk-update-icon-cache -f /usr/share/icons/hicolor/
  432.   rm -f /tmp/petget_proc/iUPDATE
  433.  fi
  434. fi
  435.  
  436. #Reconstruct configuration files for JWM, Fvwm95, IceWM...
  437. if [ "$UPDATE_MENUS" = "yes" -a "$INSTALLEDCAT" != "none" ];then
  438.  nohup /usr/sbin/fixmenus
  439.  [ "`pidof jwm`" != "" ] && { jwm -reload || jwm -restart ; }
  440. fi
  441. [ ! -f /tmp/petget_proc/install_quietly ] && kill $X3PID || echo
  442.  
  443. #120905 restore...
  444. #120903 ubuntu, have lots pkgs installed, this takes ages. remove for now, need to rewrite in C...
  445. #check any missing shared libraries...
  446. PKGS="`cat /tmp/petget_proc/petget_missing_dbentries-* | cut -f 1 -d '|' | tr '\n' '|'`"
  447. /usr/local/petget/check_deps.sh $PKGS
  448.  
  449. [ -f /tmp/petget_proc/petget/current-repo-triad.previous ] && mv -f /tmp/petget_proc/petget/current-repo-triad.previous /tmp/petget_proc/petget/current-repo-triad #120504
  450.  
  451. rm -f nohup.out 2>/dev/null
  452. ###END###
Advertisement
Add Comment
Please, Sign In to add comment