check_deps.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #!/bin/sh
  2. #choose an installed pkg and find all its dependencies.
  3. #when entered with a passed param, it is a list of pkgs, '|' delimited,
  4. #ex: abiword-1.2.3|aiksaurus-3.4.5|yabby-5.0
  5. #100718 bug fix: code block copied from /usr/local/petget/pkg_chooser.sh
  6. #100718 reduce size of missing-libs list, to fit in window.
  7. #100830 missing libs, but some pkgs have a startup script that makes some libs visible.
  8. #101220 reported missing 'alsa-lib' but wary has 'alsa-lib21a', quick hack fix.
  9. #101221 yaf-splash fix.
  10. #110706 finding missing dependencies fix (running mageia 1).
  11. #120203 BK: internationalized.
  12. #120222 npierce: use list widget, support '_' in name.
  13. #120905 vertical scrollbars, fix window too high.
  14. #130511 need to include devx-only-installed-packages, if loaded.
  15. [ "$(cat /var/local/petget/nt_category 2>/dev/null)" != "true" ] && \
  16. [ -f /tmp/install_quietly ] && set -x
  17. #; mkdir -p /tmp/PPM_LOGs ; NAME=$(basename "$0"); exec 1>> /tmp/PPM_LOGs/"$NAME".log 2>&1
  18. export TEXTDOMAIN=petget___check_deps.sh
  19. export OUTPUT_CHARSET=UTF-8
  20. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  21. . /root/.packages/DISTRO_PKGS_SPECS
  22. echo -n "" > /tmp/missinglibs.txt
  23. echo -n "" > /tmp/missinglibs_details.txt
  24. echo -n "" > /tmp/missingpkgs.txt
  25. echo -n "" > /tmp/missinglibs_cut.txt #100830
  26. echo -n "" > /tmp/missinglibs_hidden.txt #100830
  27. ###130511 also this copied from pkg_chooser.sh...
  28. if [ ! -f /root/.packages/layers-installed-packages ];then
  29. #need to include devx-only-installed-packages, if loaded...
  30. if which gcc;then
  31. cp -f /root/.packages/woof-installed-packages /tmp/ppm-layers-installed-packages
  32. cat /root/.packages/devx-only-installed-packages >> /tmp/ppm-layers-installed-packages
  33. sort -u /tmp/ppm-layers-installed-packages > /root/.packages/layers-installed-packages
  34. else
  35. cp -f /root/.packages/woof-installed-packages /root/.packages/layers-installed-packages
  36. fi
  37. fi
  38. #######100718 code block copied from /usr/local/petget/pkg_chooser.sh#######
  39. . /root/.packages/PKGS_MANAGEMENT #has PKG_REPOS_ENABLED, PKG_NAME_ALIASES
  40. #finds all user-installed pkgs and formats ready for display...
  41. /usr/local/petget/finduserinstalledpkgs.sh #writes to /tmp/installedpkgs.results
  42. #100711 moved from findmissingpkgs.sh...
  43. if [ ! -f /tmp/petget_installed_patterns_system ];then
  44. INSTALLED_PATTERNS_SYS="`cat /root/.packages/layers-installed-packages | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  45. echo "$INSTALLED_PATTERNS_SYS" > /tmp/petget_installed_patterns_system
  46. #PKGS_SPECS_TABLE also has system-installed names, some of them are generic combinations of pkgs...
  47. INSTALLED_PATTERNS_GEN="`echo "$PKGS_SPECS_TABLE" | grep '^yes' | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  48. echo "$INSTALLED_PATTERNS_GEN" >> /tmp/petget_installed_patterns_system
  49. sort -u /tmp/petget_installed_patterns_system > /tmp/petget_installed_patterns_systemx
  50. mv -f /tmp/petget_installed_patterns_systemx /tmp/petget_installed_patterns_system
  51. fi
  52. #100711 this code repeated in findmissingpkgs.sh...
  53. cp -f /tmp/petget_installed_patterns_system /tmp/petget_installed_patterns_all
  54. INSTALLED_PATTERNS_USER="`cat /root/.packages/user-installed-packages | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  55. echo "$INSTALLED_PATTERNS_USER" >> /tmp/petget_installed_patterns_all
  56. #process name aliases into patterns (used in filterpkgs.sh, findmissingpkgs.sh) ... 100126...
  57. xPKG_NAME_ALIASES="`echo "$PKG_NAME_ALIASES" | tr ' ' '\n' | grep -v '^$' | sed -e 's%^%|%' -e 's%$%|%' -e 's%,%|,|%g' -e 's%\\*%.*%g'`"
  58. echo "$xPKG_NAME_ALIASES" > /tmp/petget_pkg_name_aliases_patterns_raw #110706
  59. cp -f /tmp/petget_pkg_name_aliases_patterns_raw /tmp/petget_pkg_name_aliases_patterns #110706 _raw see findmissingpkgs.sh
  60. sed -e 's%\\%%g' /tmp/petget_installed_patterns_all > /tmp/petget_installed_patterns_all2 #101220 hack bugfix, \- should be just -.
  61. #100711 above has a problem as it has wildcards. need to expand...
  62. #ex: PKG_NAME_ALIASES has an entry 'cxxlibs,glibc*,libc-*', the above creates '|cxxlibs|,|glibc.*|,|libc\-.*|',
  63. # after expansion: '|cxxlibs|,|glibc|,|libc-|,|glibc|,|glibc_dev|,|glibc_locales|,|glibc-solibs|,|glibc-zoneinfo|'
  64. echo -n "" > /tmp/petget_pkg_name_aliases_patterns_expanded
  65. for ONEALIASLINE in `cat /tmp/petget_pkg_name_aliases_patterns | tr '\n' ' '` #ex: |cxxlibs|,|glibc.*|,|libc\-.*|
  66. do
  67. echo -n "" > /tmp/petget_temp1
  68. for PARTONELINE in `echo -n "$ONEALIASLINE" | tr ',' ' '`
  69. do
  70. grep "$PARTONELINE" /tmp/petget_installed_patterns_all2 >> /tmp/petget_temp1 #101220 hack see above.
  71. done
  72. ZZZ="`echo "$ONEALIASLINE" | sed -e 's%\.\*%%g' | tr -d '\\'`"
  73. [ -s /tmp/petget_temp1 ] && ZZZ="${ZZZ},`cat /tmp/petget_temp1 | tr '\n' ',' | tr -s ',' | tr -d '\\'`"
  74. ZZZ="`echo -n "$ZZZ" | sed -e 's%,$%%'`"
  75. echo "$ZZZ" >> /tmp/petget_pkg_name_aliases_patterns_expanded
  76. done
  77. cp -f /tmp/petget_pkg_name_aliases_patterns_expanded /tmp/petget_pkg_name_aliases_patterns
  78. #w480 PKG_NAME_IGNORE is definedin PKGS_MANAGEMENT file... 100126...
  79. xPKG_NAME_IGNORE="`echo "$PKG_NAME_IGNORE" | tr ' ' '\n' | grep -v '^$' | sed -e 's%^%|%' -e 's%$%|%' -e 's%,%|,|%g' -e 's%\\*%.*%g'`"
  80. echo "$xPKG_NAME_IGNORE" > /tmp/petget_pkg_name_ignore_patterns
  81. #######100718 end copied code block#######
  82. dependcheckfunc() {
  83. #entered with ex: APKGNAME=abiword-1.2.3
  84. if [ ! -f /tmp/install_quietly ]; then
  85. /usr/lib/gtkdialog/box_splash -close never -placement center -text "$(gettext 'Checking') ${APKGNAME} $(gettext 'for missing shared library files...')" &
  86. X1PID=$!
  87. fi
  88. #a hack if OO is installed...
  89. if [ "`echo -n "$APKGNAME" | grep 'openoffice'`" != "" ];then
  90. [ -d /opt ] && FNDOO="`find /opt -maxdepth 2 -type d -iname 'openoffice*'`"
  91. [ "$FNDOO" = "" ] && FNDOO="`find /usr -maxdepth 2 -type d -iname 'openoffice*'`"
  92. [ "$FNDOO" = "" ] && LD_LIBRARY_PATH="${FNDOO}/program:${LD_LIBRARY_PATH}"
  93. fi
  94. FNDFILES="`cat /root/.packages/$APKGNAME.files`"
  95. for ONEFILE in $FNDFILES
  96. do
  97. ISANEXEC="`file --brief $ONEFILE | grep --extended-regexp "LSB executable|shared object"`"
  98. if [ ! "$ISANEXEC" = "" ];then
  99. LDDRESULT="`ldd $ONEFILE`"
  100. MISSINGLIBS="`echo "$LDDRESULT" | grep "not found" | cut -f 2 | cut -f 1 -d " " | tr "\n" " "`"
  101. if [ ! "$MISSINGLIBS" = "" ];then
  102. echo "$(gettext 'File') $ONEFILE $(gettext 'has these missing library files:')" >> /tmp/missinglibs_details.txt #100718
  103. echo " $MISSINGLIBS" >> /tmp/missinglibs_details.txt #100718
  104. echo " $MISSINGLIBS" >> /tmp/missinglibs.txt #100718
  105. fi
  106. fi
  107. done
  108. if [ -s /tmp/missinglibs.txt ];then #100718 reduce size of list, to fit in window...
  109. MISSINGLIBSLIST="`cat /tmp/missinglibs.txt | tr '\n' ' ' | tr -s ' ' | tr ' ' '\n' | sort -u | tr '\n' ' '`"
  110. echo "$MISSINGLIBSLIST" > /tmp/missinglibs.txt
  111. #100830 some packages, such as EudoraOSE-1.0rc1-Lucid.pet used in Lucid Puppy 5.1, have a
  112. #startup script that makes some libs visible (/opt/eudora), so do this extra check...
  113. for ONEMISSINGLIB in `cat /tmp/missinglibs.txt` #100830
  114. do
  115. if [ "`find /opt /usr/lib /usr/local/lib -maxdepth 3 -name $ONEMISSINGLIB`" == "" ];then
  116. echo -n "$ONEMISSINGLIB " >> /tmp/missinglibs_cut.txt
  117. else
  118. echo -n "$ONEMISSINGLIB " >> /tmp/missinglibs_hidden.txt
  119. fi
  120. done
  121. cp -f /tmp/missinglibs_cut.txt /tmp/missinglibs.txt
  122. fi
  123. [ ! -f /tmp/install_quietly ] && kill $X1PID || echo
  124. }
  125. #searches deps of all user-installed pkgs...
  126. missingpkgsfunc() {
  127. if [ ! -f /tmp/install_quietly ]; then
  128. /usr/lib/gtkdialog/box_splash -close never -text "$(gettext 'Checking all user-installed packages for any missing dependencies...')" &
  129. X2PID=$!
  130. fi
  131. USER_DB_dependencies="`cat /root/.packages/user-installed-packages | cut -f 9 -d '|' | tr ',' '\n' | sort -u | tr '\n' ','`"
  132. /usr/local/petget/findmissingpkgs.sh "$USER_DB_dependencies"
  133. #...returns /tmp/petget_installed_patterns_all, /tmp/petget_pkg_deps_patterns, /tmp/petget_missingpkgs_patterns
  134. MISSINGDEPS_PATTERNS="`cat /tmp/petget_missingpkgs_patterns`" #v431
  135. [ ! -f /tmp/install_quietly ] && kill $X2PID || echo
  136. }
  137. if [ $1 ];then
  138. for APKGNAME in `echo -n $1 | tr '|' ' '`
  139. do
  140. [ -f /root/.packages/${APKGNAME}.files ] && dependcheckfunc
  141. done
  142. else
  143. #ask user what pkg to check...
  144. ACTIONBUTTON="<button>
  145. <label>$(gettext 'Check dependencies')</label>
  146. <action type=\"exit\">BUTTON_CHK_DEPS</action>
  147. </button>"
  148. echo -n "" > /tmp/petget_depchk_buttons
  149. cat /root/.packages/user-installed-packages | cut -f 1,10 -d '|' |
  150. while read ONEPKGSPEC
  151. do
  152. [ "$ONEPKGSPEC" = "" ] && continue
  153. ONEPKG="`echo -n "$ONEPKGSPEC" | cut -f 1 -d '|'`"
  154. ONEDESCR="`echo -n "$ONEPKGSPEC" | cut -f 2 -d '|'`"
  155. #120222 npierce: replaced radiobuttons with list and items
  156. echo "<item>${ONEPKG} DESCRIPTION: ${ONEDESCR}</item>" >> /tmp/petget_depchk_buttons
  157. done
  158. RADBUTTONS="`cat /tmp/petget_depchk_buttons`"
  159. if [ "$RADBUTTONS" = "" ];then
  160. ACTIONBUTTON=""
  161. RADBUTTONS="<item>$(gettext "No packages installed by user, click 'Cancel' button")</item>"
  162. fi
  163. export DEPS_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
  164. <vbox>
  165. <text><label>$(gettext 'Please choose what package you would like to check the dependencies of:')</label></text>
  166. <frame $(gettext 'User-installed packages')>
  167. <list selection-mode=\"2\">
  168. <variable>LIST</variable>
  169. ${RADBUTTONS}
  170. </list>
  171. </frame>
  172. <hbox>
  173. ${ACTIONBUTTON}
  174. <button cancel></button>
  175. </hbox>
  176. </vbox>
  177. </window>
  178. "
  179. RETPARAMS="`gtkdialog3 --geometry=630x327 --program=DEPS_DIALOG`" #120222
  180. #ex returned:
  181. #LIST="audacious-1.5.1"
  182. #EXIT="BUTTON_CHK_DEPS"
  183. [ "`echo "$RETPARAMS" | grep 'BUTTON_CHK_DEPS'`" = "" ] && exit
  184. #120222 npierce: Allow '_' in package name. CAUTION: Names must not contain spaces.
  185. APKGNAME="`echo "$RETPARAMS" | grep '^LIST=' | cut -f 1 -d ' ' | cut -f 2 -d '"'`" #'geanyfix
  186. dependcheckfunc
  187. fi
  188. if [ -f /tmp/install_pets_quietly ]; then
  189. LEFT=$(cat /tmp/pkgs_left_to_install | wc -l)
  190. [ "$LEFT" -le 1 ] && missingpkgsfunc
  191. else
  192. missingpkgsfunc
  193. fi
  194. #present results to user...
  195. MISSINGMSG1="<text use-markup=\"true\"><label>\"<b>$(gettext 'No missing shared libraries')</b>\"</label></text>"
  196. if [ -s /tmp/missinglibs.txt ];then
  197. MISSINGMSG1="<text><label>$(gettext 'These libraries are missing:')</label></text><text use-markup=\"true\"><label>\"<b>`cat /tmp/missinglibs.txt`</b>\"</label></text>"
  198. fi
  199. if [ -s /tmp/missinglibs_hidden.txt ];then #100830
  200. MISSINGMSG1="${MISSINGMSG1} <text><label>$(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):')</label></text><text use-markup=\"true\"><label>\"<b>`cat /tmp/missinglibs_hidden.txt`</b>\"</label></text>"
  201. fi
  202. MISSINGMSG2="<text use-markup=\"true\"><label>\"<b>$(gettext 'No missing dependent packages')</b>\"</label></text>"
  203. if [ "$MISSINGDEPS_PATTERNS" != "" ];then #[ -s /tmp/petget_missingpkgs ];then
  204. MISSINGPKGS="`echo "$MISSINGDEPS_PATTERNS" | sed -e 's%|%%g' | tr '\n' ' '`" #v431
  205. MISSINGMSG2="<text use-markup=\"true\"><label>\"<b>${MISSINGPKGS}</b>\"</label></text>"
  206. fi
  207. DETAILSBUTTON=""
  208. if [ -s /tmp/missinglibs.txt -o -s /tmp/missinglibs_hidden.txt ];then #100830 details button
  209. DETAILSBUTTON="<button><label>$(gettext 'View details')</label><action>defaulttextviewer /tmp/missinglibs_details.txt & </action></button>"
  210. fi
  211. PKGS="$APKGNAME"
  212. [ $1 ] && PKGS="`echo -n "${1}" | tr '|' ' '`"
  213. #120905 vertical scrollbars, fix window too high...
  214. if [ ! -f /tmp/install_quietly ]; then
  215. export DEPS_DIALOG="<window title=\"$(gettext 'Puppy Package Manager')\" icon-name=\"gtk-about\">
  216. <vbox>
  217. <text><label>$(gettext 'Puppy has searched for any missing shared libraries of these packages:')</label></text>
  218. <vbox scrollable=\"true\" height=\"100\">
  219. <text><label>${PKGS}</label></text>
  220. </vbox>
  221. <vbox scrollable=\"true\" height=\"100\">
  222. ${MISSINGMSG1}
  223. </vbox>
  224. <text><label>$(gettext 'Puppy has examined all user-installed packages and found these missing dependencies:')</label></text>
  225. ${MISSINGMSG2}
  226. <hbox>
  227. ${DETAILSBUTTON}
  228. <button ok></button>
  229. </hbox>
  230. </vbox>
  231. </window>
  232. "
  233. RETPARAMS="`gtkdialog4 --center --program=DEPS_DIALOG`"
  234. else
  235. RETPARAMS='EXIT="OK"'
  236. rm -f /tmp/petget_missing_dbentries-* 2>/dev/null
  237. cat /tmp/petget_missingpkgs_patterns_with_versioning >> \
  238. /tmp/overall_petget_missingpkgs_patterns.txt
  239. rm -f /tmp/petget_missingpkgs_patterns* 2>/dev/null
  240. cat /tmp/missinglibs.txt >> /tmp/overall_missing_libs.txt
  241. cat /tmp/missinglibs_hidden.txt >> /tmp/overall_missing_libs_hidden.txt
  242. rm -f /tmp/missinglibs* 2>/dev/null
  243. fi
  244. ###END###