check_deps.sh 11 KB

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