pkg_chooser.sh 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. #!/bin/bash
  2. #(c) Copyright Barry Kauler 2009, puppylinux.com
  3. #2009 Lesser GPL licence v2 (/usr/share/doc/legal/lgpl-2.1.txt).
  4. #The Puppy Package Manager main GUI window.
  5. VERSION=2
  6. #wait for indexgen.sh to finish
  7. while [ "$(ps | grep indexgen | grep -v grep)" != "" ];do sleep 0.5;done
  8. export TEXTDOMAIN=petget___pkg_chooser.sh
  9. export OUTPUT_CHARSET=UTF-8
  10. LANG1="${LANG%_*}" #ex: de
  11. HELPFILE="/usr/local/petget/help.htm"
  12. [ -f /usr/local/petget/help-${LANG1}.htm ] && HELPFILE="/usr/local/petget/help-${LANG1}.htm"
  13. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  14. # Do not allow another instance
  15. sleep 0.3
  16. [ "$( ps | grep -E '/usr/local/bin/ppm|/usr/local/petget/pkg_chooser' | grep -v -E 'grep|geany|leafpad' | wc -l)" -gt 2 ] \
  17. && . /usr/lib/gtkdialog/box_splash -timeout 3 -bg red -text "$(gettext 'PPM is already running. Exiting.')" \
  18. && exit 0
  19. # Set the skip-space flag
  20. if [ "$(cat /var/local/petget/sc_category 2>/dev/null)" = "true" ] && \
  21. [ "$(cat /tmp/pup_event_sizefreem | head -n 1 )" -gt 4000 ]; then
  22. touch /root/.packages/skip_space_check
  23. else
  24. rm -f /root/.packages/skip_space_check
  25. echo false > /var/local/petget/sc_category
  26. fi
  27. # Make sure the download folder exists and is writable
  28. if [ -f /root/.packages/download_path ]; then
  29. . /root/.packages/download_path
  30. [ ! -d "$DL_PATH" -o ! -w "$DL_PATH" ] && rm -f /root/.packages/download_path
  31. fi
  32. options_status () {
  33. [ -f /root/.packages/skip_space_check ] && \
  34. MSG_SPACE="$(gettext 'Do NOT check available space.')
  35. $(gettext '')"
  36. [ -f /root/.packages/download_path ] && [ "$DL_PATH" != "/root" ] && \
  37. MSG_DPATH="$(gettext 'Download packages in ')${DL_PATH}.
  38. $(gettext '')"
  39. [ "$(cat /var/local/petget/install_mode 2>/dev/null)" = "true" ] && \
  40. MSG_TEMPFS="$(gettext 'Save installed programs when we save to savefile.')
  41. $(gettext '')"
  42. [ "$(cat /var/local/petget/nt_category 2>/dev/null)" = "true" ] && \
  43. MSG_NOTERM="$(gettext 'Do NOT show terminal with PPM activity.')
  44. $(gettext '')"
  45. [ "$(cat /var/local/petget/db_verbose 2>/dev/null)" = "false" ] && \
  46. MSG_NODBTERM="$(gettext 'No user input during database updating.')
  47. $(gettext '')"
  48. [ "$(cat /var/local/petget/rd_category 2>/dev/null)" = "true" ] && \
  49. MSG_REDOWNL="$(gettext 'Redownload packages when already downloaded.')
  50. $(gettext '')"
  51. [ "$(cat /var/local/petget/nd_category 2>/dev/null)" = "true" ] && \
  52. MSG_SAVEPKG="$(gettext 'Do NOT delete packages after installation.')
  53. $(gettext '')"
  54. [ "$MSG_SPACE" -o "$MSG_DPATH" -o "$MSG_TEMPFS" -o "$MSG_NOTERM" -o \
  55. "$MSG_REDOWNL" -o "$MSG_SAVEPKG" -o "$MSG_NODBTERM" ] && \
  56. . /usr/lib/gtkdialog/box_ok "$(gettext 'PPM config options')" info "$(gettext 'PPM is currently running with these configuration options:')
  57. ${MSG_SPACE}${MSG_DPATH}${MSG_NOTERM}${MSG_NODBTERM}${MSG_REDOWNL}${MSG_SAVEPKG}${MSG_TEMPFS}"
  58. }
  59. export -f options_status
  60. [ "$(cat /var/local/petget/si_category 2>/dev/null)" = "true" ] && options_status
  61. . /usr/lib/gtkdialog/box_splash -close never -text "$(gettext 'Loading Puppy Package Manager...')" &
  62. SPID=$!
  63. # Remove in case we crashed
  64. clean_flags () {
  65. rm -f /tmp/{remove,install}{,_pets}_quietly 2>/dev/null
  66. rm -f /tmp/install_classic 2>/dev/null
  67. rm -f /tmp/download{_only,}_pet{,s}_quietly 2>/dev/null
  68. rm -f /tmp/overall_* 2>/dev/null
  69. rm -f /tmp/ppm_reporting 2>/dev/null
  70. rm -f /tmp/force{,d}_install 2>/dev/null
  71. rm -f /tmp/pkgs_to_install* 2>/dev/null
  72. rm -f /tmp/pkgs_DL_BAD_LIST 2>/dev/null
  73. unset SETUPCALLEDFROM
  74. }
  75. export -f clean_flags
  76. clean_flags
  77. /usr/local/petget/service_pack.sh & #121125 offer download Service Pack.
  78. mkdir -p /tmp/petget #120504
  79. mkdir -p /var/local/petget
  80. echo -n > /tmp/pkgs_to_install
  81. echo 0 > /tmp/petget/install_status_percent
  82. echo "" > /tmp/petget/install_status
  83. touch /tmp/install_pets_quietly
  84. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  85. . /root/.packages/DISTRO_PKGS_SPECS
  86. . /root/.packages/PKGS_MANAGEMENT #has PKG_REPOS_ENABLED, PKG_NAME_ALIASES
  87. ##################################################
  88. ## ##
  89. ## F U N C T I O N S ##
  90. ## ##
  91. ##################################################
  92. add_item (){
  93. # Exit if called spuriously
  94. [ "$TREE1" = "" ] && exit 0
  95. # Make sure that we have atleast one mode flag
  96. [ ! -f /tmp/install_pets_quietly -a ! -f /tmp/download_only_pet_quietly \
  97. -a ! -f /tmp/download_pets_quietly -a ! -f /tmp/install_classic ] \
  98. && touch /tmp/install_pets_quietly
  99. if [ "$(grep $TREE1 /root/.packages/user-installed-packages)" != "" -a \
  100. -f /tmp/install_pets_quietly ]; then
  101. . /usr/lib/gtkdialog/box_yesno "$(gettext 'Package is already installed')" "$(gettext 'This package is already installed! ')" "$(gettext 'If you want to re-install it, first remove it and then install it again. To download only or use the step-by-step classic mode, select No and then change the Auto Install to another option.')" "$(gettext 'To Abort the process now select Yes.')"
  102. if [ "$EXIT" = "yes" ]; then
  103. exit 0
  104. else
  105. echo $TREE1 >> /tmp/forced_install
  106. fi
  107. fi
  108. if [ "$TREE1" ] && [ ! "$(grep -F $TREE1 /tmp/pkgs_to_install)" ]; then
  109. if [ ! -f /root/.packages/skip_space_check ]; then
  110. echo 0 > /tmp/petget/install_status_percent
  111. echo "$(gettext "Calculating...")" > /tmp/petget/install_status
  112. fi
  113. NEWPACKAGE="$(grep -F $TREE1 /tmp/petget/filterpkgs.results.post)"
  114. echo "$NEWPACKAGE" >> /tmp/pkgs_to_install
  115. add_item2 &
  116. fi
  117. }
  118. add_item2(){
  119. while true; do
  120. sleep 0.3
  121. [ ! "$(grep installed_size_preview <<< "$(ps -eo pid,command)")" ] && break
  122. done
  123. touch /tmp/install_quietly
  124. /usr/local/petget/installed_size_preview.sh "$NEWPACKAGE" ADD
  125. }
  126. remove_item (){
  127. if [ "$TREE_INSTALL" ]; then
  128. if [ ! -f /root/.packages/skip_space_check ]; then
  129. echo 0 > /tmp/petget/install_status_percent
  130. echo "$(gettext "Calculating...")" > /tmp/petget/install_status
  131. fi
  132. REMVPACKAGE="$(grep "$TREE_INSTALL" /tmp/pkgs_to_install)"
  133. grep -v "$TREE_INSTALL" /tmp/pkgs_to_install > /tmp/pkgs_to_install2
  134. mv -f /tmp/pkgs_to_install2 /tmp/pkgs_to_install
  135. PKGNAME=$(echo $TREE_INSTALL | cut -f 1 -d '|')
  136. sed -i "/$PKGNAME/d" /tmp/forced_install
  137. if [ "$(cat /tmp/pkgs_to_install)" = "" ]; then
  138. rm -f /tmp/overall_*
  139. echo "" > /tmp/petget/install_status
  140. else
  141. remove_item2 &
  142. fi
  143. fi
  144. }
  145. remove_item2 (){
  146. while true; do
  147. sleep 0.3
  148. [ ! "$(grep installed_size_preview <<< "$(ps -eo pid,command)")" ] && break
  149. done
  150. touch /tmp/install_quietly #avoid splashes
  151. /usr/local/petget/installed_size_preview.sh "$REMVPACKAGE" RMV
  152. }
  153. change_mode () {
  154. PREVPKG=$(cat /tmp/pkgs_to_install 2>/dev/null)
  155. case $INSTALL_MODE in
  156. "$(gettext 'Auto install')")
  157. if [ -f /tmp/install_pets_quietly ]; then echo ok
  158. elif [ "$PREVPKG" != "" ]; then echo changed >> /tmp/mode_changed ;fi
  159. rm -f /tmp/*_pet{,s}_quietly
  160. rm -f /tmp/install_classic
  161. touch /tmp/install_pets_quietly
  162. ;;
  163. "$(gettext 'Download packages (no install)')")
  164. if [ -f /tmp/download_only_pet_quietly ]; then echo ok
  165. elif [ "$PREVPKG" != "" ]; then echo changed >> /tmp/mode_changed ;fi
  166. rm -f /tmp/*_pet{,s}_quietly
  167. rm -f /tmp/install_classic
  168. echo "" > /tmp/forced_install
  169. touch /tmp/download_only_pet_quietly
  170. ;;
  171. "$(gettext 'Download all (packages and dependencies)')")
  172. if [ -f /tmp/download_pets_quietly ]; then echo ok
  173. elif [ "$PREVPKG" != "" ]; then echo changed >> /tmp/mode_changed ;fi
  174. rm -f /tmp/*_pet{,s}_quietly
  175. rm -f /tmp/install_classic
  176. echo "" > /tmp/forced_install
  177. touch /tmp/download_pets_quietly
  178. ;;
  179. "$(gettext 'Step by step installation (classic mode)')")
  180. if [ ! -f /tmp/install_pets_quietly -a ! -f /tmp/download_only_pet_quietly] \
  181. -a ! -f /tmp/download_pets_quietly ]; then echo ok
  182. elif [ "$PREVPKG" != "" ]; then echo changed >> /tmp/mode_changed ;fi
  183. rm -f /tmp/*_pet{,s}_quietly
  184. echo "" > /tmp/forced_install
  185. touch /tmp/install_classic
  186. ;;
  187. esac
  188. }
  189. installed_warning () {
  190. FORCEDPKGS=$(cat /tmp/forced_install 2>/dev/null)
  191. . /usr/lib/gtkdialog/box_splash -timeout 10 -bg orange -fontsize large -text "$FORCEDPKGS $(gettext ' packages are already installed! Should be remove from the list. If you want to re-install, uninstall first and then install.')"
  192. }
  193. export -f add_item add_item2 remove_item remove_item2 change_mode installed_warning
  194. ##################################################
  195. ## ##
  196. ## M A I N ##
  197. ## ##
  198. ##################################################
  199. touch /root/.packages/user-installed-packages #120603 missing at first boot.
  200. #101129 choose to display EXE, DEV, DOC, NLS pkgs... note, this code-block is also in findnames.sh and filterpkgs.sh...
  201. DEF_CHK_EXE='true'
  202. DEF_CHK_DEV='false'
  203. DEF_CHK_DOC='false'
  204. DEF_CHK_NLS='false'
  205. [ -e /var/local/petget/postfilter_EXE ] && DEF_CHK_EXE="`cat /var/local/petget/postfilter_EXE`"
  206. [ -e /var/local/petget/postfilter_DEV ] && DEF_CHK_DEV="`cat /var/local/petget/postfilter_DEV`"
  207. [ -e /var/local/petget/postfilter_DOC ] && DEF_CHK_DOC="`cat /var/local/petget/postfilter_DOC`"
  208. [ -e /var/local/petget/postfilter_NLS ] && DEF_CHK_NLS="`cat /var/local/petget/postfilter_NLS`"
  209. #120515 the script /usr/local/petget/postfilterpkgs.sh handles checkbox actions, is called from ui_Ziggy and ui_Classic.
  210. #finds all user-installed pkgs and formats ready for display...
  211. /usr/local/petget/finduserinstalledpkgs.sh #writes to /tmp/installedpkgs.results
  212. #130511 need to include devx-only-installed-packages, if loaded...
  213. #note, this code block also in check_deps.sh.
  214. if which gcc;then
  215. cp -f /root/.packages/woof-installed-packages /tmp/ppm-layers-installed-packages
  216. cat /root/.packages/devx-only-installed-packages >> /tmp/ppm-layers-installed-packages
  217. sort -u /tmp/ppm-layers-installed-packages > /root/.packages/layers-installed-packages
  218. else
  219. cp -f /root/.packages/woof-installed-packages /root/.packages/layers-installed-packages
  220. fi
  221. #120224 handle translated help.htm
  222. #100711 moved from findmissingpkgs.sh... 130511 rename woof-installed-packages to layers-installed-packages...
  223. if [ ! -f /tmp/petget_installed_patterns_system ];then
  224. INSTALLED_PATTERNS_SYS="`cat /root/.packages/layers-installed-packages | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  225. echo "$INSTALLED_PATTERNS_SYS" > /tmp/petget_installed_patterns_system
  226. #PKGS_SPECS_TABLE also has system-installed names, some of them are generic combinations of pkgs...
  227. . /etc/rc.d/BOOTCONFIG
  228. if [ "$(echo $EXTRASFSLIST | grep $DISTRO_ZDRVSFS)" = "" -a \
  229. "$(echo $LASTUNIONRECORD | grep $DISTRO_ZDRVSFS)" = "" ]; then
  230. INSTALLED_PATTERNS_GEN="`echo "$PKGS_SPECS_TABLE" | grep '^yes' | grep -v 'exe>dev' | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  231. else
  232. INSTALLED_PATTERNS_GEN="`echo "$PKGS_SPECS_TABLE" | grep '^yes' | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  233. fi
  234. echo "$INSTALLED_PATTERNS_GEN" >> /tmp/petget_installed_patterns_system
  235. #120822 in precise puppy have a pet 'cups' instead of the ubuntu debs. the latter are various pkgs, including 'libcups2'.
  236. #we don't want libcups2 showing up as a missing dependency, so have to screen these alternative names out...
  237. case $DISTRO_BINARY_COMPAT in
  238. ubuntu|debian|devuan|raspbian)
  239. #for 'cups' pet, we want to create a pattern '/cups|' so can locate all debs with that DB_path entry '.../cups'
  240. INSTALLED_PTNS_PET="$(grep '\.pet|' /root/.packages/layers-installed-packages | cut -f 2 -d '|' | sed -e 's%^%/%' -e 's%$%|%' -e 's%\-%\\-%g')"
  241. if [ "$INSTALLED_PTNS_PET" != "/|" ];then
  242. echo "$INSTALLED_PTNS_PET" > /tmp/petget/installed_ptns_pet
  243. INSTALLED_ALT_NAMES="$(grep --no-filename -f /tmp/petget/installed_ptns_pet /root/.packages/Packages-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}-* | cut -f 2 -d '|')"
  244. if [ "$INSTALLED_ALT_NAMES" ];then
  245. INSTALLED_ALT_PTNS="$(echo "$INSTALLED_ALT_NAMES" | sed -e 's%^%|%' -e 's%$%|%' -e 's%\-%\\-%g')"
  246. echo "$INSTALLED_ALT_PTNS" >> /tmp/petget_installed_patterns_system
  247. fi
  248. fi
  249. ;;
  250. esac
  251. sort -u /tmp/petget_installed_patterns_system > /tmp/petget_installed_patterns_systemx
  252. mv -f /tmp/petget_installed_patterns_systemx /tmp/petget_installed_patterns_system
  253. fi
  254. #100711 this code repeated in findmissingpkgs.sh...
  255. cp -f /tmp/petget_installed_patterns_system /tmp/petget_installed_patterns_all
  256. if [ -s /root/.packages/user-installed-packages ];then
  257. INSTALLED_PATTERNS_USER="`cat /root/.packages/user-installed-packages | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  258. echo "$INSTALLED_PATTERNS_USER" >> /tmp/petget_installed_patterns_all
  259. #120822 find alt names in compat-distro pkgs, for user-installed pets...
  260. case $DISTRO_BINARY_COMPAT in
  261. ubuntu|debian|devuan|raspbian)
  262. #120904 bugfix, was very slow...
  263. MODIF1=`stat --format=%Y /root/.packages/user-installed-packages` #seconds since epoch.
  264. MODIF2=0
  265. [ -f /var/local/petget/installed_alt_ptns_pet_user ] && MODIF2=`stat --format=%Y /var/local/petget/installed_alt_ptns_pet_user`
  266. if [ $MODIF1 -gt $MODIF2 ];then
  267. INSTALLED_PTNS_PET="$(grep '\.pet|' /root/.packages/user-installed-packages | cut -f 2 -d '|')"
  268. if [ "$INSTALLED_PTNS_PET" != "" ];then
  269. xINSTALLED_PTNS_PET="$(echo "$INSTALLED_PTNS_PET" | sed -e 's%^%/%' -e 's%$%|%' -e 's%\-%\\-%g')"
  270. echo "$xINSTALLED_PTNS_PET" > /tmp/petget/fmp_xipp1
  271. INSTALLED_ALT_NAMES="$(grep --no-filename -f /tmp/petget/fmp_xipp1 /root/.packages/Packages-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}-* | cut -f 2 -d '|')"
  272. if [ "$INSTALLED_ALT_NAMES" ];then
  273. INSTALLED_ALT_PTNS="$(echo "$INSTALLED_ALT_NAMES" | sed -e 's%^%|%' -e 's%$%|%' -e 's%\-%\\-%g')"
  274. echo "$INSTALLED_ALT_PTNS" > /var/local/petget/installed_alt_ptns_pet_user
  275. echo "$INSTALLED_ALT_PTNS" >> /tmp/petget_installed_patterns_all
  276. fi
  277. fi
  278. touch /var/local/petget/installed_alt_ptns_pet_user
  279. else
  280. cat /var/local/petget/installed_alt_ptns_pet_user >> /tmp/petget_installed_patterns_all
  281. fi
  282. ;;
  283. esac
  284. fi
  285. #process name aliases into patterns (used in filterpkgs.sh, findmissingpkgs.sh) ... 100126...
  286. xPKG_NAME_ALIASES="`echo "$PKG_NAME_ALIASES" | tr ' ' '\n' | grep -v '^$' | sed -e 's%^%|%' -e 's%$%|%' -e 's%,%|,|%g' -e 's%\\*%.*%g'`"
  287. echo "$xPKG_NAME_ALIASES" > /tmp/petget_pkg_name_aliases_patterns_raw #110706
  288. cp -f /tmp/petget_pkg_name_aliases_patterns_raw /tmp/petget_pkg_name_aliases_patterns #110706 _raw see findmissingpkgs.sh.
  289. #100711 above has a problem as it has wildcards. need to expand...
  290. #ex: PKG_NAME_ALIASES has an entry 'cxxlibs,glibc*,libc-*', the above creates '|cxxlibs|,|glibc.*|,|libc\-.*|',
  291. # after expansion: '|cxxlibs|,|glibc|,|libc-|,|glibc|,|glibc_dev|,|glibc_locales|,|glibc-solibs|,|glibc-zoneinfo|'
  292. echo -n "" > /tmp/petget_pkg_name_aliases_patterns_expanded
  293. for ONEALIASLINE in `cat /tmp/petget_pkg_name_aliases_patterns | tr '\n' ' '` #ex: |cxxlibs|,|glibc.*|,|libc\-.*|
  294. do
  295. echo -n "" > /tmp/petget_temp1
  296. for PARTONELINE in `echo -n "$ONEALIASLINE" | tr ',' ' '`
  297. do
  298. grep "$PARTONELINE" /tmp/petget_installed_patterns_all >> /tmp/petget_temp1
  299. done
  300. ZZZ="`echo "$ONEALIASLINE" | sed -e 's%\.\*%%g' | tr -d '\\'`"
  301. [ -s /tmp/petget_temp1 ] && ZZZ="${ZZZ},`cat /tmp/petget_temp1 | tr '\n' ',' | tr -s ',' | tr -d '\\'`"
  302. ZZZ="`echo -n "$ZZZ" | sed -e 's%,$%%'`"
  303. echo "$ZZZ" >> /tmp/petget_pkg_name_aliases_patterns_expanded
  304. done
  305. cp -f /tmp/petget_pkg_name_aliases_patterns_expanded /tmp/petget_pkg_name_aliases_patterns
  306. #w480 PKG_NAME_IGNORE is definedin PKGS_MANAGEMENT file... 100126...
  307. xPKG_NAME_IGNORE="`echo "$PKG_NAME_IGNORE" | tr ' ' '\n' | grep -v '^$' | sed -e 's%^%|%' -e 's%$%|%' -e 's%,%|,|%g' -e 's%\\*%.*%g' -e 's%\-%\\-%g'`"
  308. echo "$xPKG_NAME_IGNORE" > /tmp/petget_pkg_name_ignore_patterns
  309. repocnt=0
  310. COMPAT_REPO=""
  311. COMPAT_DBS=""
  312. echo -n "" > /tmp/petget_active_repo_list
  313. #120831 simplify...
  314. REPOS_RADIO=""
  315. repocnt=0
  316. #sort with -puppy-* repos last...
  317. if [ "$DISTRO_BINARY_COMPAT" = "puppy" ];then
  318. aPRE="`echo -n "$PKG_REPOS_ENABLED" | tr ' ' '\n' | grep '\-puppy\-' | tr -s '\n' | tr '\n' ' '`"
  319. bPRE="`echo -n "$PKG_REPOS_ENABLED" | tr ' ' '\n' | grep -v '\-puppy\-' | tr -s '\n' | tr '\n' ' '`"
  320. else
  321. aPRE="`echo -n "$PKG_REPOS_ENABLED" | tr ' ' '\n' | grep -v '\-puppy\-' | tr -s '\n' | tr '\n' ' '`"
  322. bPRE="`echo -n "$PKG_REPOS_ENABLED" | tr ' ' '\n' | grep '\-puppy\-' | tr -s '\n' | tr '\n' ' '`"
  323. fi
  324. for ONEREPO in $aPRE $bPRE #ex: ' Packages-puppy-precise-official Packages-puppy-noarch-official Packages-ubuntu-precise-main Packages-ubuntu-precise-multiverse '
  325. do
  326. [ ! -f /root/.packages/$ONEREPO ] && continue
  327. REPOCUT="`echo -n "$ONEREPO" | cut -f 2-4 -d '-'`"
  328. [ "$REPOS_RADIO" = "" ] && FIRST_DB="$REPOCUT"
  329. xREPOCUT="$(echo -n "$REPOCUT" | sed -e 's%\-official$%%')" #120905 window too wide.
  330. REPOS_RADIO="${REPOS_RADIO}<radiobutton space-expand=\"false\" space-fill=\"false\"><label>${xREPOCUT}</label><action>/tmp/filterversion.sh ${REPOCUT}</action><action>/usr/local/petget/filterpkgs.sh</action><action>refresh:TREE1</action></radiobutton>"
  331. echo "$REPOCUT" >> /tmp/petget_active_repo_list #120903 needed in findnames.sh
  332. repocnt=`expr $repocnt + 1`
  333. #[ $repocnt -ge 5 ] && break # SFR: no limit
  334. done
  335. FILTER_CATEG="Desktop"
  336. #note, cannot initialise radio buttons in gtkdialog...
  337. echo "Desktop" > /tmp/petget_filtercategory #must start with Desktop.
  338. echo "$FIRST_DB" > /tmp/petget/current-repo-triad #ex: slackware-12.2-official
  339. #130330 GUI filtering. see also ui_Classic, ui_Ziggy, filterpkgs.sh ...
  340. GUIONLYSTR="$(gettext 'GUI apps only')"
  341. ANYTYPESTR="$(gettext 'Any type')"
  342. GUIEXCSTR="$(gettext 'GUI, not')" #130331 (look in ui_Classic, ui_Ziggy to see context)
  343. NONGUISTR="$(gettext 'Any non-GUI type')" #130331
  344. export GUIONLYSTR ANYTYPESTR GUIEXCSTR NONGUISTR #used in ui_classic and ui_ziggy
  345. [ ! -f /var/local/petget/gui_filter ] && echo -n "$ANYTYPESTR" > /var/local/petget/gui_filter # SFR: any type by default
  346. #finds pkgs in repository based on filter category and version and formats ready for display...
  347. /usr/local/petget/filterpkgs.sh $FILTER_CATEG #writes to /tmp/petget/filterpkgs.results
  348. echo '#!/bin/sh
  349. echo $1 > /tmp/petget/current-repo-triad
  350. ' > /tmp/filterversion.sh
  351. chmod 777 /tmp/filterversion.sh
  352. #run the traditional ui if set in config
  353. if [ "$(cat /var/local/petget/ui_choice 2>/dev/null)" = "Classic" ]; then
  354. . /usr/local/petget/ui_Classic
  355. exit 0
  356. fi
  357. #tall or wide orientation in the Ziggy UI
  358. UI_ORIENT="$(cat /var/local/petget/uo_choice 2>/dev/null)"
  359. [ "$UI_ORIENT" != "" ] && UI_ORIENT="$UI_ORIENT" || UI_ORIENT="wide"
  360. if [ "$UI_ORIENT" = "tall" ]; then
  361. UO_1="800"
  362. UO_2="650"
  363. UO_3="210"
  364. UO_4="210"
  365. UO_5="<vbox space-expand=\"true\" space-fill=\"true\">
  366. <hbox space-expand=\"true\" space-fill=\"true\" height-request=\"250\">"
  367. UO_6="</vbox>"
  368. else
  369. UO_1="950"
  370. UO_2="1000"
  371. UO_3="300"
  372. UO_4="100"
  373. UO_5="<hbox space-expand=\"true\" space-fill=\"true\">"
  374. UO_6=''
  375. fi
  376. # icon switching
  377. ICONDIR="/tmp/petget/icons"
  378. rm -rf "$ICONDIR"
  379. mkdir -p "$ICONDIR"
  380. cp /usr/share/pixmaps/puppy/package_remove.svg "$ICONDIR"/false.svg
  381. cp /usr/share/pixmaps/puppy/close.svg "$ICONDIR"/true.svg
  382. ln -sf "$ICONDIR"/true.svg "$ICONDIR"/tgb0.svg
  383. # check screen size
  384. SCREEN_WIDTH=$(xwininfo -root | grep -m 1 '\geometry' | cut -f1 -d 'x' |rev |cut -f1 -d ' ' |rev)
  385. [ "$SCREEN_WIDTH" -le 1000 ] && WIDTH="$SCREEN_WIDTH" || WIDTH="$UO_1"
  386. S='<window title="'$(gettext 'Puppy Package Manager v')''${VERSION}'" width-request="'${WIDTH}'" icon-name="gtk-about" default_height="440">
  387. <vbox space-expand="true" space-fill="true">
  388. <vbox space-expand="true" space-fill="true">
  389. <vbox space-expand="false" space-fill="false">
  390. <hbox spacing="1" space-expand="true" space-fill="true">
  391. <button tooltip-text="'$(gettext 'Quit package manager')'" space-expand="false" space-fill="false">
  392. '"`/usr/lib/gtkdialog/xml_button-icon quit`"'
  393. <action>exit:EXIT</action>
  394. </button>
  395. <button tooltip-text="'$(gettext 'Help')'" space-expand="false" space-fill="false">
  396. '"`/usr/lib/gtkdialog/xml_button-icon help`"'
  397. <action>defaulthtmlviewer file://'${HELPFILE}' & </action>
  398. </button>
  399. <button tooltip-text="'$(gettext 'Configure package manager')'" space-expand="false" space-fill="false">
  400. '"`/usr/lib/gtkdialog/xml_button-icon preferences`"'
  401. <action>/usr/local/petget/configure.sh</action>
  402. <action>/usr/local/petget/filterpkgs.sh</action>
  403. <action>refresh:TREE1</action>
  404. </button>
  405. <togglebutton tooltip-text="'$(gettext 'Open/Close the Uninstall packages window')'" space-expand="false" space-fill="false">
  406. <label>" '$(gettext 'Uninstall')' "</label>
  407. <variable>tgb0</variable>
  408. <input file>'"$ICONDIR"'/false.svg</input>
  409. <input file>'"$ICONDIR"'/tgb0.svg</input>
  410. <height>20</height>
  411. <action>ln -sf '"$ICONDIR"'/$tgb0.svg '"$ICONDIR"'/tgb0.svg</action>
  412. <action>refresh:tgb0</action>
  413. <action>save:tgb0</action>
  414. <output file>'"$ICONDIR"'/outputfile</output>
  415. <variable>BUTTON_UNINSTALL</variable>
  416. <action>if true show:VBOX_REMOVE</action>
  417. <action>if false hide:VBOX_REMOVE</action>
  418. </togglebutton>
  419. <text space-expand="true" space-fill="true"><label>""</label></text>
  420. <entry width-request="80" activates-default="true" is-focus="true" primary-icon-stock="gtk-clear" secondary-icon-stock="gtk-find">
  421. <variable>ENTRY1</variable>
  422. <action signal="activate">/usr/local/petget/findnames.sh all</action>
  423. <action signal="activate">refresh:TREE1</action>
  424. <action signal="activate">/usr/local/petget/show_installed_version_diffs.sh & </action>
  425. <action signal="secondary-icon-release">/usr/local/petget/findnames.sh all</action>
  426. <action signal="secondary-icon-release">refresh:TREE1</action>
  427. <action signal="secondary-icon-release">/usr/local/petget/show_installed_version_diffs.sh & </action>
  428. <action signal="primary-icon-release">clear:ENTRY1</action>
  429. </entry>
  430. <text space-expand="true" space-fill="true"><label>""</label></text>
  431. <comboboxtext width-request="150" space-expand="false" space-fill="false">
  432. <variable>INSTALL_MODE</variable>
  433. <item>'$(gettext 'Auto install')'</item>
  434. <item>'$(gettext 'Step by step installation (classic mode)')'</item>
  435. <item>'$(gettext 'Download packages (no install)')'</item>
  436. <item>'$(gettext 'Download all (packages and dependencies)')'</item>
  437. <action>change_mode</action>
  438. </comboboxtext>
  439. <button space-expand="false" space-fill="false">
  440. <variable>BUTTON_INSTALL</variable>
  441. '"`/usr/lib/gtkdialog/xml_button-icon package_add`"'
  442. <label>" '$(gettext 'Do it!')' "</label>
  443. <sensitive>false</sensitive>
  444. <action condition="command_is_true(if [ \"$(cat /tmp/pkgs_to_install)\" != \"\" ];then echo true;fi)">disable:VBOX_MAIN</action>
  445. <action>if [ "$(cat /tmp/forced_install 2>/dev/null)" != "" ]; then touch /tmp/force_install; else rm -f /tmp/force_install; fi </action>
  446. <action>cut -d"|" -f1,4 /tmp/pkgs_to_install > /tmp/pkgs_to_install_tmp; mv -f /tmp/pkgs_to_install_tmp /tmp/pkgs_to_install</action>
  447. <action condition="command_is_true(if [ -f /tmp/force_install -a -f /tmp/install_pets_quietly ]; then echo false; else echo true; fi )">/usr/local/petget/installmodes.sh "$INSTALL_MODE" &</action>
  448. <action condition="command_is_false(if [ -f /tmp/force_install -a -f /tmp/install_pets_quietly ]; then echo false; else echo true; fi )">installed_warning &</action>
  449. <action condition="command_is_false(if [ -f /tmp/force_install -a -f /tmp/install_pets_quietly ]; then echo false; else echo true; fi )">enable:VBOX_MAIN</action>
  450. </button>
  451. </hbox>
  452. </vbox>
  453. <hbox space-expand="true" space-fill="true">
  454. <vbox visible="false" space-expand="true" space-fill="true">
  455. <eventbox name="frame_remove">
  456. <vbox margin="2" space-expand="true" space-fill="true">
  457. <notebook name="frame_remove" show-tabs="false" show-border="true">
  458. <vbox margin="2" space-expand="true" space-fill="true">
  459. <notebook show-tabs="false" show-border="true">
  460. <vbox margin="2" space-expand="true" space-fill="true">
  461. <tree rubber-banding="true" selection-mode="3" space-expand="true" space-fill="true">
  462. <label>'$(gettext 'Installed Package')'|'$(gettext 'Description')'</label>
  463. <variable>TREE2</variable>
  464. <width>'${UO_2}'</width><height>100</height>
  465. <input file icon-column="1">/tmp/petget/installedpkgs.results.post</input>
  466. <action signal="button-release-event" condition="command_is_true([[ `echo $TREE2` ]] && echo true)">enable:BUTTON_UNINSTALL</action>
  467. </tree>
  468. <comboboxtext space-expand="false" space-fill="false">
  469. <variable>REMOVE_MODE</variable>
  470. <item>'$(gettext 'Auto remove')'</item>
  471. <item>'$(gettext 'Step by step remove (classic mode)')'</item>
  472. </comboboxtext>
  473. <button space-expand="false" space-fill="false">
  474. <variable>BUTTON_UNINSTALL</variable>
  475. '"`/usr/lib/gtkdialog/xml_button-icon package_remove`"'
  476. <label>" '$(gettext 'Remove package')' "</label>
  477. <sensitive>false</sensitive>
  478. <action condition="command_is_true([[ \"$TREE2\" != \"\" ]] && echo true)">disable:VBOX_MAIN</action>
  479. <action>echo "$TREE2" > /tmp/pkgs_to_remove; /usr/local/petget/removemodes.sh "$REMOVE_MODE" &</action>
  480. </button>
  481. </vbox>
  482. </notebook>
  483. </vbox>
  484. </notebook>
  485. </vbox>
  486. </eventbox>
  487. <variable>VBOX_REMOVE</variable>
  488. </vbox>
  489. <hbox space-expand="false" space-fill="false">
  490. <vbox space-expand="true" space-fill="true">
  491. <frame '$(gettext 'Repositories')'>
  492. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="2" space-expand="true" space-fill="true">
  493. '${REPOS_RADIO}'
  494. <text height-request="1" space-expand="true" space-fill="true"><label>""</label></text>
  495. <height>128</height>
  496. <width>50</width>
  497. </vbox>
  498. </frame>
  499. <vbox space-expand="false" space-fill="false">
  500. <frame '$(gettext 'package types')'>
  501. <hbox>
  502. <vbox>
  503. <checkbox>
  504. <default>'${DEF_CHK_EXE}'</default>
  505. <label>EXE</label>
  506. <variable>CHK_EXE</variable>
  507. <action>/usr/local/petget/postfilterpkgs.sh EXE $CHK_EXE</action>
  508. <action>refresh:TREE1</action>
  509. </checkbox>
  510. <checkbox>
  511. <default>'${DEF_CHK_DEV}'</default>
  512. <label>DEV</label>
  513. <variable>CHK_DEV</variable>
  514. <action>/usr/local/petget/postfilterpkgs.sh DEV $CHK_DEV</action>
  515. <action>refresh:TREE1</action>
  516. </checkbox>
  517. <checkbox>
  518. <default>'${DEF_CHK_DOC}'</default>
  519. <label>DOC</label>
  520. <variable>CHK_DOC</variable>
  521. <action>/usr/local/petget/postfilterpkgs.sh DOC $CHK_DOC</action>
  522. <action>refresh:TREE1</action>
  523. </checkbox>
  524. <checkbox>
  525. <default>'${DEF_CHK_NLS}'</default>
  526. <label>NLS</label>
  527. <variable>CHK_NLS</variable>
  528. <action>/usr/local/petget/postfilterpkgs.sh NLS $CHK_NLS</action>
  529. <action>refresh:TREE1</action>
  530. </checkbox>
  531. </vbox>
  532. <hbox space-expand="true" space-fill="true">
  533. <vbox space-expand="false" space-fill="false">
  534. <comboboxtext width-request="120">
  535. <variable>FILTERCOMBOBOX</variable>
  536. <default>'$(</var/local/petget/gui_filter)'</default>
  537. <item>'$ANYTYPESTR'</item>
  538. <item>'$GUIONLYSTR'</item>
  539. <item>GTK+2 '$GUIONLYSTR'</item>
  540. <item>GTK+3 '$GUIONLYSTR'</item>
  541. <item>Qt4 '$GUIONLYSTR'</item>
  542. <item>Qt4 '$GUIEXCSTR' KDE</item>
  543. <item>Qt5 '$GUIONLYSTR'</item>
  544. <item>Qt5 '$GUIEXCSTR' KDE</item>
  545. <item>'$NONGUISTR'</item>
  546. <action>echo -n "$FILTERCOMBOBOX" > /var/local/petget/gui_filter</action>
  547. <action>/usr/local/petget/filterpkgs.sh</action>
  548. <action>refresh:TREE1</action>
  549. </comboboxtext>
  550. </vbox>
  551. </hbox>
  552. </hbox>
  553. </frame>
  554. </vbox>
  555. </vbox>
  556. </hbox>
  557. <vbox space-expand="true" space-fill="true">
  558. <hbox spacing="1" space-expand="true" space-fill="true">
  559. <hbox space-expand="false" space-fill="false">
  560. <tree name="category" selected-row="0" exported_column="1" column-visible="true|false" space-expand="false" space-fill="false">
  561. <label>'$(gettext 'Category')'|command</label>
  562. <variable>CATEGORY</variable>
  563. <item stock="gtk-Desktop">'$(gettext 'Desktop')'|Desktop</item>
  564. <item stock="gtk-System">'$(gettext 'System')'|System</item>
  565. <item stock="gtk-Setup">'$(gettext 'Setup')'|Setup</item>
  566. <item stock="gtk-Utility">'$(gettext 'Utility')'|Utility</item>
  567. <item stock="gtk-Filesystem">'$(gettext 'Filesystem')'|Filesystem</item>
  568. <item stock="gtk-Graphic">'$(gettext 'Graphic')'|Graphic</item>
  569. <item stock="gtk-Document">'$(gettext 'Document')'|Document</item>
  570. <item stock="gtk-Business">'$(gettext 'Business')'|Business</item>
  571. <item stock="gtk-Personal">'$(gettext 'Personal')'|Personal</item>
  572. <item stock="gtk-Network">'$(gettext 'Network')'|Network</item>
  573. <item stock="gtk-Internet">'$(gettext 'Internet')'|Internet</item>
  574. <item stock="gtk-Multimedia">'$(gettext 'Multimedia')'|Multimedia</item>
  575. <item stock="gtk-Fun">'$(gettext 'Fun')'|Fun</item>'
  576. [ "$(cat /var/local/petget/bb_category 2>/dev/null)" = "true" ] && S=$S'<item stock="gtk-BB">'$(gettext 'BuildingBlock')'|BuildingBlock</item>'
  577. S=$S'<width>140</width><height>112</height>
  578. <action signal="changed">/usr/local/petget/filterpkgs.sh $CATEGORY</action>
  579. <action signal="changed">refresh:TREE1</action>
  580. </tree>
  581. </hbox>
  582. '${UO_5}'
  583. <tree hover-selection="true" selection-mode="1" column-resizeable="true|false" space-expand="true" space-fill="true">
  584. <label>'$(gettext 'Package')'|'$(gettext 'Description')'</label>
  585. <variable>TREE1</variable>
  586. <width>'${UO_3}'</width>
  587. <input file icon-column="1">/tmp/petget/filterpkgs.results.post</input>
  588. <action signal="button-release-event">add_item</action>
  589. <action signal="button-release-event">refresh:TREE_INSTALL</action>
  590. <action signal="button-release-event">enable:BUTTON_INSTALL</action>
  591. </tree>
  592. </hbox>
  593. <hbox space-expand="true" space-fill="true">
  594. <tree hover-selection="true" selection-mode="1" file-monitor="true" auto-refresh="true" hscrollbar-policy="1" column-visible="true|false|true" tooltip-text="'$(gettext 'Remove item from list by click on it')'" space-expand="false" space-fill="false">
  595. <label>'$(gettext 'Packages to install')'|'$(gettext 'Description')'|'$(gettext 'Repository')'</label>
  596. <variable>TREE_INSTALL</variable>
  597. <input file icon-column="1">/tmp/pkgs_to_install</input>
  598. <width>'${UO_4}'</width>
  599. <action signal="button-release-event">remove_item</action>
  600. <action signal="button-release-event">refresh:TREE_INSTALL</action>
  601. <action signal="button-release-event" condition="command_is_true([[ ! `cat /tmp/pkgs_to_install` ]] && echo true)">disable:BUTTON_INSTALL</action>
  602. </tree>
  603. </hbox>
  604. '${UO_6}'
  605. </hbox>
  606. </vbox>
  607. </hbox>
  608. <variable>VBOX_MAIN</variable>
  609. </vbox>
  610. <hbox space-expand="false" space-fill="false">
  611. <progressbar height-request="25" space-expand="true" space-fill="true">
  612. <input>while [ -s /tmp/petget/install_status -a "$(ps aux|grep PPM_GUI|grep gtkdialog|wc -l)" -gt 2 ]; do cat /tmp/petget/install_status_percent; cat /tmp/petget/install_status; sleep 0.5; done</input>
  613. <action>enable:VBOX_MAIN</action>
  614. <action>disable:BUTTON_INSTALL</action>
  615. <action>rm /tmp/pkgs_to_install</action>
  616. <action>refresh:TREE_INSTALL</action>
  617. <action>/usr/local/petget/filterpkgs.sh</action>
  618. <action>refresh:TREE1</action>
  619. <action>/usr/local/petget/finduserinstalledpkgs.sh</action>
  620. <action>refresh:TREE2</action>
  621. <action>echo 0 > /tmp/petget/install_status_percent</action>
  622. <action>echo "" > /tmp/petget/install_status</action>
  623. </progressbar>
  624. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  625. </hbox>
  626. </vbox>
  627. <action signal="show">kill -9 '$SPID'</action>
  628. <action signal="delete-event">rm /tmp/pkgs_to_install</action>
  629. <action signal="delete-event">rm /tmp/petget/install_status</action>
  630. </window>'
  631. export PPM_GUI="$S"
  632. mkdir -p /tmp/puppy_package_manager
  633. ln -s /usr/local/lib/X11/pixmaps/*48.png /tmp/puppy_package_manager 2>/dev/null
  634. echo '
  635. style "category" {
  636. font_name="bold" }
  637. widget "*category" style "category"
  638. style "bg_report" {
  639. bg[NORMAL]="#222" }
  640. widget "*bg_report" style "bg_report"
  641. style "frame_remove" {
  642. bg[NORMAL]="#222" }
  643. widget "*frame_remove" style "frame_remove"
  644. style "icon-style" {
  645. GtkStatusbar::shadow_type = GTK_SHADOW_NONE
  646. stock["gtk-Desktop"] = {{ "x48.png", *, *, *}}
  647. stock["gtk-System"] = {{ "pc48.png", *, *, *}}
  648. stock["gtk-Setup"] = {{ "configuration48.png", *, *, *}}
  649. stock["gtk-Utility"] = {{ "utility48.png", *, *, *}}
  650. stock["gtk-Filesystem"] = {{ "folder48.png", *, *, *}}
  651. stock["gtk-Graphic"] = {{ "paint48.png", *, *, *}}
  652. stock["gtk-Document"] = {{ "word48.png", *, *, *}}
  653. stock["gtk-Business"] = {{ "spread48.png", *, *, *}}
  654. stock["gtk-Personal"] = {{ "date48.png", *, *, *}}
  655. stock["gtk-Network"] = {{ "connect48.png", *, *, *}}
  656. stock["gtk-Internet"] = {{ "www48.png", *, *, *}}
  657. stock["gtk-Multimedia"] = {{ "multimedia48.png", *, *, *}}
  658. stock["gtk-Fun"] = {{ "games48.png", *, *, *}}
  659. stock["gtk-BB"] = {{ "pet48.png", *, *, *}}
  660. }
  661. class "GtkWidget" style "icon-style"' > /tmp/puppy_package_manager/gtkrc_ppm
  662. export GTK2_RC_FILES=/root/.gtkrc-2.0:/tmp/puppy_package_manager/gtkrc_ppm
  663. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  664. gtkdialog -p PPM_GUI
  665. # Run indexgen after we exit the GUI
  666. /usr/sbin/indexgen.sh
  667. #and clean up
  668. clean_flags