downloadpkgs.sh 22 KB

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