findpkgs 29 KB

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