downloadpkgs.sh 20 KB

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