installmodes.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. #!/bin/bash
  2. export TEXTDOMAIN=petget___pkg_chooser.sh
  3. export OUTPUT_CHARSET=UTF-8
  4. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  5. if [ -f /root/.packages/download_path ]; then
  6. . /root/.packages/download_path
  7. fi
  8. clean_up () {
  9. if [ "$(ls /tmp/*_pet{,s}_quietly /tmp/install_classic 2>/dev/null |wc -l)" -eq 1 ]; then
  10. for MODE in $(ls /tmp/*_pet{,s}_quietly /tmp/install_classic)
  11. do
  12. mv $MODE $MODE.bak
  13. done
  14. fi
  15. mv /tmp/install_quietly /tmp/install_quietly.bak
  16. echo -n > /tmp/pkgs_to_install
  17. rm -f /tmp/{install,remove}{,_pets}_quietly 2>/dev/null
  18. rm -f /tmp/install_classic 2>/dev/null
  19. rm -f /tmp/download_pets_quietly 2>/dev/null
  20. rm -f /tmp/download_only_pet_quietly 2>/dev/null
  21. rm -f /tmp/pkgs_left_to_install 2>/dev/null
  22. rm -f /tmp/pkgs_to_install_done 2>/dev/null
  23. rm -f /tmp/overall_pkg_size* 2>/dev/null
  24. rm -f /tmp/overall_dependencies 2>/dev/null
  25. rm -f /tmp/mode_changed 2>/dev/null
  26. rm -f /tmp/force*_install 2>/dev/null
  27. rm -f /tmp/pkgs_to_install_done 2>/dev/null
  28. rm -f /tmp/pgks_really_installed 2>/dev/null
  29. rm -f /tmp/pgks_failed_to_install 2>/dev/null
  30. rm -f /tmp/overall_petget_missingpkgs_patterns.txt 2>/dev/null
  31. rm -f /tmp/overall_missing_libs.txt 2>/dev/null
  32. rm -f /tmp/overall_install_report 2>/dev/null
  33. rm -f /tmp/pkgs_to_install_bar 2>/dev/null
  34. rm -f /tmp/manual_pkg_download 2>/dev/null
  35. rm -f /tmp/ppm_reporting 2>/dev/null
  36. rm -f /tmp/pkgs_DL_BAD_LIST 2>/dev/null
  37. rm -rf /tmp/PPM_LOGs/ 2>/dev/null
  38. mv $MODE.bak $MODE
  39. mv /tmp/install_quietly.bak /tmp/install_quietly
  40. }
  41. export -f clean_up
  42. report_results () {
  43. # Info source files
  44. touch /tmp/ppm_reporting # progress bar flag
  45. /usr/local/petget/finduserinstalledpkgs.sh #make sure...
  46. sync
  47. rm -f /tmp/pgks_really_installed 2>/dev/null
  48. rm -f /tmp/pgks_failed_to_install 2>/dev/null
  49. for LINE in $(cat /tmp/pkgs_to_install_done | cut -f 1 -d '|' | sort | uniq)
  50. do
  51. if [ -f /tmp/download_pets_quietly -o -f /tmp/download_only_pet_quietly \
  52. -o -f /tmp/manual_pkg_download ];then
  53. if [ -f /root/.packages/download_path ];then
  54. . /root/.packages/download_path
  55. DOWN_PATH="$DL_PATH"
  56. else
  57. DOWN_PATH=$HOME
  58. fi
  59. PREVINST=''
  60. REALLY=$(ls "$DOWN_PATH" | grep $LINE)
  61. [ "$REALLY" -a "$(grep $LINE /tmp/pkgs_DL_BAD_LIST 2>/dev/null | sort | uniq )" != "" ] && \
  62. REALLY='' && PREVINST="$(gettext 'was previously downloaded')"
  63. else
  64. PREVINST=''
  65. REALLY=$(grep $LINE /tmp/petget/installedpkgs.results)
  66. [ "$(grep $LINE /tmp/pgks_failed_to_install_forced 2>/dev/null | sort | uniq )" != "" -o \
  67. "$(grep $LINE /tmp/pkgs_DL_BAD_LIST 2>/dev/null | sort | uniq )" != "" ] \
  68. && REALLY='' && PREVINST="$(gettext 'was already installed')"
  69. fi
  70. if [ "$REALLY" != "" ]; then
  71. echo $LINE >> /tmp/pgks_really_installed
  72. else
  73. echo $LINE $PREVINST >> /tmp/pgks_failed_to_install
  74. fi
  75. done
  76. rm -f /tmp/pgks_failed_to_install_forced
  77. [ -f /tmp/pgks_really_installed ] && INSTALLED_PGKS="$(</tmp/pgks_really_installed)" \
  78. || INSTALLED_PGKS=''
  79. [ -f /tmp/pgks_failed_to_install ] && FAILED_TO_INSTALL="$(</tmp/pgks_failed_to_install)" \
  80. || FAILED_TO_INSTALL=''
  81. #MISSING_PKGS=$(cat /tmp/overall_petget_missingpkgs_patterns.txt |sort|uniq )
  82. MISSING_LIBS=$(cat /tmp/overall_missing_libs.txt 2>/dev/null | tr ' ' '\n' | sort | uniq )
  83. NOT_IN_PATH_LIBS=$(cat /tmp/overall_missing_libs_hidden.txt 2>/dev/null | tr ' ' '\n' | sort | uniq )
  84. cat << EOF > /tmp/overall_install_report
  85. Packages succesfully Installed or Downloaded
  86. $INSTALLED_PGKS
  87. Packages that failed to be Installed or Downloaded, or were aborted be the user
  88. $FAILED_TO_INSTALL
  89. Missing Shared Libraries
  90. $MISSING_LIBS
  91. Existing Libraries that may be in a location other than /lib and /usr/lib
  92. $NOT_IN_PATH_LIBS
  93. EOF
  94. # Info window/dialogue (display and option to save "missing" info)
  95. MISSINGMSG1="<i><b>$(gettext 'No missing shared libraries')</b></i>"
  96. if [ "$MISSING_LIBS" ];then
  97. MISSINGMSG1="<i><b>$(gettext 'These libraries are missing:')
  98. ${MISSING_LIBS}</b></i>"
  99. fi
  100. if [ "$NOT_IN_PATH_LIBS" ];then #100830
  101. MISSINGMSG1="<i><b>${MISSINGMSG1}</b></i>
  102. $(gettext 'These needed libraries exist but are not in the library search path (it is assumed that a startup script in the package makes these libraries loadable by the application):')
  103. <i><b>${NOT_IN_PATH_LIBS}</b></i>"
  104. fi
  105. export REPORT_DIALOG='
  106. <window title="'$(gettext 'Puppy Package Manager')'" icon-name="gtk-about" default_height="550">
  107. <vbox>
  108. '"`/usr/lib/gtkdialog/xml_info fixed package_add.svg 60 " " "$(gettext "Package install/download report")"`"'
  109. <hbox space-expand="true" space-fill="true">
  110. <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  111. <hbox space-expand="false" space-fill="false">
  112. <eventbox name="bg_report" space-expand="true" space-fill="true">
  113. <vbox margin="5" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  114. '"`/usr/lib/gtkdialog/xml_pixmap dialog-complete.svg 32`"'
  115. <text angle="90" wrap="false" yalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<big><b><span color='"'#15BC15'"'>'$(gettext 'Success')'</span></b></big> "</label></text>
  116. </vbox>
  117. </eventbox>
  118. </hbox>
  119. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="2" vscrollbar-policy="1" space-expand="true" space-fill="true">
  120. <text ypad="5" xpad="5" yalign="0" xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<i><b>'${INSTALLED_PGKS}' </b></i>"</label></text>
  121. </vbox>
  122. </hbox>
  123. </hbox>
  124. <hbox space-expand="true" space-fill="true">
  125. <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  126. <hbox space-expand="false" space-fill="false">
  127. <eventbox name="bg_report" space-expand="true" space-fill="true">
  128. <vbox margin="5" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  129. '"`/usr/lib/gtkdialog/xml_pixmap dialog-error.svg 32`"'
  130. <text angle="90" wrap="false" yalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<big><b><span color='"'#DB1B1B'"'>'$(gettext 'Failed')'</span></b></big> "</label></text>
  131. </vbox>
  132. </eventbox>
  133. </hbox>
  134. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="2" vscrollbar-policy="1" space-expand="true" space-fill="true">
  135. <text ypad="5" xpad="5" yalign="0" xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<i><b>'${FAILED_TO_INSTALL}' </b></i>"</label></text>
  136. </vbox>
  137. </hbox>
  138. </hbox>
  139. <hbox space-expand="true" space-fill="true">
  140. <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  141. <hbox space-expand="false" space-fill="false">
  142. <eventbox name="bg_report" space-expand="true" space-fill="true">
  143. <vbox margin="5" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  144. '"`/usr/lib/gtkdialog/xml_pixmap building_block.svg 32`"'
  145. <text angle="90" wrap="false" yalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<big><b><span color='"'#bbb'"'>'$(gettext 'Libs')'</span></b></big> "</label></text>
  146. </vbox>
  147. </eventbox>
  148. </hbox>
  149. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="1" vscrollbar-policy="1" space-expand="true" space-fill="true">
  150. <text ypad="5" xpad="5" yalign="0" xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'${MISSINGMSG1}'"</label></text>
  151. </vbox>
  152. </hbox>
  153. </hbox>
  154. <hbox space-expand="false" space-fill="false">
  155. <button>
  156. <label>'$(gettext 'View details')'</label>
  157. '"`/usr/lib/gtkdialog/xml_button-icon document_viewer`"'
  158. <action>defaulttextviewer /tmp/overall_install_report &</action>
  159. </button>
  160. <button ok></button>
  161. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  162. </hbox>
  163. </vbox>
  164. </window>'
  165. RETPARAMS="`gtkdialog --center -p REPORT_DIALOG`"
  166. echo 100 > /tmp/petget/install_status_percent
  167. }
  168. export -f report_results
  169. check_total_size () {
  170. rm -f /tmp/petget_deps_visualtreelog 2>/dev/null
  171. rm -f /tmp/petget_frame_cnt 2>/dev/null
  172. rm -f /tmp/petget_missingpkgs_patterns{2,_acc,_acc0,_acc-prev,x0,_and_versioning_level1} 2>/dev/null
  173. rm -f /tmp/petget_moreframes 2>/dev/null
  174. rm -f /tmp/petget_tabs 2>/dev/null
  175. rm -f /tmp/pkgs_to_install_bar 2>/dev/null
  176. #required size
  177. NEEDEDK_PLUS=$( expr $(awk '{ sum += $1 } END { print sum }' /tmp/overall_pkg_size))
  178. [ -f /tmp/overall_pkg_size_RMV ] && \
  179. NEEDEDK_MINUS=$( expr $(awk '{ sum += $1 } END { print sum }' /tmp/overall_pkg_size_RMV)) \
  180. || NEEDEDK_MINUS=0
  181. [ ! "$NEEDEDK_MINUS" ] && NEEDEDK_MINUS=0
  182. NEEDEDK=$( expr $( expr $NEEDEDK_PLUS + $NEEDEDK_MINUS ) / 768 ) # 1.5x
  183. ACTION_MSG=$(gettext 'This is not enough space to download and install the packages (including dependencies) you have selected.')
  184. if [ -f /tmp/download_pets_quietly -o -f /tmp/download_only_pet_quietly ]; then
  185. NEEDEDK=$( expr $NEEDEDK / 3 ) # 0.5x
  186. [ "$DL_PATH" ] && DOWN_PATH="$DL_PATH" || DOWN_PATH="/root"
  187. ACTION_MSG="$(gettext 'This is not enough space to download the packages (including dependencies) you have selected in ')${DOWN_PATH}."
  188. fi
  189. if [ "$(cat /var/local/petget/nd_category 2>/dev/null)" = "true" ]; then
  190. NEEDEDKDOWN=$( expr $NEEDEDK / 3 )
  191. else
  192. NEEDEDKDOWN="$NEEDEDK" # so will not trigger warning
  193. fi
  194. #---
  195. if [ ! -f /tmp/pup_event_sizefreem ]; then
  196. /usr/local/pup_event/frontend_timeout &
  197. sleep 1
  198. if [ ! -f /tmp/pup_event_sizefreem ]; then
  199. . /etc/rc.d/PUPSTATE
  200. case $PUPMODE in
  201. 2) AVAILABLE=$(df -m | grep / | head -n 1 | awk '{print $4}');;
  202. 5|6) AVAILABLE=$(df -m | grep pup_rw | awk '{print $4}');;
  203. 7|13) AVAILABLE=$(df -m | grep pup_ro1 | awk '{print $4}');;
  204. 12) AVAILABLE=$(df -m | grep pup_rw | awk '{print $4}')
  205. [ "$AVAILABLE" = "" ] && AVAILABLE=$(df -m | grep dev_save | awk '{print $4}');;
  206. esac
  207. if [ ! "$AVAILABLE" ]; then
  208. echo "Free space estimation error. Exiting" > /tmp/petget/install_status
  209. . /usr/lib/gtkdialog/box_ok "$(gettext 'Free space error')" error "$(gettext 'This is a rare error that fails to report the available free space. It should be OK after a restart')"
  210. clean_up
  211. exit 1
  212. else
  213. AVAILABLE="$AVAILABLE"
  214. fi
  215. else
  216. AVAILABLE=$(cat /tmp/pup_event_sizefreem | head -n 1 )
  217. fi
  218. else
  219. AVAILABLE=$(cat /tmp/pup_event_sizefreem | head -n 1 )
  220. fi
  221. if [ "$DL_PATH" -a ! "$DL_PATH" = "/root" ]; then
  222. if [ -f /tmp/download_pets_quietly -o -f /tmp/download_only_pet_quietly \
  223. -o "$(cat /var/local/petget/nd_category 2>/dev/null)" = "true" ]; then
  224. SAVEAVAILABLE=$(df -m "$DL_PATH"| awk 'END {print $4}')
  225. else
  226. SAVEAVAILABLE="$AVAILABLE" # so will not trigger warning
  227. fi
  228. else
  229. SAVEAVAILABLE="$AVAILABLE" # so will not trigger warning
  230. fi
  231. if [ -f /tmp/download_pets_quietly -o -f /tmp/download_only_pet_quietly ]; then
  232. [ "$SAVEAVAILABLE" != "$AVAILABLE" ] && AVAILABLE="$SAVEAVAILABLE"
  233. fi
  234. PACKAGES=$(cat /tmp/pkgs_to_install | cut -f 1 -d '|')
  235. DEPENDENCIES=$(cat /tmp/overall_dependencies 2>/dev/null | sort | uniq)
  236. [ "$AVAILABLE" = "0" -o "$AVAILABLE" = "" ] && echo "No space left on device. Exiting" \
  237. > /tmp/petget/install_status && clean_up && exit 0
  238. #statusbar in main gui
  239. PERCENT=$((${NEEDEDK}*100/${AVAILABLE}))
  240. [ $PERCENT -gt 99 ] && PERCENT=99
  241. if [ -s /tmp/overall_pkg_size ] && [ $PERCENT = 0 ]; then PERCENT=1; fi
  242. echo "$PERCENT" > /tmp/petget/install_status_percent
  243. if [ "$(cat /tmp/pkgs_to_install /tmp/overall_dependencies 2>/dev/null)" = "" ]; then
  244. echo "" > /tmp/petget/install_status
  245. else
  246. cat /tmp/pkgs_to_install | cut -f1 -d '|' > /tmp/pkgs_to_install_bar
  247. if [ -f /tmp/install_pets_quietly -o -f /tmp/install_classic ]; then
  248. if [ "$(cat /var/local/petget/nd_category 2>/dev/null)" != "true" ]; then
  249. BARNEEDEDK=$( expr 2 \* ${NEEDEDK} \/ 3 )
  250. BARMSG="$(gettext 'to install')"
  251. else
  252. BARNEEDEDK=${NEEDEDK}
  253. BARMSG="$(gettext 'to install (and keep pkgs)')"
  254. fi
  255. else
  256. BARNEEDEDK=${NEEDEDK}
  257. BARMSG="$(gettext 'to download')"
  258. fi
  259. echo "$(gettext 'Packages (with deps)'): $(cat /tmp/pkgs_to_install_bar /tmp/overall_dependencies 2>/dev/null |sort | uniq | wc -l) - $(gettext 'Required space') ${BARMSG}: ${BARNEEDEDK}MB - $(gettext 'Available'): ${AVAILABLE}MB" > /tmp/petget/install_status
  260. fi
  261. #Check if enough space on system
  262. if [ "$NEEDEDKDOWN" -ge "$SAVEAVAILABLE" -a "$AVAILABLE" -ge "$NEEDEDK" ]; then
  263. ACTION_MSG="$(gettext 'Although there is sufficient space to install the packages, there is no space in your download folder, ')$DL_PATH$(gettext ', to save the packages (including dependencies). ')"
  264. AVAILABLE="$SAVEAVAILABLE"
  265. fi
  266. if [ "$NEEDEDK" -ge "$AVAILABLE" -o "$NEEDEDKDOWN" -ge "$SAVEAVAILABLE" ]; then
  267. export PPM_error='
  268. <window title="PPM - '$(gettext 'Space needed')'" icon-name="gtk-no">
  269. <vbox space-expand="true" space-fill="true">
  270. <frame '$(gettext 'Error')'>
  271. <hbox homogeneous="true">
  272. '"`/usr/lib/gtkdialog/xml_pixmap dialog-error.svg popup`"'
  273. </hbox>
  274. <hbox border-width="10" homogeneous="true">
  275. <vbox space-expand="true" space-fill="true">
  276. <text xalign="0" use-markup="true"><label>"'$(gettext 'Available space on your system is')' '${AVAILABLE}' MB. <b>'${ACTION_MSG}'</b> '$(gettext 'Please delete some files or resize your puppy save area or change package save location, as appropriate.')'"</label></text>
  277. <vbox scrollable="true" shadow-type="0" height="150" width="350" space-expand="true" space-fill="true">
  278. <text xalign="0"><label>"'$PACKAGES'"</label></text>
  279. <text xalign="0"><label>"'$DEPENDENCIES'"</label></text>
  280. </vbox>
  281. </vbox>
  282. </hbox>
  283. </frame>
  284. <hbox space-expand="false" space-fill="false">
  285. <button>
  286. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  287. <label>" '$(gettext 'Ok')' "</label>
  288. </button>
  289. </hbox>
  290. </vbox>
  291. </window>'
  292. gtkdialog --center -p PPM_error
  293. killall yaf-splash
  294. if [ ! -f /tmp/install_classic ]; then
  295. echo "" > /tmp/petget/install_status
  296. echo 0 > /tmp/petget/install_status_percent
  297. if [ "$(ls /tmp/*_pet{,s}_quietly /tmp/install_classic |wc -l)" -eq 1 ]; then
  298. for MODE in $(ls /tmp/*_pet{,s}_quietly /tmp/install_classic)
  299. do
  300. mv $MODE $MODE.bak
  301. done
  302. fi
  303. clean_up
  304. mv $MODE.bak $MODE
  305. else
  306. . /usr/lib/gtkdialog/box_yesno "$(gettext 'Last warning')" "$(eval echo $(gettext '$NEEDEDK of the $AVAILABLE available MB will be used to install the package\(s\) you selected.'))" "<b>$(gettext 'It is NOT sufficient. Please exit now.')</b>" "$(gettext 'However, if you are sure about the step-by-step process, take a risk.')" "$(gettext 'Do you want to cancel installation?')"
  307. if [ "$EXIT" = "yes" ]; then
  308. echo 0 > /tmp/petget/install_status_percent
  309. echo "" > /tmp/petget/install_status
  310. if [ "$(ls /tmp/*_pet{,s}_quietly /tmp/install_classic |wc -l)" -eq 1 ]; then
  311. for MODE in $(ls /tmp/*_pet{,s}_quietly /tmp/install_classic)
  312. do
  313. mv $MODE $MODE.bak
  314. done
  315. fi
  316. clean_up
  317. mv $MODE.bak $MODE
  318. else
  319. echo "good luck"
  320. fi
  321. fi
  322. fi
  323. }
  324. export -f check_total_size
  325. status_bar_func () {
  326. while $1 ; do
  327. TOTALPKGS=$(cat /tmp/pkgs_to_install_bar /tmp/overall_dependencies 2>/dev/null |sort | uniq | wc -l)
  328. DONEPGKS=$(cat /tmp/overall_package_status_log 2>/dev/null | wc -l)
  329. PERCENT=$( expr $DONEPGKS \* 100 \/ $TOTALPKGS )
  330. [ $PERCENT = 100 ] && PERCENT=99
  331. echo $PERCENT > /tmp/petget/install_status_percent
  332. sleep 0.3
  333. [ -f /tmp/ppm_reporting ] && break
  334. done
  335. }
  336. export -f status_bar_func
  337. install_package () {
  338. [ "$(cat /tmp/pkgs_to_install)" = "" ] && exit 0
  339. cat /tmp/pkgs_to_install | tr ' ' '\n' > /tmp/pkgs_left_to_install
  340. rm -f /tmp/overall_package_status_log
  341. echo 0 > /tmp/petget/install_status_percent
  342. echo "$(gettext "Calculating total required space...")" > /tmp/petget/install_status
  343. [ ! -f /root/.packages/skip_space_check ] && check_total_size
  344. status_bar_func &
  345. while read LINE; do
  346. REPO=$(echo $LINE | cut -f 2 -d '|')
  347. echo "$REPO" > /tmp/petget/current-repo-triad
  348. TREE1=$(echo $LINE | cut -f 1 -d '|')
  349. if [ -f /tmp/install_quietly ];then
  350. if [ "$(grep $TREE1 /root/.packages/user-installed-packages 2>/dev/null)" = "" \
  351. -a -f /tmp/install_pets_quietly ]; then
  352. if [ "$(cat /var/local/petget/nt_category 2>/dev/null)" = "true" ]; then
  353. /usr/local/petget/installpreview.sh
  354. else
  355. rxvt -title "$VTTITLE... $(gettext 'Do NOT close')" \
  356. -fn -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-* -bg black \
  357. -fg grey -geometry 80x5+50+50 -e /usr/local/petget/installpreview.sh
  358. fi
  359. else
  360. if [ "$(cat /var/local/petget/nt_category 2>/dev/null)" = "true" ]; then
  361. /usr/local/petget/installpreview.sh
  362. else
  363. rxvt -title "$VTTITLE... $(gettext 'Do NOT close')" \
  364. -fn -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-* -bg black \
  365. -fg grey -geometry 80x5+50+50 -e /usr/local/petget/installpreview.sh
  366. fi
  367. fi
  368. else
  369. /usr/local/petget/installpreview.sh
  370. fi
  371. /usr/local/petget/finduserinstalledpkgs.sh
  372. sed -i "/$TREE1/d" /tmp/pkgs_left_to_install
  373. done < /tmp/pkgs_to_install
  374. sync
  375. report_results
  376. clean_up
  377. }
  378. export -f install_package
  379. recalculate_sizes () {
  380. if [ "$(grep changed /tmp/mode_changed 2>/dev/null)" != "" ]; then
  381. rm -f /tmp/overall_*
  382. for LINE in $(cat /tmp/pkgs_to_install)
  383. do
  384. /usr/local/petget/installed_size_preview.sh $LINE ADD
  385. done
  386. else
  387. echo "cool!"
  388. fi
  389. rm -f /tmp/mode_changed
  390. }
  391. export -f recalculate_sizes
  392. wait_func () {
  393. . /usr/lib/gtkdialog/box_splash -close never -text "$(gettext 'Please wait, calculating total required space for the installation...')" &
  394. X1PID=$!
  395. recalculate_sizes
  396. while true ; do
  397. sleep 0.2
  398. [ "$(ps -eo pid,command | grep installed_size_preview | grep -v grep)" = "" ] && break
  399. done
  400. kill -9 $X1PID
  401. }
  402. export -f wait_func
  403. case "$1" in
  404. check_total_size)
  405. touch /tmp/install_quietly #avoid splashes
  406. check_total_size
  407. ;;
  408. "$(gettext 'Auto install')")
  409. wait_func
  410. rm -f /tmp/install_pets_quietly
  411. rm -f /tmp/install_classic 2>/dev/null
  412. rm -f /tmp/download_pets_quietly 2>/dev/null
  413. rm -f /tmp/download_only_pet_quietly 2>/dev/null
  414. touch /tmp/install_quietly
  415. touch /tmp/install_pets_quietly
  416. cp -a /tmp/pkgs_to_install /tmp/pkgs_to_install_done
  417. VTTITLE=Installing
  418. export VTTITLE
  419. install_package
  420. unset VTTITLE
  421. ;;
  422. "$(gettext 'Download packages (no install)')")
  423. wait_func
  424. rm -f /tmp/install_pets_quietly
  425. rm -f /tmp/install_classic 2>/dev/null
  426. rm -f /tmp/download_pets_quietly 2>/dev/null
  427. rm -f /tmp/download_only_pet_quietly 2>/dev/null
  428. touch /tmp/install_quietly
  429. touch /tmp/download_only_pet_quietly
  430. cp -a /tmp/pkgs_to_install /tmp/pkgs_to_install_done
  431. VTTITLE=Downloading
  432. export VTTITLE
  433. install_package
  434. unset VTTITLE
  435. ;;
  436. "$(gettext 'Download all (packages and dependencies)')")
  437. wait_func
  438. rm -f /tmp/install_pets_quietly
  439. rm -f /tmp/install_classic 2>/dev/null
  440. rm -f /tmp/download_pets_quietly 2>/dev/null
  441. rm -f /tmp/download_only_pet_quietly 2>/dev/null
  442. touch /tmp/install_quietly
  443. touch /tmp/download_pets_quietly
  444. cp -a /tmp/pkgs_to_install /tmp/pkgs_to_install_done
  445. VTTITLE=Downloading
  446. export VTTITLE
  447. install_package
  448. unset VTTITLE
  449. ;;
  450. "$(gettext 'Step by step installation (classic mode)')")
  451. wait_func
  452. rm -f /tmp/install{,_pets}_quietly
  453. rm -f /tmp/download_pets_quietly 2>/dev/null
  454. rm -f /tmp/download_only_pet_quietly 2>/dev/null
  455. touch /tmp/install_classic
  456. cp -a /tmp/pkgs_to_install /tmp/pkgs_to_install_done
  457. install_package
  458. ;;
  459. esac