removemodes.sh 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #!/bin/bash
  2. #set -x ; mkdir -p /root/LOGs; NAME=$(basename "$0"); exec 1>> /root/LOGs/"$NAME".log 2>&1
  3. export TEXTDOMAIN=petget___pkg_chooser.sh
  4. export OUTPUT_CHARSET=UTF-8
  5. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  6. # Check input
  7. if [ "$TREE2" != "" ]; then
  8. if [ "$(grep $TREE2 /tmp/pkgs_to_remove)" = "" ]; then
  9. echo "$TREE2" >> /tmp/pkgs_to_remove
  10. fi
  11. else
  12. exit 0
  13. fi
  14. report_window () {
  15. #[ ! -f /tmp/remove_pets_quietly ] && exit 0
  16. /usr/local/petget/finduserinstalledpkgs.sh
  17. sync
  18. rm -f /tmp/pgks_really_removed 2>/dev/null
  19. rm -f /tmp/pgks_failed_to_remove 2>/dev/null
  20. for LINE in $(cat /tmp/pkgs_to_remove_done)
  21. do
  22. REALLY=$(grep $LINE /tmp/petget/installedpkgs.results)
  23. if [ "$REALLY" = "" ]; then
  24. echo $LINE >> /tmp/pgks_really_removed
  25. else
  26. echo $LINE >> /tmp/pgks_failed_to_remove
  27. fi
  28. done
  29. REMOVED_PGKS="$(</tmp/pgks_really_removed)"
  30. FAILED_TO_REMOVE="$(</tmp/pgks_failed_to_remove)"
  31. if [ -s /tmp/overall_petget-deps-maybe-rem ];then
  32. MAYBEREM="`cat /tmp/overall_petget-deps-maybe-rem | cut -f 1 -d ' ' | tr '\n' ' '`"
  33. MAYBEREMMSG1="$(gettext 'The following package(s) are dependencies for the package(s) you just removed. You may want to remove them too or reinstalled the package(s) you just removed'):
  34. <i><b>${MAYBEREM}</b></i>"
  35. fi
  36. cat << EOF > /tmp/overall_remove_deport
  37. Packages succesfully uninstalled:
  38. $REMOVED_PGKS
  39. Packages that did not uninstall properly or the user abortded their removal:
  40. $FAILED_TO_REMOVE
  41. Installed packages that may not be needed after the removal of the above:
  42. $MAYBEREM
  43. EOF
  44. # Info window/dialogue (display and option to save "missing" info)
  45. export REPORT_DIALOG='
  46. <window title="'$(gettext 'Puppy Package Manager')'" icon-name="gtk-about" default_height="550">
  47. <vbox space-expand="true" space-fill="true">
  48. '"`/usr/lib/gtkdialog/xml_info fixed package_remove.svg 60 " " "$(gettext "Remove packages report")"`"'
  49. <hbox space-expand="true" space-fill="true">
  50. <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  51. <hbox space-expand="false" space-fill="false">
  52. <eventbox name="bg_report" space-expand="true" space-fill="true">
  53. <vbox margin="5" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  54. '"`/usr/lib/gtkdialog/xml_pixmap dialog-complete.svg 32`"'
  55. <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>
  56. </vbox>
  57. </eventbox>
  58. </hbox>
  59. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="2" vscrollbar-policy="1" space-expand="true" space-fill="true">
  60. <text ypad="5" xpad="5" yalign="0" xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<i><b>'${REMOVED_PGKS}' </b></i>"</label></text>
  61. </vbox>
  62. </hbox>
  63. </hbox>
  64. <hbox space-expand="true" space-fill="true">
  65. <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  66. <hbox space-expand="false" space-fill="false">
  67. <eventbox name="bg_report" space-expand="true" space-fill="true">
  68. <vbox margin="5" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  69. '"`/usr/lib/gtkdialog/xml_pixmap dialog-error.svg 32`"'
  70. <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>
  71. </vbox>
  72. </eventbox>
  73. </hbox>
  74. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="2" vscrollbar-policy="1" space-expand="true" space-fill="true">
  75. <text ypad="5" xpad="5" yalign="0" xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<i><b>'${FAILED_TO_REMOVE}' </b></i>"</label></text>
  76. </vbox>
  77. </hbox>
  78. </hbox>
  79. <hbox space-expand="true" space-fill="true">
  80. <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  81. <hbox space-expand="false" space-fill="false">
  82. <eventbox name="bg_report" space-expand="true" space-fill="true">
  83. <vbox margin="5" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  84. '"`/usr/lib/gtkdialog/xml_pixmap building_block.svg 32`"'
  85. <text angle="90" wrap="false" yalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"<big><b><span color='"'#bbb'"'>'$(gettext 'Depends')'</span></b></big> "</label></text>
  86. </vbox>
  87. </eventbox>
  88. </hbox>
  89. <vbox scrollable="true" shadow-type="0" hscrollbar-policy="1" vscrollbar-policy="1" space-expand="true" space-fill="true">
  90. <text ypad="5" xpad="5" yalign="0" xalign="0" use-markup="true" space-expand="true" space-fill="true"><label>"'${MAYBEREMMSG1}'"</label></text>
  91. </vbox>
  92. </hbox>
  93. </hbox>
  94. <hbox space-expand="false" space-fill="false">
  95. <button>
  96. <label>'$(gettext 'View details')'</label>
  97. '"`/usr/lib/gtkdialog/xml_button-icon document_viewer`"'
  98. <action>defaulttextviewer /tmp/overall_remove_deport &</action>
  99. </button>
  100. <button ok></button>
  101. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  102. </hbox>
  103. </vbox>
  104. </window>'
  105. RETPARAMS="`gtkdialog --center -p REPORT_DIALOG`"
  106. rm -f /tmp/pgks_really_removed
  107. rm -f /tmp/pgks_failed_to_remove
  108. rm -f /tmp/pkgs_to_remove_done
  109. rm -f /tmp/overall_remove_deport
  110. rm -f /tmp/overall_petget-deps-maybe-rem
  111. echo 100 > /tmp/petget/install_status_percent
  112. }
  113. export -f report_window
  114. remove_package () {
  115. [ ! "$(</tmp/pkgs_to_remove)" ] && exit 0
  116. TOTAL="$(grep -c "[a-z]" /tmp/pkgs_to_remove)"
  117. COUNT=0
  118. cp /tmp/pkgs_to_remove /tmp/pkgs_left_to_remove
  119. # cat /tmp/pkgs_to_remove
  120. for LINE in $(cat /tmp/pkgs_to_remove)
  121. do
  122. TREE2=$LINE
  123. #output to progressbar
  124. COUNT=$(($COUNT+1))
  125. PERCENT=$(($COUNT*100/$TOTAL))
  126. [ $PERCENT = 100 ] && PERCENT=99
  127. echo $PERCENT > /tmp/petget/install_status_percent
  128. echo "$(gettext 'Removing'): $LINE" > /tmp/petget/install_status
  129. #---
  130. if [ -f /tmp/remove_pets_quietly ]; then
  131. if [ "$(cat /var/local/petget/nt_category 2>/dev/null)" = "true" ]; then
  132. /usr/local/petget/removepreview.sh
  133. else
  134. rxvt -title "$(gettext 'Removing... Do NOT Close')" \
  135. -fn -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-* -bg black \
  136. -fg grey -geometry 80x5+50+50 -e /usr/local/petget/removepreview.sh
  137. fi
  138. else
  139. /usr/local/petget/removepreview.sh
  140. fi
  141. sed -i "/$TREE2/d" /tmp/pkgs_left_to_remove
  142. sync
  143. done
  144. /usr/local/petget/findmissingpkgs.sh
  145. /usr/local/petget/finduserinstalledpkgs.sh
  146. rm -f /tmp/{pkgs_to_remove,pkgs_left_to_remove}
  147. report_window
  148. rm -f /tmp/remove_pets_quietly 2>/dev/null
  149. }
  150. export -f remove_package
  151. classic_remove () {
  152. rm -f /tmp/remove{,_pets}_quietly 2>/dev/null
  153. cp -a /tmp/pkgs_to_remove /tmp/pkgs_to_remove_done
  154. remove_package
  155. echo 100 > /tmp/petget/install_status_percent
  156. }
  157. export -f classic_remove
  158. auto_remove () {
  159. rm -f /tmp/remove_pets_quietly 2>/dev/null
  160. touch /tmp/remove_pets_quietly
  161. cp -a /tmp/pkgs_to_remove /tmp/pkgs_to_remove_done
  162. remove_package
  163. }
  164. export -f auto_remove
  165. delete_out_entry () {
  166. sed -i "/$TREE2/d" /tmp/pkgs_to_remove
  167. }
  168. export -f delete_out_entry
  169. case "$1" in
  170. "$(gettext 'Auto remove')") auto_remove;;
  171. "$(gettext 'Step by step remove (classic mode)')") classic_remove;;
  172. esac