findmissingpkgs.sh 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2009, puppylinux.com
  3. #2009 Lesser GPL licence v2 (see /usr/share/doc/legal).
  4. #called from /usr/local/petget/installpreview.sh or check_deps.sh
  5. #/tmp/petget_pkg_name_aliases_patterns is written by pkg_chooser.sh.
  6. #passed param is a list of dependencies (DB_dependencies field of the pkg database).
  7. #results format, see comment end of this script.
  8. #100126 handle PKG_NAME_IGNORE variable from file PKGS_MANAGEMENT.
  9. #100711 fix handling of PKG_NAME_ALIASES variable (defined in PKGS_MANAGEMENT file).
  10. #110706 finding missing dependencies fix (running mageia 1).
  11. #110722 versioning info added to dependencies.
  12. #110822 versioning operators can be chained, ex: +linux_kernel&ge2.6.32&lt2.6.33
  13. #120822 in precise puppy have a pet 'cups' instead of the ubuntu debs. the latter are various pkgs, including 'libcups2'. we don't want libcups2 showing up as a missing dependency, so have to screen these alternative names out. see also pkg_chooser.sh
  14. #120904 bugfix, was very slow.
  15. DB_dependencies="$1" #in standard format of the package database, field 9.
  16. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  17. . /root/.packages/DISTRO_PKGS_SPECS #has PKGS_SPECS_TABLE
  18. . /root/.packages/PKGS_MANAGEMENT #has PKG_ALIASES_INSTALLED
  19. #110722 versioning info added to dependencies...
  20. #the dependencies field can now have &ge, &gt, &eq, &le, &lt
  21. #ex1: |+ncurses,+readline&ge2.3.5,+glibc|
  22. #chained operators allowed: ex2: |+ncurses,+readline&ge2.3.5&lt2.3.6,+glibc|
  23. #if you want a package to be kernel version sensitive:
  24. #ex3: |+ncurses,+readline,+glibc,+linux_kernel&ge2.6.39|
  25. xDB_dependencies="`echo -n "$DB_dependencies" | tr ',' '\n' | cut -f 1 -d '&' | tr '\n' ','`" #110722 chop off any versioning info.
  26. #make pkg deps into patterns... 110722 change DB_dependencies to xDB_dependencies...
  27. PKGDEPS_PATTERNS="`echo -n "$xDB_dependencies" | tr ',' '\n' | grep '^+' | sed -e 's%^+%%' -e 's%^%|%' -e 's%$%|%'`"
  28. echo "$PKGDEPS_PATTERNS" > /tmp/petget_pkg_deps_patterns #ex line, mageia: |libdbus-glib-1_2|
  29. #110722 same as above, but with versioning info...
  30. PKGDEPS_PATTERNS_WITHVER="`echo -n "$DB_dependencies" | tr ',' '\n' | grep '^+' | sed -e 's%^+%%' -e 's%^%|%' -e 's%$%|%' -e 's%&%|%g'`"
  31. echo "$PKGDEPS_PATTERNS_WITHVER" > /tmp/petget_pkg_deps_patterns_with_versioning #ex line, mageia: |libdbus-glib-1_2|ge2.3.6|
  32. #110706 mageia, a dep "libdbus-glib-1_2" must be located in variable PKG_ALIASES_INSTALLED (in file PKGS_MANAGEMENT)...
  33. #/tmp/petget_pkg_name_aliases_patterns[_raw] created in check_deps.sh
  34. for ONEALIAS in `cat /tmp/petget_pkg_name_aliases_patterns_raw | tr '\n' ' ' | tr ',' ' '` #ex: |cxxlibs|,|glibc.*|,|libc\-.*|
  35. do
  36. FNDDEPSPTNS="`grep "$ONEALIAS" /tmp/petget_pkg_deps_patterns`"
  37. if [ "$FNDDEPSPTNS" != "" ];then
  38. echo "$FNDDEPSPTNS" >> /tmp/petget_pkg_name_aliases_patterns
  39. fi
  40. done
  41. #need patterns of all installed pkgs...
  42. #100711 /tmp/petget_installed_patterns_system is created in pkg_chooser.sh.
  43. cp -f /tmp/petget_installed_patterns_system /tmp/petget_installed_patterns_all
  44. if [ -s /root/.packages/user-installed-packages ];then
  45. INSTALLED_PATTERNS_USER="`cat /root/.packages/user-installed-packages | cut -f 2 -d '|' | sed -e 's%^%|%' -e 's%$%|%' -e 's%\\-%\\\\-%g'`"
  46. echo "$INSTALLED_PATTERNS_USER" >> /tmp/petget_installed_patterns_all
  47. #120822 this code also in pkg_chooser.sh, find alt deb names...
  48. case $DISTRO_BINARY_COMPAT in
  49. ubuntu|debian|raspbian)
  50. #120904 bugfix, was very slow...
  51. MODIF1=`stat --format=%Y /root/.packages/user-installed-packages` #seconds since epoch.
  52. MODIF2=0
  53. [ -f /var/local/petget/installed_alt_ptns_pet_user ] && MODIF2=`stat --format=%Y /var/local/petget/installed_alt_ptns_pet_user`
  54. if [ $MODIF1 -gt $MODIF2 ];then
  55. INSTALLED_PTNS_PET="$(grep '\.pet|' /root/.packages/user-installed-packages | cut -f 2 -d '|')"
  56. if [ "$INSTALLED_PTNS_PET" != "" ];then
  57. xINSTALLED_PTNS_PET="$(echo "$INSTALLED_PTNS_PET" | sed -e 's%^%/%' -e 's%$%|%' -e 's%\-%\\-%g')"
  58. echo "$xINSTALLED_PTNS_PET" > /tmp/petget/fmp_xipp
  59. INSTALLED_ALT_NAMES="$(grep --no-filename -f /tmp/petget/fmp_xipp /root/.packages/Packages-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}-* | cut -f 2 -d '|')"
  60. if [ "$INSTALLED_ALT_NAMES" ];then
  61. INSTALLED_ALT_PTNS="$(echo "$INSTALLED_ALT_NAMES" | sed -e 's%^%|%' -e 's%$%|%' -e 's%\-%\\-%g')"
  62. echo "$INSTALLED_ALT_PTNS" > /var/local/petget/installed_alt_ptns_pet_user
  63. echo "$INSTALLED_ALT_PTNS" >> /tmp/petget_installed_patterns_all
  64. fi
  65. fi
  66. touch /var/local/petget/installed_alt_ptns_pet_user
  67. else
  68. cat /var/local/petget/installed_alt_ptns_pet_user >> /tmp/petget_installed_patterns_all
  69. fi
  70. ;;
  71. esac
  72. fi
  73. #add these alias names to the installed patterns...
  74. #packages may have different names, add them to installed list...
  75. INSTALLEDALIASES="`grep --file=/tmp/petget_installed_patterns_all /tmp/petget_pkg_name_aliases_patterns | tr ',' '\n'`"
  76. [ "$INSTALLEDALIASES" ] && echo "$INSTALLEDALIASES" >> /tmp/petget_installed_patterns_all
  77. #110706 mageia, a dep "libdbus-glib-1_2" must be located in variable PKG_ALIASES_INSTALLED (in file PKGS_MANAGEMENT)...
  78. #/tmp/petget_pkg_name_aliases_patterns[_raw] created in check_deps.sh, pkg_chooser.sh
  79. for ONEALIAS in `cat /tmp/petget_pkg_name_aliases_patterns_raw | tr '\n' ' ' | tr ',' ' '` #ex: |cxxlibs|,|glibc.*|,|libc\-.*|
  80. do
  81. FNDPTN="`grep "$ONEALIAS" /tmp/petget_installed_patterns_all`"
  82. if [ "$FNDPTN" ];then
  83. FNDDEPPTN="`grep "$ONEALIAS" /tmp/petget_pkg_deps_patterns`"
  84. [ "$FNDDEPPTN" ] && echo "$FNDDEPPTN" >> /tmp/petget_installed_patterns_all
  85. fi
  86. done
  87. #100126 some names to ignore, as most likely already installed...
  88. #/tmp/petget_pkg_name_ignore_patterns is created in pkg_choose.sh
  89. cat /tmp/petget_pkg_name_ignore_patterns >> /tmp/petget_installed_patterns_all
  90. #clean it up...
  91. grep -v '^$' /tmp/petget_installed_patterns_all > /tmp/petget_installed_patterns_all-tmp
  92. mv -f /tmp/petget_installed_patterns_all-tmp /tmp/petget_installed_patterns_all
  93. #remove installed pkgs from the list of dependencies...
  94. MISSINGDEPS_PATTERNS="`grep --file=/tmp/petget_installed_patterns_all -v /tmp/petget_pkg_deps_patterns | grep -v '^$'`"
  95. echo "$MISSINGDEPS_PATTERNS" > /tmp/petget_missingpkgs_patterns #can be read by dependencies.sh, find_deps.sh.
  96. #notes on results:
  97. #/tmp/petget_missingpkgs_patterns has a list of missing dependencies, format ex:
  98. # |kdebase|
  99. # |kdelibs|
  100. # |mesa-lib|
  101. # |qt|
  102. #/tmp/petget_installed_patterns_all (read in dependencies.sh) has a list of already installed
  103. # packages, both builtin and user-installed. One on each line, exs:
  104. # |915resolution|
  105. # |a52dec|
  106. # |absvolume_puppy|
  107. # |alsa\-lib|
  108. # |cyrus\-sasl|
  109. # ...notice the '-' are backslashed.
  110. #110722
  111. MISSINGDEPS_PATTERNS_WITHVER="`grep --file=/tmp/petget_missingpkgs_patterns /tmp/petget_pkg_deps_patterns_with_versioning | grep -v '^$'`"
  112. echo "$MISSINGDEPS_PATTERNS_WITHVER" > /tmp/petget_missingpkgs_patterns_with_versioning #can be read by dependencies.sh, find_deps.sh.
  113. #...ex each line: |kdebase|ge2.3.6|
  114. # ex with chained operators: |kdebase|ge2.3.6|lt2.4.5|
  115. #note, dependencies.sh currently not using this file.
  116. #120831 npierce, jemimah: dependencies.sh now using /tmp/petget_missingpkgs_patterns_with_versioning.
  117. ###END###