remove_builtin 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. #Barry Kauler Dec. 2010, license GPL v3 /usr/share/doc/legal.
  3. #based on a script by technosaurus, Dec. 2010.
  4. #101222 fix menu.
  5. #101227 technosaurus: fixed reverse dependency check.
  6. #110505 support sudo for non-root user.
  7. #120202 rodin.s: internationalized.
  8. #120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
  9. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  10. export TEXTDOMAIN=remove_builtin
  11. export TEXTDOMAINDIR=/usr/share/locale
  12. export OUTPUT_CHARSET=UTF-8
  13. eval_gettext () {
  14. local myMESSAGE=$(gettext "$1")
  15. eval echo \"$myMESSAGE\"
  16. }
  17. export LANGORG=$LANG
  18. Yes_lbl="$(gettext 'Yes')"
  19. No_lbl="$(gettext 'No')"
  20. MSG1="`gettext \"Simple utility to 'delete' packages that are builtin\nto the read-only .sfs file (Squashfs filesystem)\"`"
  21. #!/bin/sh
  22. D=$HOME/.packages/builtin_files
  23. while [ 1 ];do
  24. FIXMENU='no' #101222
  25. PKGS=`ls -1 $D`
  26. PKG=`Xdialog --left --screen-center --backtitle "${MSG1}" --title "$(gettext 'Remove builtin packages')" --stdout --help "$(gettext "In all modes of running Puppy, other than a full hard-drive installation,\n
  27. all of the Puppy files are in a compressed read-only file named 'puppy.sfs'\n
  28. or 'wary_500.sfs' (or some similar name). So you can't actually delete these\n
  29. files. However, if you want to remaster the live-CD to create your own custom\n
  30. Puppy (see Setup menu), you can use this little program to 'pretend' to delete\n
  31. them -- and they will really be gone in the remastered CD. So, for example if\n
  32. you remove SeaMonkey, it will be gone in the remastered CD thus reducing the\n
  33. size of the .iso live-CD file.\n\n
  34. Technical note: the lists of builtin files is at /root/.packages/builtin_files,\n
  35. the list of builtin pkgs is in /root/.packages/woof-installed-packages.")" --combobox "$(gettext 'Select package to remove:')" 0 0 $PKGS`
  36. if [ "$PKG" ];then
  37. aREGEX="|${PKG}|"
  38. DESCR="`grep "$aREGEX" /root/.packages/woof-installed-packages |cut -d "|" -f 10`"
  39. Xdialog --left --screen-center --backtitle "$(gettext 'Confirm that you want to delete') '${PKG}'" --title "$(gettext 'Remove builtin packages')" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$(gettext 'Description of package:')\n
  40. ${DESCR}\n\n
  41. $(gettext 'For information only, these are dependencies of') '${PKG}':\n
  42. `grep "$aREGEX" /root/.packages/woof-installed-packages |cut -d "|" -f 9 | sed -e 's%^+%%' -e 's%,+% %g'`
  43. \n
  44. `eval_gettext \"Warning, removing '\\\${PKG}' _may_ break the following packages:\"`\n
  45. `grep +${PKG} /root/.packages/woof-installed-packages |cut -d "|" -f 2 |tr "\n" " "`
  46. \n
  47. $(gettext 'Continue?')" 0 0
  48. if [ $? -eq 0 ];then
  49. [ "`grep '\.desktop$' ${D}/${PKG}`" != "" ] && FIXMENU='yes' #101222
  50. for x in `cat $D/$PKG`; do [ -d $x ] && cd $x || rm $x; done
  51. for x in `tac $D/$PKG`; do [ -d $x ] && [ ! "`ls $x`" ] && rmdir $x; done
  52. rm $D/$PKG
  53. grep -v "$aREGEX" /root/.packages/woof-installed-packages > /tmp/woof-installed-packages-cut2
  54. mv -f /tmp/woof-installed-packages-cut2 /root/.packages/woof-installed-packages
  55. MSG1="`eval_gettext \"Package '\\\${PKG}' was removed. Choose another...\"`"
  56. if [ "$FIXMENU" = "yes" ];then #101222
  57. fixmenus
  58. [ "`pidof jwm`" != "" ] && jwm -restart
  59. sleep 1
  60. fi
  61. else
  62. MSG1="`eval_gettext \"Package '\\\${PKG}' was not removed. Choose another...\"`"
  63. fi
  64. continue
  65. fi
  66. break
  67. done