findpkgs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. #!/bin/bash
  2. #Copyright Barry Kauler, aug 2011, bkhome.org
  3. #110817 find all packages to be used in a Puppy build, pet and compat.
  4. #110821 must also work with working-dir set to /root/.packages
  5. #110908 fix o/p file for pkgs which genericname not found.
  6. #111014 tweak support for 3.x kernel.
  7. #111127 no longer check if host has 'printcols', 'vercmp', it is done in 'merge2out' script.
  8. #111127 syntax checking of db files is happening too much.
  9. #111128 checking fields 11,12,13 of db now much faster.
  10. #111204 do not use /var/local/woof, instead 'status' directory (better for running from different save-files).
  11. #111204 use md5sum for all checking whether to rerun this script.
  12. #120515 build from "gentoo" binary tarballs (refer support/gentoo).
  13. #120719 support raspbian.
  14. #120812 db category now allows optional subcategory (for which an icons exists in /usr/local/lib/X11/mini-icons).
  15. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  16. #121102 pet_packages-${DISTRO_COMPAT_VERSION} (or pet_packages-${DISTRO_FILE_PREFIX}) is now pet_packages-${DISTRO_DB_SUBNAME.
  17. #130306 arch linux: gz now xz. maybe only 'DISTRO_COMPAT_REPOS-arch'.
  18. #130312 add wary5 fallback.
  19. #130313 having problem with repo-override. $PKGLOCFLD needs to be respected (ex: pet:wary5).
  20. #130316 fixed bug, getting duplicate :$GENERICNAME: in file FINAL_PKGS.
  21. #130320 fix disappearing pkg in FINAL_PKGS.
  22. #130320 get rid of |puppy|wary5| |t2|8.0rc| in fallbacks searching for pet.
  23. #130321 bring back |t2|8.0rc|
  24. #variable PKGS_SPECS_TABLE in file DISTRO_PKGS_SPECS-* to have optional values in 5th field:
  25. #yes|915resolution||exe,dev,doc,nls|[pet[:<repo>]] or yes|915resolution||exe,dev,doc,nls|[compat[:<repo>]]
  26. #exs: yes|915resolution||exe,dev,doc,nls|compat yes|915resolution|915resolution|exe,dev,doc,nls|compat:core
  27. #...'compat' means pkg from compatible-distro, 'core' is a specific repo, 3rd or 4rd field in 'Packages-mageia-1-core'
  28. #...3rd field is now optional for both pet/compat if 5th field present.
  29. #previously, a pet pkg is implied by empty 3rd field (and empty 5th), however now can have an optional name qualifier...
  30. #ex: yes|915resolution|915resolution-2011*|exe,dev,doc,nls|pet
  31. #...optional glob wildcard(s) in 3rd field, multiple parameters allowed (comma delimiters), '-' exclusion-prefix also.
  32. # PET pkgs: no need to specify _DEV, _DOC, _NLS, they are implied by 4th field.
  33. #if above is unclear, please read: http://bkhome.org/blog/?viewDetailed=02414
  34. export LANG=C #faster.
  35. CURDIR="`pwd`"
  36. if [ "$CURDIR" = "/root/.packages" ];then #110821
  37. . /etc/DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  38. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  39. #DS_DATE=`stat --format=%Y /etc/DISTRO_SPECS`
  40. DS_DATE="`md5sum /etc/DISTRO_SPECS | cut -f 1 -d ' '`"
  41. . ./DISTRO_PKGS_SPECS #has PKGS_SPECS_TABLE, FALLBACKS_COMPAT_VERSIONS
  42. . ./DISTRO_COMPAT_REPOS #v431 has PKG_DOCS_DISTRO_COMPAT
  43. #DPS_MODIFY_DATE=`stat --format=%Y ./DISTRO_PKGS_SPECS` #modify date, seconds since last epoch.
  44. DPS_MODIFY_DATE="`md5sum ./DISTRO_PKGS_SPECS | cut -f 1 -d ' '`"
  45. else
  46. . ./DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  47. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  48. #DS_DATE=`stat --format=%Y ./DISTRO_SPECS`
  49. DS_DATE="`md5sum ./DISTRO_SPECS | cut -f 1 -d ' '`"
  50. if [ -f ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  51. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  52. else
  53. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT} #130306
  54. fi
  55. if [ -f ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  56. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} #has FALLBACKS_COMPAT_VERSIONS
  57. #DPS_MODIFY_DATE=`stat --format=%Y ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}` #modify date, seconds since last epoch.
  58. DPS_MODIFY_DATE="`md5sum ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} | cut -f 1 -d ' '`"
  59. else
  60. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT} #has FALLBACKS_COMPAT_VERSIONS
  61. #DPS_MODIFY_DATE=`stat --format=%Y ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}` #modify date, seconds since last epoch.
  62. DPS_MODIFY_DATE="`md5sum ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT} | cut -f 1 -d ' '`"
  63. fi
  64. fi
  65. . ./DISTRO_PET_REPOS #has PET_REPOS, PACKAGELISTS_PET_ORDER
  66. . ./PKGS_MANAGEMENT #has PKG_NAME_ALIASES
  67. . ./WOOFMERGEVARS #111127 need to know if a cross-build.
  68. #variable DISTRO_KERNEL_PET is in file DISTRO_SPECS... ex: linux_kernel-2.6.32-44-i486-w5.pet 111014 remove if-then...
  69. KERNMAJ="`echo -n "$DISTRO_KERNEL_PET" | cut -f 2 -d '-' | cut -f 1 -d '.'`" #2 or 3
  70. #if [ "$KERNMAJ" = "3" ];then
  71. # KERNELVER3="`echo -n "$DISTRO_KERNEL_PET" | cut -f 2 -d '-' | cut -f 1,2 -d '.' | cut -f 1 -d '_'`" #ex: 3.1
  72. #else
  73. KERNELVER3="`echo -n "$DISTRO_KERNEL_PET" | cut -f 2 -d '-' | cut -f 1,2,3 -d '.' | cut -f 1 -d '_'`" #ex: 2.6.32
  74. #fi
  75. #modify compat-distro fallback list...
  76. if [ "$FALLBACKS_COMPAT_VERSIONS" != "" ];then
  77. FALLBACKS_COMPAT_VERSIONS="`echo -n "$FALLBACKS_COMPAT_VERSIONS" | grep -o "${DISTRO_COMPAT_VERSION}.*"`"
  78. #ex: 'koala jaunty intrepid' gets reduced to 'jaunty intrepid' if DISTRO_COMPAT_VERSION=jaunty
  79. fi
  80. REPO_DEFAULT_SUBDIR="pet_packages-${DISTRO_DB_SUBNAME}" #121102
  81. BINARIES='deb' #get them from packages-deb.
  82. [ "$DISTRO_BINARY_COMPAT" = "t2" ] && BINARIES="bz2" #get them from packages-bz2-${DISTRO_COMPAT_VERSION}.
  83. [ "$DISTRO_BINARY_COMPAT" = "slackware" ] && BINARIES="tgz_txz" #download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  84. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  85. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_xz-${DISTRO_COMPAT_VERSION}. 130306
  86. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #built entirely from pet pkgs.
  87. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  88. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm"
  89. [ "$DISTRO_BINARY_COMPAT" = "gentoo" ] && BINARIES="gentoo" #120515 download to packages-gentoo-gap6
  90. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  91. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}"
  92. #the files that have compatible-distro pkg docs (these were downloaded by 0setup)...
  93. PKGLISTS_COMPAT="`echo "$PKG_DOCS_DISTRO_COMPAT" | tr ' ' '\n' | cut -f 3 -d '|' | tr '\n' ' '`" #see file DISTRO_PKGS_SPECS-ubuntu
  94. #...format ex: 'Packages-ubuntu-intrepid-main Packages-ubuntu-intrepid-universe'
  95. CURRDIR="`pwd`"
  96. #[ ! -d packages-templates ] && exit 1 #precaution.
  97. mkdir -p status
  98. STATUSDIR="${CURRDIR}/status"
  99. #for efficiency, only run this script if have too... 111204 use md5sum instead of date...
  100. KEEPGOING='no'
  101. for ADBFILE in $PACKAGELISTS_PET_ORDER $PKGLISTS_COMPAT
  102. do
  103. #NEWDATE=`stat --format=%Y $ADBFILE`
  104. NEWDATE="`md5sum $ADBFILE | cut -f 1 -d ' '`"
  105. OLDDATE="0"
  106. [ -f ${STATUSDIR}/MODIFY_DATE_${ADBFILE} ] && OLDDATE="`cat ${STATUSDIR}/MODIFY_DATE_${ADBFILE}`"
  107. if [ "$NEWDATE" != "$OLDDATE" ];then
  108. KEEPGOING='yes'
  109. #echo -n "$NEWDATE" > ${STATUSDIR}/MODIFY_DATE_${ADBFILE} #no, this is done below.
  110. fi
  111. done
  112. OLD_DPS_DATE="0"
  113. [ -f ${STATUSDIR}/findpkgs_DPS_MODIFY_DATE-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ] && OLD_DPS_DATE="`cat ${STATUSDIR}/findpkgs_DPS_MODIFY_DATE-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}`"
  114. if [ "$DPS_MODIFY_DATE" != "$OLD_DPS_DATE" ];then
  115. KEEPGOING='yes'
  116. echo -n "${DPS_MODIFY_DATE}" > ${STATUSDIR}/findpkgs_DPS_MODIFY_DATE-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  117. fi
  118. OLD_DS_DATE="0"
  119. [ -f ${STATUSDIR}/findpkgs_MODIFY_DATE_DISTRO_SPECS ] && OLD_DS_DATE="`cat ${STATUSDIR}/findpkgs_MODIFY_DATE_DISTRO_SPECS`"
  120. if [ "$DS_DATE" != "$OLD_DS_DATE" ];then
  121. KEEPGOING='yes'
  122. echo -n "$DS_DATE" > ${STATUSDIR}/findpkgs_MODIFY_DATE_DISTRO_SPECS
  123. fi
  124. [ ! -f ${STATUSDIR}/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ] && KEEPGOING='yes'
  125. if [ "$KEEPGOING" != "yes" ];then
  126. echo
  127. echo "Exiting from support/findpkgs, already created up-to-date pkg list:"
  128. echo " ${STATUSDIR}/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  129. echo
  130. exit 0
  131. fi
  132. rm -rf /tmp/findpkgs_tmp 2>/dev/null
  133. mkdir /tmp/findpkgs_tmp
  134. #remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  135. PKGS_SPECS_TABLE="`echo "$PKGS_SPECS_TABLE" | grep -v '^#' | grep -v '^$' | tr '\t' ' ' | tr -s ' ' | tr '+' '&' | sed -e 's%|&.*%%' | tr '&' '+' | sed -e 's% #.*%%' -e 's% $%%' -e 's%$%|%' -e 's%||$%|%'`"
  136. echo
  137. echo "Checking syntax of PKGS_SPECS_TABLE..."
  138. CNT=1
  139. for ONECHK in $PKGS_SPECS_TABLE
  140. do
  141. BADFLAG='no'
  142. NUMDELS=`echo "$ONECHK" | sed -e 's/[^|]//g' | wc -c`
  143. [ $NUMDELS -lt 4 -o $NUMDELS -gt 6 ] && BADFLAG='yes'
  144. YESNO="`echo "$ONECHK" | cut -f 1 -d '|' | grep -E 'yes|no'`"
  145. [ "YESNO" = "" ] && BADFLAG='yes'
  146. GENPKG="`echo "$ONECHK" | cut -f 2 -d '|'`"
  147. [ "$GENPKG" = "" ] && BADFLAG='yes'
  148. if [ "$BADFLAG" = "yes" ];then
  149. echo "SYNTAX ERROR LINE ${CNT}: '$ONECHK'"
  150. echo "$PKGS_SPECS_TABLE" > /tmp/pst-dump
  151. exit 1
  152. fi
  153. CNT=$(($CNT + 1))
  154. done
  155. echo -n "" > /tmp/findpkgs_tmp/pet_log1
  156. echo -n "" > /tmp/findpkgs_tmp/compat_log1
  157. echo -n "" > /tmp/findpkgs_tmp/PREFERRED_PKGS
  158. echo -n "" > /tmp/findpkgs_tmp/FINAL_PKGS
  159. #compiledPTNS is to select a pkg that most closely matches the compile-environment of the compat-distro...
  160. #||| means architecture-independent pkg, needs high preference, immediately after exact-compiled match...
  161. petcompiledPTNS="|${DISTRO_BINARY_COMPAT}|${DISTRO_COMPAT_VERSION}| |||" #ex: '|ubuntu|intrepid|' '|||'
  162. for ONECOMPATVERSION in $FALLBACKS_COMPAT_VERSIONS #sliding scale, ex: koala jaunty intrepid
  163. do
  164. [ "$ONECOMPATVERSION" = "$DISTRO_COMPAT_VERSION" ] && continue
  165. [ "$ONECOMPATVERSION" = "4" ] && break #bottom of ladder, drop down to |puppy| test only. (i have some |puppy| in common repo, want to find them before |puppy|4|)
  166. petcompiledPTNS="${petcompiledPTNS} |${DISTRO_BINARY_COMPAT}|${ONECOMPATVERSION}|"
  167. done
  168. #need hack, older quirky pkgs compiled with |t2|8.0rc| and have some of these in common repo...
  169. #130320 get rid of |puppy|wary5| |t2|8.0rc| ... 130321 bring back |t2|8.0rc| ...
  170. if [ "$DISTRO_BINARY_COMPAT" = "puppy" ];then
  171. petcompiledPTNS="${petcompiledPTNS} |t2|8.0rc| |puppy| |" #increasingly desperate. last one will find any pkg with matching name. 130312 add wary5.
  172. else
  173. petcompiledPTNS="${petcompiledPTNS} |${DISTRO_BINARY_COMPAT}| |t2|8.0rc| |puppy| |" #increasingly desperate. 130312 add wary5.
  174. fi
  175. ##111127 this code block is running too many times. the most likely situation is when db files for a compat-distro
  176. ##are created by 0setup/1download and the last two/three fields are left out. just check first line of db...
  177. ##problem with ||| above high priority, compileddistro|compiledrelease| are optional fields and may be missing.
  178. ##printcols <file> 2 3 8 9 11 12 (see below) does insert 11 & 12 delimiters if missing, but that would bump the
  179. ##priority of that pkg -- results in pkgs in Packages-puppy-4-official getting chosen.
  180. #for ADBFILE in $PACKAGELISTS_PET_ORDER $PKGLISTS_COMPAT
  181. #do
  182. # NEWDATE=`stat --format=%Y $ADBFILE` #seconds since last epoch.
  183. # OLDDATE=0
  184. # [ -f ${STATUSDIR}/MODIFY_DATE_${ADBFILE} ] && OLDDATE=`cat ${STATUSDIR}/MODIFY_DATE_${ADBFILE}`
  185. # if [ $NEWDATE -ne $OLDDATE ];then
  186. # #if ! vercmp "$NEWDATE" eq "$OLDDATE";then
  187. # echo "Fixing compileddistro|compiledrelease| fields in $ADBFILE"
  188. # echo -n "" > /tmp/findpkgs_tmp/dbfilefixed
  189. # DB_compileddistro="`echo -n "$ADBFILE" | cut -f 2 -d '-'`" #ex: puppy
  190. # DB_compiledrelease="`echo -n "$ADBFILE" | cut -f 3 -d '-'`" #ex: 4
  191. # DB_repo="`echo -n "$ADBFILE" | cut -f 4 -d '-'`" #ex: official
  192. # #db fields: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  193. # cat $ADBFILE |
  194. # while read ONELINE
  195. # do
  196. # echo -n "."
  197. # DELNUM=`echo -n "$ONELINE" | sed -e 's%[^|]%%g' | wc -c` #number of | delimiters.
  198. # case $DELNUM in
  199. # 10) echo "${ONELINE}${DB_compileddistro}|${DB_compiledrelease}||" >> /tmp/findpkgs_tmp/dbfilefixed ;;
  200. # 9) echo "|${ONELINE}${DB_compileddistro}|${DB_compiledrelease}||" >> /tmp/findpkgs_tmp/dbfilefixed ;; #broken, missing | on end of description.
  201. # *)
  202. # #echo "$ONELINE" >> /tmp/findpkgs_tmp/dbfilefixed
  203. # #111127 mark entire file as ok, get out (see note above)...
  204. # NEWDATE=`stat --format=%Y $ADBFILE` #seconds since last epoch.
  205. # echo -n "$NEWDATE" > ${STATUSDIR}/MODIFY_DATE_${ADBFILE}
  206. # continue 2
  207. # ;;
  208. # esac
  209. # done
  210. # sync
  211. # echo
  212. # mv -f $ADBFILE /tmp/findpkgs_tmp/${ADBFILE}-PREVIOUS
  213. # #mv -f /tmp/findpkgs_tmp/dbfilefixed $ADBFILE
  214. # #Packages-puppy-slacko-official has some duplicate entries, cleanup...
  215. # sort -u --key=1,1 --field-separator="|" /tmp/findpkgs_tmp/dbfilefixed > ${ADBFILE}
  216. # NEWDATE=`stat --format=%Y $ADBFILE` #seconds since last epoch.
  217. # echo -n "$NEWDATE" > ${STATUSDIR}/MODIFY_DATE_${ADBFILE}
  218. # fi
  219. #done
  220. #111128 redo the above, much faster...
  221. #problem with ||| above high priority, compileddistro|compiledrelease| are optional fields and may be missing.
  222. #printcols <file> 2 3 8 9 11 12 (see below) does insert 11 & 12 delimiters if missing, but that would bump the
  223. #priority of that pkg -- results in pkgs in Packages-puppy-4-official getting chosen.
  224. for ADBFILE in $PACKAGELISTS_PET_ORDER $PKGLISTS_COMPAT
  225. do
  226. NEWSUM="`md5sum $ADBFILE | cut -f 1 -d ' '`"
  227. OLDSUM="0"
  228. [ -f ${STATUSDIR}/MODIFY_DATE_${ADBFILE} ] && OLDSUM="`cat ${STATUSDIR}/MODIFY_DATE_${ADBFILE}`"
  229. if [ "$NEWSUM" != "$OLDSUM" ];then
  230. DB_compileddistro="`echo -n "$ADBFILE" | cut -f 2 -d '-'`" #ex: puppy
  231. DB_compiledrelease="`echo -n "$ADBFILE" | cut -f 3 -d '-'`" #ex: 4
  232. DB_repo="`echo -n "$ADBFILE" | cut -f 4 -d '-'`" #ex: official
  233. #db fields: pkgname|nameonly|version|pkgrelease|category[;subcategory]|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  234. echo "Fixing compileddistro|compiledrelease| fields in $ADBFILE"
  235. FIELD11PTN="s%VERTBARCHAR$%VERTBARCHAR${DB_compileddistro}VERTBARCHAR%"
  236. FIELD12PTN="s%VERTBARCHAR$%VERTBARCHAR${DB_compiledrelease}VERTBARCHAR%"
  237. sed -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e 's%|%VERTBARCHAR%' -e "${FIELD11PTN}" -e "${FIELD12PTN}" -e 's%VERTBARCHAR$%VERTBARCHARVERTBARCHAR%' -e 's%\(VERTBARCHAR[^|]*|[^|]*|$\)%\1|%' -e 's%VERTBARCHAR%|%g' ${ADBFILE} > /tmp/findpkgs_tmp/dbfilefixed
  238. REALNEWSUM="`md5sum /tmp/findpkgs_tmp/dbfilefixed | cut -f 1 -d ' '`"
  239. if [ "$REALNEWSUM" != "$NEWSUM" ];then
  240. cp -f /tmp/findpkgs_tmp/dbfilefixed $ADBFILE
  241. NEWSUM="$REALNEWSUM"
  242. fi
  243. echo -n "$NEWSUM" > ${STATUSDIR}/MODIFY_DATE_${ADBFILE}
  244. fi
  245. done
  246. ##################
  247. ###FIRST SEARCH###
  248. ##################
  249. echo
  250. echo "First pass at finding packages to be used in the Puppy build..."
  251. search_func() {
  252. SEARCHNUM="$1"
  253. for ONEPKGSPEC in $PKGS_SPECS_TABLE
  254. do
  255. [ "$ONEPKGSPEC" = "" ] && continue
  256. YESNO="`echo "$ONEPKGSPEC" | cut -f 1 -d '|'`"
  257. [ "$YESNO" = "no" ] && continue
  258. GENERICNAME="`echo "$ONEPKGSPEC" | cut -f 2 -d '|'`"
  259. BINARYPARTNAMES="`echo "$ONEPKGSPEC" | cut -f 3 -d '|' | tr ',' ' '`"
  260. if [ "$BINARYPARTNAMES" = "" ];then
  261. xBINARYPARTNAMES="$GENERICNAME"
  262. else
  263. #cut out any to be excluded ( '-' prefix)...
  264. BINARYEXCLUDED0="`echo "$BINARYPARTNAMES" | tr ' ' '\n' | grep '^-' | sed -e 's/^-//'`"
  265. xBINARYPARTNAMES="`echo "$BINARYPARTNAMES" | tr ' ' '\n' | grep -v '^-' | tr '\n' ' '`"
  266. fi
  267. echo -n "" > /tmp/findpkgs_tmp/excludePTNS
  268. if [ "$BINARYEXCLUDED0" ];then
  269. excludePTNS="`echo -n "$BINARYEXCLUDED0" | sed -e 's%\\-%\\\\-%g' -e 's%\\*%.*%g' -e 's%^%|%'`" #i think that dashes need to be backslashed, change blob * wildcard to reg.expr.
  270. echo "$excludePTNS" > /tmp/findpkgs_tmp/excludePTNS
  271. fi
  272. PKGLOC2=''; PKGLOC1='pet' #original behaviour
  273. [ "$BINARYPARTNAMES" != "" ] && PKGLOC1='compat' #original behaviour
  274. PKGLOCFLD="`echo "$ONEPKGSPEC" | cut -f 5 -d '|'`"
  275. if [ "$PKGLOCFLD" ];then
  276. PKGLOC1="`echo -n "$PKGLOCFLD" | cut -f 1 -d ':'`"
  277. [ "`echo -n "$PKGLOCFLD" | grep ':'`" != "" ] && PKGLOC2="`echo -n "$PKGLOCFLD" | cut -f 2 -d ':'`"
  278. fi
  279. if [ "$PKGLOC1" = "pet" ];then
  280. PACKAGELISTS_ORDER="$PACKAGELISTS_PET_ORDER"
  281. xPACKAGELISTS_ORDER="$PACKAGELISTS_PET_ORDER"
  282. compiledPTNS="$petcompiledPTNS"
  283. else
  284. PACKAGELISTS_ORDER="$PKGLISTS_COMPAT"
  285. xPACKAGELISTS_ORDER="$PKGLISTS_COMPAT"
  286. compiledPTNS='.' #allow everything through.
  287. fi
  288. if [ "$PKGLOC2" ];then #exs: core, nonfree, contrib, official (4th field in Packages-puppy-wary5-official)
  289. locPTN="\-${PKGLOC2}$"
  290. xPACKAGELISTS_ORDER="`echo -n "$PACKAGELISTS_ORDER" | tr -s ' ' | tr ' ' '\n' | grep "$locPTN" | tr '\n' ' '`"
  291. if [ ! "$xPACKAGELISTS_ORDER" ];then
  292. locPTN="\-${PKGLOC2}\-" #allow choose 3rd field also -wary5-
  293. xPACKAGELISTS_ORDER="`echo -n "$PACKAGELISTS_ORDER" | tr -s ' ' | tr ' ' '\n' | grep "$locPTN" | tr '\n' ' '`"
  294. fi
  295. fi
  296. echo -n "$GENERICNAME "
  297. for APARTNAME in $xBINARYPARTNAMES
  298. do
  299. #APARTNAME could have glob wildcard(s)...
  300. if [ "`echo -n "$APARTNAME" | grep '\\*$'`" != "" ];then #if has '*' on end, then look in full pkg name.
  301. namePTN="|`echo -n "$APARTNAME" | sed -e 's%\\-%\\\\-%g' -e 's%\\*%.*%g'`|" #i think that dashes need to be backslashed, change blob * wildcard to reg.expr.
  302. else
  303. namePTN="^`echo -n "$APARTNAME" | sed -e 's%\\-%\\\\-%g' -e 's%\\*%.*%g'`|" #i think that dashes need to be backslashed, change blob * wildcard to reg.expr.
  304. fi
  305. #in wary, i have many pkgs that are _DEV only, need to find these, a hack fix to find most...
  306. devnamePTN="`echo -n "$namePTN" | sed -e 's%|$%_DEV|%'`"
  307. echo -n "" > /tmp/findpkgs_tmp/FNDSPECS
  308. for acompiledPTN in $compiledPTNS
  309. do
  310. for PKGLIST in $xPACKAGELISTS_ORDER #ex: Packages-puppy-drake-official Packages-puppy-common-official Packages-puppy-4-official
  311. do
  312. #2 3 8 9 11 12 is: nameonly version fullpkgname dependencies compileddistro compiledrelease
  313. FNDSPECS="`printcols ./${PKGLIST} 2 3 8 9 11 12 | grep "$namePTN" | grep "$acompiledPTN" | grep -v -f /tmp/findpkgs_tmp/excludePTNS`" #note, no 'head -n 1'
  314. #in wary, i have many pkgs that are _DEV only, need to find these, a hack fix to find most...
  315. [ ! "$FNDSPECS" ] && FNDSPECS="`printcols ./${PKGLIST} 2 3 8 9 11 12 | grep "$devnamePTN" | grep "$acompiledPTN" | grep -v -f /tmp/findpkgs_tmp/excludePTNS`" #note, no 'head -n 1'
  316. if [ "$FNDSPECS" ];then
  317. for ONESPEC in $FNDSPECS #maybe more than one find.
  318. do
  319. echo "${ONESPEC}${PKGLIST}" >> /tmp/findpkgs_tmp/FNDSPECS #ex: abiword|2.3.4|abiword-2.3.4.pet|+gtk+|puppy|wary5|Packages-puppy-wary5-official
  320. done
  321. fi
  322. [ -s /tmp/findpkgs_tmp/FNDSPECS ] && break 2 #pkg(s) found.
  323. done
  324. done
  325. if [ ! -s /tmp/findpkgs_tmp/FNDSPECS ];then
  326. echo "WARNING: $APARTNAME pkg was not found!"
  327. continue
  328. fi
  329. for ONESPEC in `cat /tmp/findpkgs_tmp/FNDSPECS | tr '\n' ' '` #maybe more than one pkg found.
  330. do
  331. if [ "$SEARCHNUM" = "2" ];then #second search.
  332. #if there is a preferred pkg (after versioned-dep checking in this script) use that instead...
  333. if [ -s /tmp/findpkgs_tmp/PREFERRED_PKGS ];then
  334. if [ "$PKGLOCFLD" = "" ];then #130313 see also below. need to respect repo-override, even if a preferred version logged.
  335. fndnamePTN="^`echo -n "$ONESPEC" | cut -f 1 -d '|'`|" #ex: ^abiword|
  336. PREFSPEC="`grep "$fndnamePTN" /tmp/findpkgs_tmp/PREFERRED_PKGS`"
  337. [ "$PREFSPEC" ] && ONESPEC="$PREFSPEC"
  338. fi
  339. fi
  340. fndnamePTN="|`echo -n "$ONESPEC" | cut -f 1 -d '|'`|" #ex: |abiword|
  341. versionPTN="|`echo -n "$ONESPEC" | cut -f 2 -d '|'`|" #ex: |2.3.4|
  342. fullnamePTN="|`echo -n "$ONESPEC" | cut -f 3 -d '|'`|" #ex: |abiword-2.3.4.pet|
  343. REPODBFILE="`echo -n "$ONESPEC" | grep -o '|Packages-[^|]*' | cut -f 2 -d '|'`"
  344. #FULLDBENTRY="`grep "$fullnamePTN" $REPODBFILE`"
  345. #log the complete db entry, prefixed with generic-name, pet/compat and repo db filename...
  346. devnamePTN="|`echo -n "$ONESPEC" | cut -f 1 -d '|'`_DEV|" #ex: |abiword_DEV|
  347. docnamePTN="|`echo -n "$ONESPEC" | cut -f 1 -d '|'`_DOC|" #ex: |abiword_DOC|
  348. nlsnamePTN="|`echo -n "$ONESPEC" | cut -f 1 -d '|'`_NLS|" #ex: |abiword_NLS|
  349. for onePTN in $fndnamePTN $devnamePTN $docnamePTN $nlsnamePTN
  350. do
  351. FULLDBENTRY="`grep "$onePTN" $REPODBFILE | grep "$versionPTN"`"
  352. if [ "$FULLDBENTRY" ];then
  353. #130313 i think this is where having problem. a repo-override $PKGLOCFLD needs to be respected (ex: pet:wary5)...
  354. if [ "$PKGLOCFLD" ];then
  355. EXISTENTRY="`grep "$onePTN" /tmp/findpkgs_tmp/FINAL_PKGS | grep "$REPODBFILE"`"
  356. else
  357. EXISTENTRY="`grep "$onePTN" /tmp/findpkgs_tmp/FINAL_PKGS`" #previous code.
  358. fi
  359. if [ "$EXISTENTRY" = "" ];then
  360. echo ":${GENERICNAME}:|${PKGLOC1}|${REPODBFILE}|${FULLDBENTRY}" >> /tmp/findpkgs_tmp/FINAL_PKGS #ex: :a52dec:|compat|Packages-puppy-wary5-official|a52dec-0.7.4-w5|a52dec|0.7.4-w5||BuildingBlock|68K||a52dec-0.7.4-w5.pet||A free ATSC A52 stream decoder|puppy|wary5||
  361. else
  362. grep -v "$onePTN" /tmp/findpkgs_tmp/FINAL_PKGS > /tmp/findpkgs_tmp/FINAL_PKGS2
  363. mv -f /tmp/findpkgs_tmp/FINAL_PKGS2 /tmp/findpkgs_tmp/FINAL_PKGS
  364. #130316 in arch build getting duplicate generic names, ex:
  365. # :cups::cups:|pet|Packages-puppy-wary5-official|cups_DEV-1.4.8-w5c|cups_DEV|1.4.8-w5c||BuildingBlock|216K||cups_DEV-1.4.8-w5c.pet|+cups|common unix printing system|puppy|wary5||
  366. gnPTN1=':'"${GENERICNAME}"'[:|]'
  367. if [ "$(echo -n "${EXISTENTRY}" | grep "${gnPTN1}")" = "" ];then
  368. echo ":${GENERICNAME}:${EXISTENTRY}" >> /tmp/findpkgs_tmp/FINAL_PKGS #ex: :audio::a52dec:|compat|Packages-puppy-wary5-official|a52dec-0.7.4-w5|a52dec|0.7.4-w5||BuildingBlock|68K||a52dec-0.7.4-w5.pet||A free ATSC A52 stream decoder|puppy|wary5||
  369. else #130320 fix disappearing pkg.
  370. echo "${EXISTENTRY}" >> /tmp/findpkgs_tmp/FINAL_PKGS #ex: :audio::a52dec:|compat|Packages-puppy-wary5-official|a52dec-0.7.4-w5|a52dec|0.7.4-w5||BuildingBlock|68K||a52dec-0.7.4-w5.pet||A free ATSC A52 stream decoder|puppy|wary5||
  371. fi
  372. fi
  373. fi
  374. done
  375. else #1st search
  376. VERDEPS="`echo -n "$ONESPEC" | cut -f 4 -d '|' | tr ',' '\n' | sed -e 's%^+%%'`" #field-4 is dependencies.
  377. if [ "$VERDEPS" = "" ];then
  378. echo "`echo -n "${ONESPEC}" | cut -f 1,2,3,5,6,7 -d '|'`|" >> /tmp/findpkgs_tmp/${PKGLOC1}_log1 #ex: abiword|2.3.4|abiword-2.3.4-w5.pet|puppy|wary5|Packages-puppy-wary5-official|
  379. else
  380. for ONEVERDEP in `echo -n "${VERDEPS}" | tr '\n' ' '` #create one line for each dep.
  381. do
  382. echo "`echo -n "${ONESPEC}" | cut -f 1,2,3,5,6,7 -d '|'`|${ONEVERDEP}" >> /tmp/findpkgs_tmp/${PKGLOC1}_log1 #ex: abiword|2.3.4|abiword-2.3.4-w5.pet|puppy|wary5|Packages-puppy-wary5-official|aiksaurus&gt5.6.7
  383. done
  384. fi
  385. fi
  386. done
  387. done
  388. done
  389. } #end search_func
  390. search_func 1 #first search.
  391. sync
  392. #####################
  393. ###POST PROCESSING###
  394. #####################
  395. #append dummy linux_kernel line...
  396. echo "linux_kernel|${KERNELVER3}|linux_kernel-${KERNELVER3}.pet|||" >> /tmp/findpkgs_tmp/pet_log1
  397. #don't forget, need read aliases for deps, variable PKG_NAME_ALIASES in file PKGS_MANAGEMENT...
  398. #want to handle multiple conditions ex: aiksaurus&gt5.6.7&lt5.7.8
  399. echo
  400. echo
  401. echo "Processing dependencies..."
  402. echo -n "" > /tmp/findpkgs_tmp/fnd_ok_deps
  403. echo -n "" > /tmp/findpkgs_tmp/fnd_ok_apps
  404. for ONESPEC in `cat /tmp/findpkgs_tmp/compat_log1 /tmp/findpkgs_tmp/pet_log1 | grep '&' | tr '\n' ' '`
  405. do
  406. #ex: ONESPEC=abiword|2.3.4|abiword-2.3.4-w5.pet|puppy|wary5|Packages-puppy-wary5-official|aiksaurus&gt5.6.7
  407. appPTN="^`echo -n "$ONESPEC" | cut -f 1 -d '|'`|" #pattern of the application name ex: ^abiword|
  408. appVER="`echo -n "$ONESPEC" | cut -f 2 -d '|'`" #ex: 2.3.4
  409. DEPFLD="`echo -n "$ONESPEC" | cut -f 7 -d '|'`"
  410. DEPNAME="`echo -n "$DEPFLD" | cut -f 1 -d '&'`"
  411. DEPCONDS="`echo -n "$DEPFLD" | cut -f 2-9 -d '&' | tr '&' ' '`"
  412. depnamePTN="|${DEPNAME}|"
  413. echo -n "$DEPNAME "
  414. #handle aliases...
  415. aliasesPTNS="`echo "$PKG_NAME_ALIASES" | tr ' ' '\n' | grep -v '^$' | sed -e 's%^%|%' -e 's%$%|%' -e 's%,%|,|%g' -e 's%\\*%.*%g'`"
  416. #ex: PKG_NAME_ALIASES has an entry cxxlibs,glibc*,libc-* the above creates |cxxlibs|,|glibc.*|,|libc\-.*|
  417. echo "$aliasesPTNS" > /tmp/findpkgs_tmp/aliasesPTNS
  418. singlePTNS="`echo "$aliasesPTNS" | tr ',' '\n'`"
  419. echo "$singlePTNS" > /tmp/findpkgs_tmp/singlePTNS
  420. FNDALIAS="`echo -n "$depnamePTN" | grep -f /tmp/findpkgs_tmp/singlePTNS | sed -e 's%\\.\\*%*%g' -e 's%\\\\-%-%g'`" #translate .* \- back to * -
  421. if [ "$FNDALIAS" ];then
  422. aliasPTNS="`echo -n "$FNDALIAS" | grep -f /tmp/findpkgs_tmp/aliasesPTNS | tr ',' ' '`" #ex: |cxxlibs| |glibc.*| |libc\-.*|
  423. else
  424. aliasPTNS="^${DEPNAME}|"
  425. fi
  426. for namePTN in $aliasPTNS
  427. do
  428. for FNDPKG in `cat /tmp/findpkgs_tmp/compat_log1 /tmp/findpkgs_tmp/pet_log1 | grep "$namePTN" | tr '\n' ' '`
  429. do
  430. #found a dependency, now check its version is ok...
  431. FNDVER="`echo -n "$FNDPKG" | cut -f 2 -d '|'`"
  432. condFLG='good'
  433. for ACOND in $DEPCONDS #ex: gt5.6.7 lt6.7.8
  434. do
  435. DEPOP="`echo -n "$ACOND" | cut -c 1,2`"
  436. DEPVER="`echo -n "$ACOND" | cut -c 3-99`"
  437. if ! vercmp ${FNDVER} ${DEPOP} ${DEPVER};then
  438. condFLG='bad'
  439. fi
  440. done
  441. [ "$condFLG" = "bad" ] && continue
  442. #version is ok.
  443. #log dep info, make sure only latest version is logged...
  444. depVERprev="`grep "$namePTN" /tmp/findpkgs_tmp/fnd_ok_deps | cut -f 2 -d '|'`"
  445. if [ "$depVERprev" = "" ];then
  446. echo "$FNDPKG" >> /tmp/findpkgs_tmp/fnd_ok_deps
  447. else
  448. if vercmp ${FNDVER} gt ${depVERprev};then
  449. grep -v "$namePTN" /tmp/findpkgs_tmp/fnd_ok_deps > /tmp/findpkgs_tmp/fnd_ok_deps2
  450. mv -f /tmp/findpkgs_tmp/fnd_ok_deps2 /tmp/findpkgs_tmp/fnd_ok_deps
  451. echo "$FNDPKG" >> /tmp/findpkgs_tmp/fnd_ok_deps
  452. fi
  453. fi
  454. #log actual pkg info as well as deps, make sure latest version logged...
  455. appVERprev="`grep "$appPTN" /tmp/findpkgs_tmp/fnd_ok_apps | cut -f 2 -d '|'`"
  456. if [ "$appVERprev" = "" ];then
  457. echo "$ONESPEC" >> /tmp/findpkgs_tmp/fnd_ok_apps
  458. else
  459. if vercmp ${appVER} gt ${appVERprev};then
  460. grep -v "$appPTN" /tmp/findpkgs_tmp/fnd_ok_apps > /tmp/findpkgs_tmp/fnd_ok_apps2
  461. mv -f /tmp/findpkgs_tmp/fnd_ok_apps2 /tmp/findpkgs_tmp/fnd_ok_apps
  462. echo "$ONESPEC" >> /tmp/findpkgs_tmp/fnd_ok_apps
  463. fi
  464. fi
  465. done
  466. done
  467. done
  468. echo -n "" > /tmp/findpkgs_tmp/PREFERRED_PKGS
  469. cat /tmp/findpkgs_tmp/fnd_ok_deps >> /tmp/findpkgs_tmp/PREFERRED_PKGS
  470. cat /tmp/findpkgs_tmp/fnd_ok_apps >> /tmp/findpkgs_tmp/PREFERRED_PKGS
  471. sort --key=3,3 --field-separator="|" -u /tmp/findpkgs_tmp/PREFERRED_PKGS > /tmp/findpkgs_tmp/PREFERRED_PKGS2
  472. grep -v '^linux_kernel|' /tmp/findpkgs_tmp/PREFERRED_PKGS2 > /tmp/findpkgs_tmp/PREFERRED_PKGS #remove dummy entry.
  473. cp -f /tmp/findpkgs_tmp/PREFERRED_PKGS ${STATUSDIR}/findpkgs_PREFERRED_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} #so retained between boots.
  474. sync
  475. ###################
  476. ###SECOND SEARCH###
  477. ###################
  478. #now find all pkgs again, this time use prefs recorded in /tmp/findpkgs_tmp/PREFERRED_PKGS
  479. echo
  480. echo
  481. echo "Second pass at finding packages to be used in the Puppy build..."
  482. search_func 2 #result will be in /tmp/findpkgs_tmp/FINAL_PKGS
  483. #...each line is full db entry for package, prefixed with :generic-name:, pet/compat and repo-db-file
  484. # ex: :a52dec:|compat|Packages-puppy-wary5-official|a52dec-0.7.4-w5|a52dec|0.7.4-w5||BuildingBlock|68K||a52dec-0.7.4-w5.pet||A free ATSC A52 stream decoder|puppy|wary5||
  485. # 'compat' means pkg obtained from compatible-distro, in case of Wary they are also PETs.
  486. # :generic-name: usually coincides with actual name in package. multiple pkgs may be combined into one generic-name.
  487. # if the same pkg is combined into two different generic-names, then the line will look like this: :gcc_lib::gcc_dev:| (ex from Slacko).
  488. #110908 not-found pkgs are left in here without the genericname etc fields preprended...
  489. grep '^:' /tmp/findpkgs_tmp/FINAL_PKGS > /tmp/findpkgs_tmp/FINAL_PKGSx
  490. mv -f /tmp/findpkgs_tmp/FINAL_PKGSx /tmp/findpkgs_tmp/FINAL_PKGS
  491. sync
  492. sort --key=4,4 --field-separator="|" /tmp/findpkgs_tmp/FINAL_PKGS > ${STATUSDIR}/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} #so retained between boots.
  493. sync
  494. echo
  495. echo
  496. echo "Script finished. Result is in file"
  497. echo " status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  498. Each line is full db entry for pkg, prefixed with :generic-name:, pet/compat
  499. and db-file. ex:
  500. :a52dec:|compat|Packages-puppy-wary5-official|a52dec-0.7.4-w5|a52dec|0.7.4-w5||BuildingBlock|68K||a52dec-0.7.4-w5.pet||A free ATSC A52 stream decoder|puppy|wary5||
  501. 'compat' means pkg from compat-distro, in case of Wary they are also PETs
  502. :generic-name: is 2nd field in PKGS_SPECS_TABLE, note in some cases multiple
  503. packages are combined into same genericname, or same pkg can be shared by
  504. multiple genericnames -- latter case, line will look like: :gcc_lib::gcc_dev:|"
  505. ###END###