installed_size_preview.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/bin/sh
  2. # addapted from installpreview.sh
  3. [ -f /root/.packages/skip_space_check ] && exit 0
  4. REPO=$(echo $1 | cut -f 4 -d '|')
  5. [ ! "$REPO" ] && REPO=$(echo $1 | cut -f 2 -d '|')
  6. echo "$REPO" > /tmp/petget/current-repo-triad
  7. TREE1=$(echo $1 | cut -f 1 -d '|')
  8. [ ! "$TREE1" ] && exit 0
  9. export TEXTDOMAIN=petget___installed_size_preview.sh
  10. export OUTPUT_CHARSET=UTF-8
  11. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  12. . /root/.packages/DISTRO_PKGS_SPECS
  13. DB_FILE=Packages-`cat /tmp/petget/current-repo-triad`
  14. tPATTERN='^'"$TREE1"'|'
  15. EXAMDEPSFLAG='yes'
  16. ttPTN='^'"$TREE1"'|.*ALREADY INSTALLED'
  17. if [ "`grep "$ttPTN" /tmp/petget/filterpkgs.results.post`" != "" ];then
  18. EXAMDEPSFLAG='no'
  19. fi
  20. rm -f /tmp/petget_missing_dbentries-* 2>/dev/null
  21. rm -f /tmp/petget_missingpkgs_patterns 2>/dev/null
  22. rm -f /tmp/petget_installedsizek 2>/dev/null
  23. DB_ENTRY="`grep "$tPATTERN" /root/.packages/$DB_FILE | head -n 1`"
  24. DB_dependencies="`echo -n "$DB_ENTRY" | cut -f 9 -d '|'`"
  25. DB_size="`echo -n "$DB_ENTRY" | cut -f 6 -d '|'`"
  26. SIZEFREEM=`cat /tmp/pup_event_sizefreem | head -n 1`
  27. SIZEFREEK=`expr $SIZEFREEM \* 1024`
  28. if [ "$DB_dependencies" != "" -a ! -f /tmp/download_only_pet_quietly ]; then
  29. echo "${TREE1}" > /tmp/petget_installpreview_pkgname
  30. /usr/local/petget/findmissingpkgs.sh "$DB_dependencies"
  31. fi
  32. MISSINGDEPS_PATTERNS="$(cat /tmp/petget_missingpkgs_patterns)"
  33. if [ "$MISSINGDEPS_PATTERNS" = "" -a "$(grep $DB_ENTRY /tmp/overall_dependencies)" = "" ]; then
  34. SIZEMK="`echo -n "$DB_size" | rev | cut -c 1`"
  35. SIZEVAL=`echo -n "$DB_size" | rev | cut -c 2-9 | rev`
  36. case "$SIZEMK" in
  37. K) echo cool /dev/null ;;
  38. M) SIZEVAL=$( expr $SIZEVAL \* 1024 ) ;;
  39. *) SIZEVAL=$( expr $SIZEVAL \/ 1024 ) ;;
  40. esac
  41. if [ "$2" = "RMV" ]; then
  42. echo -$SIZEVAL >> /tmp/overall_pkg_size_RMV
  43. else
  44. echo $SIZEVAL >> /tmp/overall_pkg_size
  45. fi
  46. sync
  47. /usr/local/petget/installmodes.sh check_total_size &
  48. exit 0
  49. fi
  50. /usr/local/petget/dependencies.sh
  51. [ $? -ne 0 ] && kill -9 $(pidof installed_size_preview.sh) \
  52. && exec /usr/local/petget/installed_size_preview.sh
  53. FNDMISSINGDBENTRYFILE="`ls -1 /tmp/petget_missing_dbentries-* 2>/dev/null`"
  54. #130511 popup warning if a dep in devx but devx not loaded...
  55. if ! which gcc; then
  56. NEEDGCC="$(cat /tmp/petget_missing_dbentries-* | grep -E '\|gcc\||\|gcc_dev_DEV\|' | cut -f 1 -d '|')"
  57. if [ "$NEEDGCC" ];then
  58. rm -f /tmp/petget_installed_patterns_system #see pkg_chooser.sh
  59. #create a separate process for the popup, with delay...
  60. DEVXNAME="devx_${DISTRO_FILE_PREFIX}_${DISTRO_VERSION}.sfs"
  61. /usr/lib/gtkdialog/box_ok "PPM $(gettext 'Warning')" warning "<b>$(gettext 'WARNING: devx not installed')</b>" "$(gettext 'Package:') <b>${TREE1}</b>" "$(gettext "This package has dependencies that are in the 'devx' SFS file, which is Puppy's C/C++/Vala/Genie/BaCon mega-package, a complete compiling environment.")" "$(gettext 'The devx file is named:') <b>${DEVXNAME}</b>" "$(gettext "Please cancel installation, close the Puppy Package Manager, then click the 'install' icon on the desktop and install the devx SFS file first.")"
  62. fi
  63. fi
  64. #compose pkgs into checkboxes...
  65. MAIN_REPO="`echo "$DB_FILE" | cut -f 2-9 -d '-'`"
  66. MAINPKG_NAME="`echo "$DB_ENTRY" | cut -f 1 -d '|'`"
  67. MAINPKG_SIZE="`echo "$DB_ENTRY" | cut -f 6 -d '|'`"
  68. INSTALLEDSIZEK=0
  69. if [ "$MAINPKG_SIZE" != "" -a "$(grep $MAINPKG_NAME /tmp/overall_dependencies)" = "" ]; then
  70. if [ "$2" = "RMV" ]; then
  71. INSTALLEDSIZEKMAIN=-$(echo "$MAINPKG_SIZE" | rev | cut -c 2-10 | rev)
  72. echo "$INSTALLEDSIZEKMAIN" > /tmp/petget_installedsizek # In case all deps are needed
  73. else
  74. INSTALLEDSIZEKMAIN=$(echo "$MAINPKG_SIZE" | rev | cut -c 2-10 | rev)
  75. fi
  76. fi
  77. echo -n "" > /tmp/petget_moreframes
  78. echo -n "" > /tmp/petget_tabs
  79. echo "0" > /tmp/petget_frame_cnt
  80. DEP_CNT=0
  81. ONEREPO=""
  82. for ONEDEPSLIST in `ls -1 /tmp/petget_missing_dbentries-*`
  83. do
  84. ONEREPO_PREV="$ONEREPO"
  85. ONEREPO="`echo "$ONEDEPSLIST" | grep -o 'Packages.*' | sed -e 's%Packages\\-%%'`"
  86. cat $ONEDEPSLIST |
  87. while read ONELIST
  88. do
  89. DEP_NAME="`echo "$ONELIST" | cut -f 1 -d '|'`"
  90. DEP_SIZE="`echo "$ONELIST" | cut -f 6 -d '|'`"
  91. ADDSIZEK=0
  92. if [ -f /tmp/overall_dependencies -a \
  93. "$(grep $DEP_NAME /tmp/overall_dependencies)" != "" ]; then
  94. if [ "$2" = "ADD" -o "$(grep $DEP_NAME /tmp/overall_dependencies | wc -l)" -gt 1 ]; then
  95. echo done that
  96. else
  97. [ "$DEP_SIZE" != "" ] && [ "$(grep $DEP_NAME /tmp/overall_dependencies | wc -l)" -le 1 ] \
  98. && [ "$(grep $DEP_NAME /tmp/pkgs_to_install)" = "" ] && ADDSIZEK=`echo "$DEP_SIZE" | rev | cut -c 2-10 | rev`
  99. INSTALLEDSIZEK=`expr $INSTALLEDSIZEK - $ADDSIZEK`
  100. echo "$INSTALLEDSIZEK" > /tmp/petget_installedsizek_rep
  101. fi
  102. else
  103. [ "$DEP_SIZE" != "" ] && [ "$(grep $DEP_NAME /tmp/pkgs_to_install)" = "" ] \
  104. && ADDSIZEK=`echo "$DEP_SIZE" | rev | cut -c 2-10 | rev`
  105. INSTALLEDSIZEK=`expr $INSTALLEDSIZEK + $ADDSIZEK`
  106. echo "$INSTALLEDSIZEK" > /tmp/petget_installedsizek_rep
  107. fi
  108. done
  109. if [ "$(cat /tmp/petget_installedsizek_rep)" != "$INSTALLEDSIZEKMAIN" ]; then
  110. cat /tmp/petget_installedsizek_rep >> /tmp/petget_installedsizek
  111. fi
  112. done
  113. rm -f /tmp/petget_installedsizek_rep
  114. INSTALLEDSIZEK=`cat /tmp/petget_installedsizek`
  115. if [ "$2" = "RMV" ]; then
  116. echo "$INSTALLEDSIZEK" >> /tmp/overall_pkg_size_RMV
  117. for LINE in $(cat /tmp/petget_missing_dbentries-* 2>/dev/null | sort | uniq | cut -f1 -d '|')
  118. do
  119. sed -i "0,/$LINE/{//d;}" /tmp/overall_dependencies
  120. done
  121. else
  122. echo "$INSTALLEDSIZEK" >> /tmp/overall_pkg_size
  123. echo "$INSTALLEDSIZEKMAIN" >> /tmp/overall_pkg_size
  124. cat /tmp/petget_missing_dbentries-* | cut -f1 -d '|' >> /tmp/dependecies_list
  125. fi
  126. if [ "$2" = "ADD" ]; then
  127. cat /tmp/dependecies_list | sort | uniq >> /tmp/overall_dependencies
  128. rm -f /tmp/dependecies_list
  129. fi
  130. sync
  131. /usr/local/petget/installmodes.sh check_total_size &