findpkgs 29 KB

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