downloadpkgs.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2009, puppylinux.com
  3. #2009 Lesser GPL licence v2 (see /usr/share/doc/legal).
  4. #called from /usr/local/petget/installpreview.sh
  5. #The database entries for the packages to be installed are in /tmp/petget_missing_dbentries-*
  6. #ex: /tmp/petget_missing_dbentries-Packages-slackware-12.2-official
  7. #v424 fix msg, x does not need restart to update menu.
  8. #100117 fix for downloading pets from quirky repo.
  9. #100903 fix if subdirectory field 7 in pkg db entry is empty.
  10. #100921 bypass if file list empty.
  11. #100926 fix hack, one puppy repo does not have "puppylinux" in url.
  12. #101013 improvement suggested by L18L, list current locales in 'trim the fat'.
  13. #101014 another hack, wary5 pets are now in the ibiblio quirky site.
  14. #101016 do not offer to trim-the-fat if install pet pkg(s).
  15. #101116 call download_file to download pkg, instead of direct run of wget.
  16. #101118 improve test fail and exit number.
  17. #110812 hack for pets that are in quirky site at ibiblio.
  18. #120203 BK: internationalized.
  19. #120313 'noarch' repo is on quirky ibiblio site.
  20. #120515 support download from arm gentoo compat-distro binary pkgs on ibiblio quirky site.
  21. #120904 vertical scrollbar for successful-install window. 120907 another.
  22. #120908 fixes for composing repo-list.
  23. #120927 want to translate "CATEGORY:" and "PACKAGE:" that are in /tmp/petget-installed-pkgs-log (see installpkg.sh).
  24. #121011 L18L reported problem, category names also need translating.
  25. #121019 flag to download_file when called from ppm.
  26. #121105 hack for RetroPrecise.
  27. #121123 first test that all pkgs exist online before downloading any.
  28. #121130 fix 121123.
  29. [ "$(cat /var/local/petget/nt_category 2>/dev/null)" != "true" ] && \
  30. [ -f /tmp/install_quietly ] && set -x
  31. #; mkdir -p /tmp/PPM_LOGs ; NAME=$(basename "$0"); exec 1>> /tmp/PPM_LOGs/"$NAME".log 2>&1
  32. export TEXTDOMAIN=petget___downloadpkgs.sh
  33. export OUTPUT_CHARSET=UTF-8
  34. #export LANG=C
  35. PASSEDPARAM=""
  36. [ $1 ] && PASSEDPARAM="$1" #DOWNLOADONLY
  37. FLAGPET="" #101016
  38. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  39. . /root/.packages/DISTRO_PKGS_SPECS #
  40. . /root/.packages/DISTRO_PET_REPOS #has PET_REPOS, PACKAGELISTS_PET_ORDER
  41. . /root/.packages/DISTRO_COMPAT_REPOS #v431 has REPOS_DISTRO_COMPAT
  42. if [ -f /root/.packages/download_path ]; then
  43. . /root/.packages/download_path
  44. [ -d "$DL_PATH" -a -w "$DL_PATH" ] && DL_PATH="$DL_PATH" || DL_PATH=/root
  45. else
  46. DL_PATH=/root
  47. fi
  48. DL_SAVE_FLAG=$(cat /var/local/petget/nd_category 2>/dev/null)
  49. echo -n "" > /tmp/petget-installed-pkgs-log
  50. PKGCNT=0 ; FAILCNT=0 ; EXITVAL=0 #101118
  51. for ONELIST in `ls -1 /tmp/petget_missing_dbentries-Packages-*` #ex: petget_missing_dbentries-Packages-puppy-quirky-official
  52. do
  53. #ex of entry in file $ONELIST: rox-menu-0.5.0|rox-menu|0.5.0||Desktop|128K|pet_packages-quirky|rox-menu-0.5.0.pet|+rox-clib,+rox_filer|menu for a rox panel|t2|8.0rc|official|
  54. echo -n "" > /tmp/petget_repos
  55. LISTNAME="`echo -n "$ONELIST" | grep -o 'Packages.*'`" #ex: Packages-puppy-quirky-official
  56. #note: puppy4, had 4xx, which should resolve to 4 i think...
  57. REPO_DEFAULT_SUBSUBDIR="`echo -n "$LISTNAME" | cut -f 3 -d '-' | sed -e 's%xx$%%'`" #100903 ex: quirky
  58. #110812 hack for pets that are in quirky site at ibiblio...
  59. OFFICIAL_REPO='puppylinux'
  60. #Remove BK's quirky hacks 131206
  61. case $LISTNAME in
  62. Packages-puppy-*) #a .pet pkg.
  63. for ONEPETREPO in $PET_REPOS #ex: ibiblio.org|http://distro.ibiblio.org//quirky|Packages-puppy-quirky-official
  64. do
  65. ONEPETREPO_3_PATTERN="`echo -n "$ONEPETREPO" | cut -f 3 -d '|' | sed -e 's%\\-%\\\\-%g' -e 's%\\*%.*%g'`"
  66. ONEPETREPO_1_2="`echo -n "$ONEPETREPO" | cut -f 1,2 -d '|'`"
  67. [ "`echo -n "$LISTNAME" | grep "$ONEPETREPO_3_PATTERN"`" != "" ] && echo "${ONEPETREPO_1_2}|${LISTNAME}" >> /tmp/petget_repos
  68. #...ex: ibiblio.org|http://distro.ibiblio.org//puppylinux|Packages-puppy-4-official
  69. done
  70. ;;
  71. *) #a compat pkg.
  72. #have the compat-distro repo urls in /root/.packages/DISTRO_PKGS_SPECS,
  73. #variable REPOS_DISTRO_COMPAT ...
  74. #REPOS_DISTRO_COMPAT has the associated Packages-* local database file...
  75. for ONEURLENTRY in $REPOS_DISTRO_COMPAT
  76. do
  77. PARTPKGDB="`echo -n "$ONEURLENTRY" | cut -f 3 -d '|'`"
  78. #PARTPKGDB may have a glob * wildcard, convert to reg.expr., also backslash '-'...
  79. PARTPKGDB="`echo -n "$PARTPKGDB" | sed -e 's%\\-%\\\\-%g' -e 's%\\*%.*%g'`"
  80. ONEURLENTRY_1_2="`echo -n "$ONEURLENTRY" | cut -f 1,2 -d '|'`"
  81. [ "`echo "$LISTNAME" | grep "$PARTPKGDB"`" != "" ] && echo "${ONEURLENTRY_1_2}|${LISTNAME}" >> /tmp/petget_repos
  82. done
  83. ;;
  84. esac
  85. sort --key=1 --field-separator="|" --unique /tmp/petget_repos > /tmp/petget_repos-tmp
  86. mv -f /tmp/petget_repos-tmp /tmp/petget_repos
  87. #/tmp/petget_repos has a list of repos for downloading these packages.
  88. #now put up a window, request which url to use...
  89. LISTNAMECUT="`echo -n "$LISTNAME" | cut -f 2-9 -d '-'`" #take Packages- off.
  90. REPOBUTTONS=""
  91. for ONEREPOSPEC in `cat /tmp/petget_repos`
  92. do
  93. URL_TEST="`echo -n "$ONEREPOSPEC" | cut -f 1 -d '|'`"
  94. URL_FULL="`echo -n "$ONEREPOSPEC" | cut -f 2 -d '|'`"
  95. REPOBUTTONS="${REPOBUTTONS}<radiobutton><label>${URL_TEST}</label><variable>RADIO_URL_${URL_TEST}</variable></radiobutton>"
  96. done
  97. PKGNAMES="`cat $ONELIST | cut -f 1 -d '|' | tr '\n' ' '`"
  98. [ "$PKGNAMES" = "" -o "$PKGNAMES" = " " ] && continue #100921
  99. #120907 scrollbar...
  100. if [ ! -f /tmp/install_quietly ]; then
  101. export PPM_DEPS_DIALOG="<window title=\"$(gettext 'Puppy Package Manager: download')\" icon-name=\"gtk-about\">
  102. <vbox>
  103. <text><label>$(gettext 'You have chosen to download these packages:')</label></text>
  104. <vbox scrollable=\"true\" height=\"100\">
  105. <text use-markup=\"true\"><label>\"<b>${PKGNAMES}</b>\"</label></text>
  106. </vbox>
  107. <text><label>$(gettext "Please choose which URL you would like to download them from. Choose 'LOCAL FOLDER' if you have already have them on this computer (on hard drive, USB drive or CD):")</label></text>
  108. <frame ${LISTNAMECUT}>
  109. ${REPOBUTTONS}
  110. <radiobutton><label>$(gettext 'LOCAL FOLDER')</label><variable>RADIO_URL_LOCAL</variable></radiobutton>
  111. </frame>
  112. <hbox>
  113. <button>
  114. <label>$(gettext 'Test URLs')</label>
  115. <action>/usr/local/petget/testurls.sh</action>
  116. </button>
  117. <button>
  118. <label>$(gettext 'Download packages')</label>
  119. <action type=\"exit\">BUTTON_PKGS_DOWNLOAD</action>
  120. </button>
  121. <button cancel></button>
  122. </hbox>
  123. </vbox>
  124. </window>
  125. "
  126. RETPARAMS="`gtkdialog -p PPM_DEPS_DIALOG`"
  127. else
  128. RETPARAMS='EXIT="BUTTON_PKGS_DOWNLOAD"'
  129. fi
  130. #RETPARAMS ex:
  131. #RADIO_URL_LOCAL="false"
  132. #RADIO_URL_repository.slacky.eu="true"
  133. #EXIT="BUTTON_PKGS_DOWNLOAD"
  134. [ "`echo "$RETPARAMS" | grep 'BUTTON_PKGS_DOWNLOAD'`" = "" ] && exit 1
  135. #determine the url to download from....
  136. #if [ "$RADIO_URL_LOCAL" = "true" ];then
  137. if [ "`echo "$RETPARAMS" | grep 'RADIO_URL_LOCAL' | grep 'true'`" != "" ];then
  138. #put up a dlg box asking for folder with pkgs...
  139. LOCALDIR="/root"
  140. if [ -s /var/log/petlocaldir ];then
  141. OLDLOCALDIR="`cat /var/log/petlocaldir`"
  142. [ -d $OLDLOCALDIR ] && LOCALDIR="$OLDLOCALDIR"
  143. fi
  144. LOCALDIR="`Xdialog --backtitle "Note: Files not displayed, only directories" --title "Choose local directory" --stdout --no-buttons --dselect "$LOCALDIR" 0 0`"
  145. [ $? -ne 0 ] && exit 1
  146. if [ "$LOCALDIR" != "" ];then #121130
  147. LOCALDIR="$(echo -n "$LOCALDIR" | sed -e 's%/$%%')" #drop / off the end.
  148. echo "$LOCALDIR" > /var/log/petlocaldir
  149. else
  150. exit 1
  151. fi
  152. DOWNLOADFROM="file://${LOCALDIR}"
  153. else
  154. if [ ! -f /tmp/install_quietly ]; then
  155. URL_BASIC="`echo "$RETPARAMS" | grep 'RADIO_URL_' | grep '"true"' | cut -f 1 -d '=' | cut -f 3 -d '_'`"
  156. DOWNLOADFROM="`cat /tmp/petget_repos | grep "$URL_BASIC" | head -n 1 | cut -f 2 -d '|'`"
  157. else
  158. DOWNLOADFROM="`awk '{ if (NR==1) print $0 }' /tmp/petget_repos | cut -f 2 -d '|'`"
  159. DOWNLOADFROM_ALT="`awk '{ if (NR==2) print $0 }' /tmp/petget_repos | cut -f 2 -d '|'`"
  160. fi
  161. fi
  162. #now download and install them...
  163. cd "$DL_PATH"
  164. #121123 first test that they all exist online...
  165. if [ ! -f /tmp/install_quietly ];then
  166. . yaf-splash -bg '#FFD600' -close never -fontsize large -text "$(gettext 'Please wait, testing that packages exist in repository...')" &
  167. testPID=$!
  168. else
  169. echo "$(gettext 'Testing that packages exist in repository')" > /tmp/petget/install_status
  170. fi
  171. DL_BAD_LIST=''
  172. for ONEFILE in `cat $ONELIST | cut -f 7,8,13 -d '|'` #path|fullfilename|repo-id
  173. do
  174. ONEREPOID="`echo -n "$ONEFILE" | cut -f 3 -d '|'`" #ex: official (...|puppy|wary5|official|)
  175. ONEPATH="`echo -n "$ONEFILE" | cut -f 1 -d '|'`"
  176. ONEPKGNAME="`echo -n "$ONEFILE" | cut -f 2 -d '|'`"
  177. ONEFILE="`echo -n "$ONEFILE" | cut -f 1,2 -d '|' | tr '|' '/'`" #path/fullfilename
  178. [ "`echo -n "$ONEFILE" | rev | cut -c 1-3 | rev`" = "pet" ] && FLAGPET='yes'
  179. if [ "`echo "$RETPARAMS" | grep 'RADIO_URL_LOCAL' | grep 'true'`" != "" ];then
  180. if [ ! -f ${LOCALDIR}/${ONEPKGNAME} ];then #121130 fix.
  181. [ ! -f ./${ONEPKGNAME} ] && DL_BAD_LIST="${DL_BAD_LIST} ${ONEPKGNAME}"
  182. fi
  183. else
  184. if [ "$ONEPATH" == "" ];then
  185. if [ "$FLAGPET" != "yes" ];then
  186. ONEFILE="compat_packages-${REPO_DEFAULT_SUBSUBDIR}${ONEFILE}"
  187. else
  188. ONEFILE="pet_packages-${REPO_DEFAULT_SUBSUBDIR}${ONEFILE}"
  189. fi
  190. fi
  191. if [ ! -f /tmp/install_quietly ]; then
  192. LANG=C wget -4 -t 2 -T 20 --waitretry=20 --spider -S "${DOWNLOADFROM}/${ONEFILE}" > /tmp/download_file_spider.log0 2>&1 #
  193. if [ $? -ne 0 ];then
  194. DL_BAD_LIST="${DL_BAD_LIST} ${ONEPKGNAME}"
  195. fi
  196. else
  197. LANG=C wget -4 -t 2 -T 20 --waitretry=20 --spider -S "${DOWNLOADFROM}/${ONEFILE}" > /tmp/download_file_spider.log0 2>&1 #
  198. if [ $? -ne 0 ];then
  199. DOWNLOADFROM="${DOWNLOADFROM_ALT}"
  200. LANG=C wget -4 -t 2 -T 20 --waitretry=20 --spider -S "${DOWNLOADFROM}/${ONEFILE}" > /tmp/download_file_spider.log0 2>&1
  201. if [ $? -ne 0 ];then
  202. DL_BAD_LIST="${DL_BAD_LIST} ${ONEPKGNAME}"
  203. fi
  204. fi
  205. fi
  206. fi
  207. done
  208. [ ! -f /tmp/install_quietly ] && pupkill $testPID || echo
  209. if [ "$DL_BAD_LIST" ];then
  210. BADMSG1="$(gettext 'Unfortunately, these packages are not available:')"
  211. BADMSG2="$(gettext "It may be that the local package database needs to be updated. In some cases, the packages in the online package repository change, so you may be trying to download a package that no longer exists.")"
  212. BADMSG3="$(gettext "SOLUTION: From the main PPM window, click the 'Configure' BUTTON and click the 'Update' button to update the local package database.")"
  213. BADMSG4="$(gettext 'The installation has been aborted!')"
  214. /usr/lib/gtkdialog/box_ok "$(gettext 'Packages not available')" error "${BADMSG1}" "<b>${DL_BAD_LIST}</b>" "${BADMSG4}" "${BADMSG2} ${BADMSG3}"
  215. echo ${DL_BAD_LIST} >> /tmp/pkgs_DL_BAD_LIST
  216. exit 1
  217. fi
  218. for ONEFILE in `cat $ONELIST | cut -f 7,8,13 -d '|'` #100527 path|fullfilename|repo-id
  219. do
  220. PKGCNT=`expr $PKGCNT + 1` #101118
  221. #100903 reorder...
  222. ONEREPOID="`echo -n "$ONEFILE" | cut -f 3 -d '|'`" #100527 ex: official (...|puppy|wary5|official|)
  223. ONEPATH="`echo -n "$ONEFILE" | cut -f 1 -d '|'`" #100527
  224. ONEFILE="`echo -n "$ONEFILE" | cut -f 1,2 -d '|' | tr '|' '/'`" #100527 path/fullfilename
  225. [ "`echo -n "$ONEFILE" | rev | cut -c 1-3 | rev`" = "pet" ] && FLAGPET='yes' #101016
  226. #if [ "$RADIO_URL_LOCAL" = "true" ];then
  227. if [ "`echo "$RETPARAMS" | grep 'RADIO_URL_LOCAL' | grep 'true'`" != "" ];then
  228. [ ! -f ${LOCALDIR}/${ONEFILE} ] && ONEFILE="`basename $ONEFILE`"
  229. cp -f ${LOCALDIR}/${ONEFILE} ./
  230. else
  231. #100527 need fix if |path| field of pkg database was empty... 100903 improve...
  232. if [ "$ONEPATH" == "" ];then #120515
  233. if [ "$FLAGPET" != "yes" ];then
  234. ONEFILE="compat_packages-${REPO_DEFAULT_SUBSUBDIR}${ONEFILE}"
  235. else
  236. ONEFILE="pet_packages-${REPO_DEFAULT_SUBSUBDIR}${ONEFILE}"
  237. fi
  238. fi
  239. #101116 now have a download utility...
  240. echo "$(gettext 'downloading'): ${ONEFILE}" > /tmp/petget/install_status
  241. export DL_F_CALLED_FROM='ppm' #121019
  242. download_file ${DOWNLOADFROM}/${ONEFILE}
  243. if [ $? -ne 0 ];then #101116
  244. DLPKG="`basename $ONEFILE`"
  245. [ -f "${DL_PATH}"/$DLPKG ] && rm -f "${DL_PATH}"/$DLPKG
  246. fi
  247. unset DL_F_CALLED_FROM
  248. fi
  249. sync
  250. DLPKG="`basename $ONEFILE`"
  251. if [ -f "${DL_PATH}"/$DLPKG -a "$DLPKG" != "" ];then
  252. if [ "$PASSEDPARAM" = "DOWNLOADONLY" ];then
  253. echo "$(gettext 'Verifying'): ${ONEFILE}" > /tmp/petget/install_status
  254. /usr/local/petget/verifypkg.sh $DLPKG
  255. else
  256. echo "$(gettext 'Installing'): ${ONEFILE}" > /tmp/petget/install_status
  257. /usr/local/petget/installpkg.sh $DLPKG
  258. #...appends pkgname and category to /tmp/petget-installed-pkgs-log if successful.
  259. fi
  260. if [ $? -ne 0 ];then
  261. LASTPKG=$(tail -n 1 /tmp/pgks_failed_to_install_forced)
  262. if [ $(echo ${DLPKG} | grep ${LASTPKG}) = "" ]; then
  263. /usr/lib/gtkdialog/box_ok "$(gettext 'Puppy Package Manager')" error "<b>$(gettext 'Faulty download of') ${DLPKG}</b>"
  264. FAILCNT=`expr $FAILCNT + 1` #101118
  265. fi
  266. fi
  267. #already removed, but take precautions...
  268. [ "$PASSEDPARAM" != "DOWNLOADONLY" -a "$DL_SAVE_FLAG" != "true" \
  269. -a "$(grep ${DLPKG} /tmp/pkg_preexists)" = "" ] && rm -f $DLPKG 2>/dev/null
  270. rm -f /tmp/pkg_preexists 2>/dev/null
  271. else
  272. /usr/lib/gtkdialog/box_ok "$(gettext 'Puppy Package Manager')" error "<b>$(gettext 'Failed to download') ${DLPKG}</b>"
  273. FAILCNT=`expr $FAILCNT + 1` #101118
  274. fi
  275. done
  276. done
  277. #101118 exit 1 if all pkgs failed to download...
  278. [ $FAILCNT -ne 0 ] && [ $FAILCNT -eq $PKGCNT ] && EXITVAL=1
  279. if [ "$PASSEDPARAM" = "DOWNLOADONLY" -a ! -f /tmp/download_pets_quietly \
  280. -a ! -f /tmp/download_only_pet_quietly ];then
  281. /usr/lib/gtkdialog/box_ok "$(gettext 'Puppy Package Manager')" complete "$(gettext 'Finished. The packages have been downloaded to') $PWD $(gettext 'directory.')"
  282. exit $EXITVAL
  283. fi
  284. #announce summary of successfully installed pkgs...
  285. #installpkg.sh will have logged to /tmp/petget-installed-pkgs-log
  286. if [ -s /tmp/petget-installed-pkgs-log ];then
  287. [ -f /tmp/install_quietly ] && FLAGPET='yes'
  288. if [ "$FLAGPET" != "yes" ];then #101016 do not offer to trim-the-fat if pet pkg(s)
  289. BUTTONS9="<text><label>$(gettext "NOTE: If you are concerned about the large size of the installed packages, Puppy has some clever code to delete files that are not likely to be needed for the application to actually run. If you would like to try this, click 'Trim the fat' button (otherwise just click 'OK'):")</label></text>
  290. <hbox>
  291. <button><label>$(gettext 'Trim the fat')</label><action type=\"exit\">BUTTON_TRIM_FAT</action></button>
  292. <button ok></button>
  293. </hbox>"
  294. else
  295. BUTTONS9="<hbox>
  296. <button ok></button>
  297. </hbox>"
  298. fi
  299. INSTALLEDMSG="`cat /tmp/petget-installed-pkgs-log`" #ex line: "PACKAGE: langpack_ru-20120720 CATEGORY: Setup"
  300. #note, same code in petget...
  301. #121011 L18L reported problem, category names also need translating...
  302. ZDesktop="$(gettext 'Desktop')"
  303. ZSystem="$(gettext 'System')"
  304. ZSetup="$(gettext 'Setup')"
  305. ZUtility="$(gettext 'Utility')"
  306. ZFilesystem="$(gettext 'Filesystem')"
  307. ZGraphic="$(gettext 'Graphic')"
  308. ZDocument="$(gettext 'Document')"
  309. ZBusiness="$(gettext 'Business')"
  310. ZPersonal="$(gettext 'Personal')"
  311. ZNetwork="$(gettext 'Network')"
  312. ZInternet="$(gettext 'Internet')"
  313. ZMultimedia="$(gettext 'Multimedia')"
  314. ZFun="$(gettext 'Fun')"
  315. ZHelp="$(gettext 'Help')"
  316. Znone="$(gettext 'none')"
  317. ZPTNDesktop="s%CATEGORY: Desktop%CATEGORY: ${ZDesktop}%"
  318. ZPTNSystem="s%CATEGORY: System%CATEGORY: ${ZSystem}%"
  319. ZPTNSetup="s%CATEGORY: Setup%CATEGORY: ${ZSetup}%"
  320. ZPTNUtility="s%CATEGORY: Utility%CATEGORY: ${ZUtility}%"
  321. ZPTNFilesystem="s%CATEGORY: Filesystem%CATEGORY: ${ZFilesystem}%"
  322. ZPTNGraphic="s%CATEGORY: Graphic%CATEGORY: ${ZGraphic}%"
  323. ZPTNDocument="s%CATEGORY: Document%CATEGORY: ${ZDocument}%"
  324. ZPTNBusiness="s%CATEGORY: Business%CATEGORY: ${ZBusiness}%"
  325. ZPTNPersonal="s%CATEGORY: Personal%CATEGORY: ${ZPersonal}%"
  326. ZPTNNetwork="s%CATEGORY: Network%CATEGORY: ${ZNetwork}%"
  327. ZPTNInternet="s%CATEGORY: Internet%CATEGORY: ${ZInternet}%"
  328. ZPTNMultimedia="s%CATEGORY: Multimedia%CATEGORY: ${ZMultimedia}%"
  329. ZPTNFun="s%CATEGORY: Fun%CATEGORY: ${ZFun}%"
  330. ZPTNHelp="s%CATEGORY: Help%CATEGORY: ${ZHelp}%"
  331. ZPTNnone="s%CATEGORY: none%CATEGORY: ${Znone}%"
  332. #120927 want to translate "CATEGORY:" and "PACKAGE:" that are in /tmp/petget-installed-pkgs-log (see installpkg.sh)...
  333. ZCATEGORY="$(gettext 'CATEGORY:')"
  334. ZPACKAGE="$(gettext 'PACKAGE:')"
  335. ZPTN1="s%CATEGORY:%${ZCATEGORY}%"
  336. ZPTN2="s%PACKAGE:%${ZPACKAGE}%"
  337. ZINSTALLEDMSG="$(sed -e "$ZPTNDesktop" -e "$ZPTNSystem" -e "$ZPTNSetup" -e "$ZPTNUtility" -e "$ZPTNFilesystem" -e "$ZPTNGraphic" -e "$ZPTNDocument" -e "$ZPTNBusiness" -e "$ZPTNPersonal" -e "$ZPTNNetwork" -e "$ZPTNInternet" -e "$ZPTNMultimedia" -e "$ZPTNFun" -e "$ZPTNHelp" -e "$ZPTNnone" -e "$ZPTN1" -e "$ZPTN2" /tmp/petget-installed-pkgs-log)" #121011 more ptns.
  338. CAT_MSG="$(gettext 'Note: the package(s) do not have a menu entry.')"
  339. [ "`echo "$INSTALLEDMSG" | grep -o 'CATEGORY.*' | grep -v 'none'`" != "" ] && CAT_MSG="$(gettext '...look in the appropriate category in the menu (bottom-left of screen) to run the application. Note, some packages do not have a menu entry.')" #424 fix. 101016 fix.
  340. #120904 vertical scrollbar...
  341. if [ ! -f /tmp/install_quietly ]; then
  342. export PPM_INSTALL="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
  343. <vbox>
  344. <pixmap><input file>/usr/share/pixmaps/puppy/dialog-complete.svg</input></pixmap>
  345. <text><label>$(gettext 'The following packages have been successfully installed:')</label></text>
  346. <vbox scrollable=\"true\" height=\"100\">
  347. <text wrap=\"false\" use-markup=\"true\"><label>\"<b>${ZINSTALLEDMSG}</b>\"</label></text>
  348. </vbox>
  349. <text><label>${CAT_MSG}</label></text>
  350. ${BUTTONS9}
  351. </vbox>
  352. </window>
  353. "
  354. RETPARAMS="`gtkdialog -p PPM_INSTALL`"
  355. eval "$RETPARAMS"
  356. else
  357. RETPARAMS='EXIT="OK"'
  358. fi
  359. #trim the fat...
  360. if [ "$EXIT" = "BUTTON_TRIM_FAT" ];then
  361. INSTALLEDPKGNAMES="`echo "$INSTALLEDMSG" | cut -f 2 -d ' ' | tr '\n' ' '`"
  362. #101013 improvement suggested by L18L...
  363. CURRLOCALES="`locale -a | grep _ | cut -d '_' -f 1`"
  364. LISTLOCALES="`echo -e -n "en\n${CURRLOCALES}" | sort -u | tr -s '\n' | tr '\n' ',' | sed -e 's%,$%%'`"
  365. export PPM_TRIM_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
  366. <vbox>
  367. <pixmap><input file>/usr/share/pixmaps/puppy/dialog-question.svg</input></pixmap>
  368. <text><label>$(gettext "You have chosen to 'trim the fat' of these installed packages:")</label></text>
  369. <text use-markup=\"true\"><label>\"<b>${INSTALLEDPKGNAMES}</b>\"</label></text>
  370. <frame Locale>
  371. <text><label>$(gettext 'Type the 2-letter country designations for the locales that you want to retain, separated by commas. Leave blank to retain all locale files (see /usr/share/locale for examples):')</label></text>
  372. <entry><default>${LISTLOCALES}</default><variable>ENTRY_LOCALE</variable></entry>
  373. </frame>
  374. <frame $(gettext 'Documentation')>
  375. <checkbox><default>true</default><label>$(gettext 'Tick this to delete documentation files')</label><variable>CHECK_DOCDEL</variable></checkbox>
  376. </frame>
  377. <frame $(gettext 'Development')>
  378. <checkbox><default>true</default><label>$(gettext 'Tick this to delete development files')</label><variable>CHECK_DEVDEL</variable></checkbox>
  379. <text><label>$(gettext '(only needed if these packages are required as dependencies when compiling another package from source code)')</label></text>
  380. </frame>
  381. <text><label>$(gettext "Click 'OK', or if you decide to chicken-out click 'Cancel':")</label></text>
  382. <hbox>
  383. <button ok></button>
  384. <button cancel></button>
  385. </hbox>
  386. </vbox>
  387. </window>"
  388. RETPARAMS="`gtkdialog -p PPM_TRIM_DIALOG`"
  389. eval "$RETPARAMS"
  390. [ "$EXIT" != "OK" ] && exit $EXITVAL
  391. if [ ! -f /tmp/install_quietly ]; then
  392. /usr/lib/gtkdialog/box_splash -text "$(gettext 'Please wait, trimming fat from packages...')" &
  393. X4PID=$!
  394. fi
  395. elPATTERN="`echo -n "$ENTRY_LOCALE" | tr ',' '\n' | sed -e 's%^%/%' -e 's%$%/%' | tr '\n' '|'`"
  396. for PKGNAME in $INSTALLEDPKGNAMES
  397. do
  398. cat /root/.packages/${PKGNAME}.files |
  399. while read ONEFILE
  400. do
  401. [ ! -f "$ONEFILE" ] && continue
  402. [ -h "$ONEFILE" ] && continue
  403. #find out if this is an international language file...
  404. if [ "$ENTRY_LOCALE" != "" ];then
  405. if [ "`echo -n "$ONEFILE" | grep --extended-regexp '/locale/|/nls/|/i18n/' | grep -v -E "$elPATTERN"`" != "" ];then
  406. rm -f "$ONEFILE"
  407. grep -v "$ONEFILE" /root/.packages/${PKGNAME}.files > /tmp/petget_pkgfiles_temp
  408. mv -f /tmp/petget_pkgfiles_temp /root/.packages/${PKGNAME}.files
  409. continue
  410. fi
  411. fi
  412. #find out if this is a documentation file...
  413. if [ "$CHECK_DOCDEL" = "true" ];then
  414. if [ "`echo -n "$ONEFILE" | grep --extended-regexp '/man/|/doc/|/doc-base/|/docs/|/info/|/gtk-doc/|/faq/|/manual/|/examples/|/help/|/htdocs/'`" != "" ];then
  415. rm -f "$ONEFILE" 2>/dev/null
  416. grep -v "$ONEFILE" /root/.packages/${PKGNAME}.files > /tmp/petget_pkgfiles_temp
  417. mv -f /tmp/petget_pkgfiles_temp /root/.packages/${PKGNAME}.files
  418. continue
  419. fi
  420. fi
  421. #find out if this is development file...
  422. if [ "$CHECK_DEVDEL" = "true" ];then
  423. if [ "`echo -n "$ONEFILE" | grep --extended-regexp '/include/|/pkgconfig/|/aclocal|/cvs/|/svn/'`" != "" ];then
  424. rm -f "$ONEFILE" 2>/dev/null
  425. grep -v "$ONEFILE" /root/.packages/${PKGNAME}.files > /tmp/petget_pkgfiles_temp
  426. mv -f /tmp/petget_pkgfiles_temp /root/.packages/${PKGNAME}.files
  427. continue
  428. fi
  429. #all .a and .la files... and any stray .m4 files...
  430. if [ "`echo -n "$ONEBASE" | grep --extended-regexp '\.a$|\.la$|\.m4$'`" != "" ];then
  431. rm -f "$ONEFILE"
  432. grep -v "$ONEFILE" /root/.packages/${PKGNAME}.files > /tmp/petget_pkgfiles_temp
  433. mv -f /tmp/petget_pkgfiles_temp /root/.packages/${PKGNAME}.files
  434. fi
  435. fi
  436. done
  437. done
  438. [ ! -f /tmp/install_quietly ] && kill $X4PID || echo
  439. fi
  440. fi
  441. exit $EXITVAL #101118
  442. ###END###