0setup 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. #!/bin/ash
  2. #(c) Copyright 2009 Barry Kauler.
  3. #100617 support slackware .txz pkgs.
  4. #100626 '-' chars were getting removed from dependencies.
  5. #110523 Iguleder: support Scientific Linux rpm pkgs.
  6. #110612 support Mageia Linux.
  7. #111121 noryb009: improve arch linux support, patched: 0setup, 1download, 2createpackages, 3builddistro, DISTRO_COMPAT_REPOS-arch, support/arch/runDotInstalls
  8. #111129 prevent 'mv' fail error message.
  9. #111203 noryb009: arch linux -2 patch.
  10. #120126 mavrothal: offer option to skip specific repos. refer http://bkhome.org/blog/?viewDetailed=02650
  11. #120315 pkg list entries may have optional forced repo field. Ref: http://bkhome.org/blog/?viewDetailed=02414
  12. #120515 build from "gentoo" binary tarballs (refer support/gentoo). --no need to modify anything in 0setup.
  13. #120719 support raspbian. fix debian db format change.
  14. #120804 fix when only have pkgname_DEV, no pkgname.
  15. #120812 db category now allows optional subcategory (for which an icons exists in /usr/local/lib/X11/mini-icons).
  16. #120815 for debian, ubuntu, use the generic name provided in the $DB_path, instead of $Package, for find_cat.
  17. #120825 debian/ubuntu/raspbian: merge -updates dbs.
  18. #120909 moved exit-point when running in puppy.
  19. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  20. #121111 debdb2pupdb, new fast deb to pup db converter.
  21. #121112 note, debdb2pupdb no longer calls find_cat.
  22. #121113 improve file PKGS_HOMEPAGES sort after run debdb2pupdb.
  23. #121113 read Ubuntu-db 'Section' parameter to help assign category.
  24. #121113 ubuntu-db: introduce STARTMARKER field between db records.
  25. #121113 reverse question, enter only for ubuntu db -updates.
  26. #121116 0setup also runs in running puppy called from ppm. some o/p needs to be translated, done in /usr/share/sss/script_strings/script_strings. see below all LANGORG insertions.
  27. #121130 bug found, when not building a upup.
  28. #130126 find_cat rewritten. works as before, also can post-process an entire db-entry or db-entries-file. arch code rewritten by noryb009
  29. #130305 debdb2pupdb.bac now also check that deps exist, create list of pkgs.
  30. #130306 fix arch linux build.
  31. #130316 debdb2pupdb does not use /tmp/0setupcompletelistpkgs in a running puppy.
  32. #130319 remove 'raspbian' from updates code section.
  33. LANGORG="$(locale | grep '^LANG=' | cut -d '=' -f 2)" #121116
  34. export LANG=C #faster.
  35. if [ -f ./DISTRO_SPECS ];then
  36. . ./DISTRO_SPECS
  37. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  38. if [ -f ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #v431
  39. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  40. else
  41. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT} #130306
  42. fi
  43. if [ -f ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #w478
  44. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  45. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  46. else
  47. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}
  48. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}"
  49. fi
  50. . ./PKGS_MANAGEMENT
  51. . ./DISTRO_PET_REPOS
  52. RUNNINGPUP='no'
  53. else
  54. #want to run this script in running puppy, to update db's...
  55. . /etc/DISTRO_SPECS
  56. . /root/.packages/DISTRO_COMPAT_REPOS #v431
  57. . /root/.packages/DISTRO_PKGS_SPECS
  58. . /root/.packages/PKGS_MANAGEMENT
  59. . /root/.packages/DISTRO_PET_REPOS
  60. cd /root/.packages
  61. RUNNINGPUP='yes'
  62. fi
  63. #remove comments from PKGS_SPECS_TABLE
  64. PKGS_SPECS_TABLE="`echo "$PKGS_SPECS_TABLE" | grep -v '^#'`"
  65. #w480 check puppy pkg db files...
  66. if [ "$RUNNINGPUP" = "no" ];then
  67. ./support/fix-puppy-dbs
  68. [ $? -eq 1 ] && exit
  69. fi
  70. [ -f ./support/debdb2pupdb ] && cp -f ./support/debdb2pupdb /usr/local/petget/ #121111 0setup needs it here, when run from PPM.
  71. #note, 3builddistro copies it into rootfs-complete/usr/local/petget when building a pup.
  72. #121112 note, debdb2pupdb no longer calls find_cat.
  73. #w015 to speed things up, this func replaced by compiled app support/find_cat ...
  74. [ -f ./support/find_cat ] && cp -f ./support/find_cat /usr/local/petget/ #130126
  75. FIND_CAT="/usr/local/petget/find_cat"
  76. #130126 make sure have latest in host system...
  77. [ -f rootfs-skeleton/usr/local/petget/categories.dat ] && cp -f rootfs-skeleton/usr/local/petget/categories.dat /usr/local/petget/
  78. if [ -f ./support/rpm2ppm ];then #110612
  79. RPM2PPM='./support/rpm2ppm'
  80. else
  81. RPM2PPM='/usr/local/petget/rpm2ppm' #see 3builddistro.
  82. fi
  83. if [ -f ./support/mageia2ppm ];then #110612
  84. MAGEIA2PPM='./support/mageia2ppm'
  85. else
  86. MAGEIA2PPM='/usr/local/petget/mageia2ppm' #see 3builddistro
  87. fi
  88. #w091018 now logging errors for future recall...
  89. mkdir -p /var/woof
  90. RUNDATE="`date`"
  91. echo -n "" > /var/woof/0setup_fail_report_$RUNNINGPUP #RUNNINGPUP=yes or no. latter if woof.
  92. LANG=${LANGORG} echo "This is a report on the last time the '0setup' script was run.
  93. Date and time '0setup' last run: ${RUNDATE}
  94. Compatible-distro and release-name: ${DISTRO_BINARY_COMPAT}, ${DISTRO_COMPAT_VERSION}
  95. Mostly only errors get logged, so the less seen below, the better.
  96. Log of last run of '0setup':
  97. " >> /var/woof/0setup_fail_report_$RUNNINGPUP
  98. #download docs on compatible-distro pkgs...
  99. for PKGLISTSPEC in $PKG_DOCS_DISTRO_COMPAT #see file DISTRO_PKGS_SPECS-ubuntu
  100. do
  101. PKGLISTFILE="`echo -n "$PKGLISTSPEC" | cut -f 3 -d '|'`"
  102. PKGLISTURI="`echo -n "$PKGLISTSPEC" | cut -f 2 -d '|'`"
  103. [ "$PKGLISTURI" = "" ] && continue #w478 no url, pkg db file only kept in woof.
  104. skipdl=""
  105. if [ "$RUNNINGPUP" = "no" -a -f $PKGLISTFILE ];then
  106. echo
  107. echo "Local db file '${PKGLISTFILE}' already exists."
  108. echo "Press ENTER key only to upgrade it,"
  109. echo -n "or any other printable char to skip: "
  110. read skipdl
  111. fi
  112. if [ "$skipdl" = "" ];then
  113. echo
  114. LANG=${LANGORG} echo "A package information database file needs to be downloaded."
  115. LANG=${LANGORG} echo "This will be downloaded from:"
  116. echo "$PKGLISTURI"
  117. LANG=${LANGORG} echo "and will be processed and named: ${PKGLISTFILE}"
  118. LANG=${LANGORG} echo -n "Press ENTER key to download, any other to skip it: " #120126
  119. read downloadit
  120. if [ "$downloadit" = "" ] ; then #120126
  121. DLFILE="`basename $PKGLISTURI`"
  122. [ -f $DLFILE ] && mv -f $DLFILE /tmp/${DLFILE}-backup1 #v431 otherwise wget creates a new file ${DLFILE}.1
  123. rxvt -name pet -bg orange -geometry 80x10 -e wget $PKGLISTURI
  124. sync
  125. xDLFILE="$DLFILE"
  126. if [ -f $DLFILE ];then
  127. case ${DISTRO_BINARY_COMPAT} in
  128. ubuntu|debian|raspbian)
  129. xDLFILE="`basename $DLFILE .bz2`"
  130. bunzip2 $DLFILE
  131. RETSTAT=$?
  132. [ $RETSTAT -eq 0 ] && mv -f $xDLFILE ${PKGLISTFILE}pre
  133. ;;
  134. slackware)
  135. RETSTAT=0
  136. mv -f $xDLFILE ${PKGLISTFILE}pre
  137. ;;
  138. arch)
  139. #130126 arch code rewritten by noryb009: call find_cat afterward...
  140. #130306 BK: sub() funtion to fix version relation operators...
  141. #130306 BK: filtered out bad chars from description (note tortuous way to escape ' char)...
  142. LANG=${LANGORG} echo "Processing ${DLFILE} please wait..."
  143. xDLFILE="`basename $DLFILE .gz`" #actually it's a tarball: core.db.tar.gz, extra.db.tar.gz, community.db.tar.gz
  144. rm -rf sandbox0 2>/dev/null
  145. mkdir sandbox0
  146. cd sandbox0
  147. tar xzf "../$DLFILE"
  148. RETSTAT=$?
  149. cd ..
  150. if [ $RETSTAT -eq 0 ];then
  151. rm -f "$DLFILE"
  152. xxDLFILE="`basename $DLFILE .db.tar.gz`" #this will be core, extra, community 130306
  153. for i in sandbox0/*; do
  154. cat "$i/desc" "$i/depends"
  155. done | awk -v pkgpath="$xxDLFILE" '
  156. function output() {
  157. if(filename == "") return;
  158. printf("%s-%s|%s|%s|%s||%sK|%s/os/i686|%s|%s|%s|\n", pkgname, pkgverarr[1], pkgname, pkgverarr[1], pkgverarr[2], pkgsize, pkgpath, filename, pkgdeps, pkgdesc)
  159. pkgname=""; pkgverarr[1]=""; pkgverarr[2]=""; pkgsize=""; filename=""; pkgdeps=""; inDeps=0; pkgdesc="";
  160. }
  161. BEGIN{
  162. inDeps=0
  163. }
  164. {
  165. if($1 == ""){
  166. #do nothing
  167. }else if($1 == "%FILENAME%"){
  168. inDeps=0
  169. output()
  170. getline filename
  171. }else if($1 == "%NAME%"){
  172. inDeps=0
  173. getline pkgname
  174. }else if($1 == "%VERSION%"){
  175. inDeps=0
  176. getline pkgver; split(pkgver, pkgverarr, "-")
  177. }else if($1 == "%DESC%"){
  178. inDeps=0
  179. getline pkgdesc
  180. gsub(/</, " ", pkgdesc)
  181. gsub(/>/, " ", pkgdesc)
  182. gsub(/\|/, " ", pkgdesc)
  183. gsub(/'\''/, " ", pkgdesc)
  184. gsub(/\"/, " ", pkgdesc)
  185. gsub(/\(/, " ", pkgdesc)
  186. gsub(/\)/, " ", pkgdesc)
  187. }else if($1 == "%ISIZE%"){
  188. inDeps=0
  189. getline pkgsize; pkgsize = pkgsize / 1024
  190. }else if($1 == "%DEPENDS%"){
  191. inDeps=1
  192. }else if($1 ~ /^%/){
  193. inDeps=0
  194. }else if(inDeps == 1){ # dependency
  195. if(pkgdeps != "") pkgdeps=pkgdeps","
  196. pkgdeps=pkgdeps"+"
  197. sub(/>=/, "\\&ge", $0)
  198. sub(/<=/, "\\&le", $0)
  199. sub(/>/, "\\&gt", $0)
  200. sub(/</, "\\&lt", $0)
  201. sub(/=/, "\\&eq", $0)
  202. pkgdeps=pkgdeps$0
  203. }
  204. }
  205. END{
  206. output();
  207. }
  208. ' > /tmp/${PKGLISTFILE}temp #130306
  209. ${FIND_CAT} /tmp/${PKGLISTFILE}temp > $PKGLISTFILE #130126 130306
  210. fi
  211. rm -rf sandbox0 2>/dev/null
  212. ;;
  213. t2) #w017
  214. RETSTAT=0
  215. ;;
  216. puppy)
  217. RETSTAT=0
  218. ;;
  219. scientific) #110523 Iguleder
  220. xDLFILE="`basename $DLFILE .gz`"
  221. gunzip $DLFILE
  222. RETSTAT=$?
  223. [ $RETSTAT -eq 0 ] && mv -f $xDLFILE ${PKGLISTFILE}pre
  224. ;;
  225. mageia) #110612
  226. xDLFILE="`basename $DLFILE .cz`" #DLFILE=synthesis.hdlist.cz
  227. mv -f $DLFILE ${xDLFILE}.gz #.cz is actually a gzipped file.
  228. gunzip ${xDLFILE}.gz
  229. RETSTAT=$?
  230. [ $RETSTAT -eq 0 ] && mv -f $xDLFILE ${PKGLISTFILE}pre #ex: Packages-mageia-1-corepre
  231. ;;
  232. esac
  233. if [ $RETSTAT -eq 0 ];then
  234. LANG=${LANGORG} echo "...success."
  235. else
  236. LANG=${LANGORG} echo "Downloaded file is corrupted. Deleting file and aborting."
  237. rm -f $xDLFILE 2>/dev/null
  238. rm -f $DLFILE 2>/dev/null
  239. exit
  240. fi
  241. else
  242. LANG=${LANGORG} echo "Failed to download, aborting."
  243. LANG=${LANGORG} echo "
  244. Failed to download db file:
  245. ${PKGLISTURI}
  246. ...exited from 0setup script." >> /var/woof/0setup_fail_report_$RUNNINGPUP
  247. exit
  248. fi
  249. else #120126
  250. LANG=${LANGORG} echo "...skipped"
  251. fi
  252. fi
  253. done
  254. #120825 -update dbs...
  255. DBUPDATEFLAG='invalid' #121130
  256. PKGLISTS_COMPAT_UPDATES=""
  257. case $DISTRO_BINARY_COMPAT in
  258. ubuntu|debian) #130319 removed |raspbian
  259. echo
  260. LANG=${LANGORG} echo "Do you want to download the ${DISTRO_BINARY_COMPAT}-updates package databases?"
  261. LANG=${LANGORG} echo "Accept, they will be downloaded and merged,"
  262. LANG=${LANGORG} echo "such that only the updated pkg db entries are kept."
  263. LANG=${LANGORG} echo "Example: as at August 31, 2012, Ubuntu Precise Pangolin 12.04 has the first
  264. 'Service Pack' which is version 12.04.1 -- accepting here will obtain the
  265. package lists for 12.04.1 -- it is generally recommended to accept."
  266. LANG=${LANGORG} echo -n "ENTER key only to accept, any other printable char then ENTER to decline: "
  267. read DBUPDATEFLAG
  268. if [ "$DBUPDATEFLAG" = "" ];then #121113
  269. #basically same code as above, slight mods...
  270. for PKGLISTSPEC in $PKG_DOCS_DISTRO_COMPAT
  271. do
  272. updPTN1="s%${DISTRO_COMPAT_VERSION}%${DISTRO_COMPAT_VERSION}_updates%" #ex: 'precise' becomes 'precise_updates' (underscore because - is delimiter)
  273. updPTN2="s%${DISTRO_COMPAT_VERSION}%${DISTRO_COMPAT_VERSION}-updates%" #ex: 'precise' becomes 'precise-updates'
  274. PKGLISTFILE="`echo -n "$PKGLISTSPEC" | cut -f 3 -d '|' | sed "$updPTN1"`"
  275. PKGLISTURI="`echo -n "$PKGLISTSPEC" | cut -f 2 -d '|' | sed "$updPTN2"`"
  276. [ "$PKGLISTURI" = "" ] && continue #w478 no url, pkg db file only kept in woof.
  277. PKGLISTS_COMPAT_UPDATES="${PKGLISTS_COMPAT_UPDATES} ${PKGLISTFILE}" #see further down.
  278. skipdl=""
  279. if [ "$RUNNINGPUP" = "no" -a -f $PKGLISTFILE ];then
  280. echo
  281. echo "Local db file '${PKGLISTFILE}' already exists."
  282. echo "Press ENTER key only to upgrade it,"
  283. echo -n "or any other printable char to skip: "
  284. read skipdl
  285. fi
  286. if [ "$skipdl" = "" ];then
  287. echo
  288. LANG=${LANGORG} echo "A package information database file needs to be downloaded."
  289. LANG=${LANGORG} echo "This will be downloaded from:"
  290. echo "$PKGLISTURI"
  291. LANG=${LANGORG} echo "and will be processed and named: ${PKGLISTFILE}"
  292. LANG=${LANGORG} echo -n "Press ENTER key to download, any other to skip it: " #120126
  293. read downloadit
  294. if [ "$downloadit" = "" ] ; then #120126
  295. DLFILE="`basename $PKGLISTURI`"
  296. [ -f $DLFILE ] && mv -f $DLFILE /tmp/${DLFILE}-backup1 #v431 otherwise wget creates a new file ${DLFILE}.1
  297. rxvt -name pet -bg orange -geometry 80x10 -e wget $PKGLISTURI
  298. sync
  299. xDLFILE="$DLFILE"
  300. if [ -f $DLFILE ];then
  301. case ${DISTRO_BINARY_COMPAT} in
  302. ubuntu|debian) #130319 removed |raspbian
  303. xDLFILE="`basename $DLFILE .bz2`"
  304. bunzip2 $DLFILE
  305. RETSTAT=$?
  306. [ $RETSTAT -eq 0 ] && mv -f $xDLFILE ${PKGLISTFILE}pre
  307. ;;
  308. esac
  309. if [ $RETSTAT -eq 0 ];then
  310. LANG=${LANGORG} echo "...success."
  311. else
  312. LANG=${LANGORG} echo "Downloaded file is corrupted. Deleting file and aborting."
  313. rm -f $xDLFILE 2>/dev/null
  314. rm -f $DLFILE 2>/dev/null
  315. exit
  316. fi
  317. else
  318. LANG=${LANGORG} echo "Failed to download, aborting."
  319. LANG=${LANGORG} echo "
  320. Failed to download db file:
  321. $PKGLISTURI
  322. ...exited from 0setup script." >> /var/woof/0setup_fail_report_$RUNNINGPUP
  323. exit
  324. fi
  325. else #120126
  326. LANG=${LANGORG} echo "...skipped"
  327. fi
  328. fi
  329. done
  330. fi
  331. ;;
  332. esac
  333. ###download pet pkg databases...
  334. for PKGLISTSPEC in $PKG_DOCS_PET_REPOS #see file DISTRO_PET_REPOS
  335. do
  336. PKGLISTFILE="`echo -n "$PKGLISTSPEC" | cut -f 3 -d '|'`"
  337. PKGLISTURI="`echo -n "$PKGLISTSPEC" | cut -f 2 -d '|'`"
  338. if [ "$RUNNINGPUP" = "yes" -o ! -f $PKGLISTFILE ];then
  339. echo
  340. LANG=${LANGORG} echo "A package information database file needs to be downloaded."
  341. LANG=${LANGORG} echo "This will be downloaded from:"
  342. echo "$PKGLISTURI"
  343. LANG=${LANGORG} echo "and will be named: ${PKGLISTFILE}"
  344. LANG=${LANGORG} echo -n "Press ENTER key to download, any other to skip it: " #120126
  345. read downloadit
  346. if [ "$downloadit" = "" ] ; then #120126
  347. DLFILE="`basename $PKGLISTURI`"
  348. [ -f $DLFILE ] && mv -f $DLFILE /tmp/${DLFILE}-backup1 #v431 otherwise wget creates a new file ${DLFILE}.1 111129 prevent error msg.
  349. rxvt -name pet -bg orange -geometry 80x10 -e wget $PKGLISTURI
  350. sync
  351. [ -f $DLFILE ] && LANG=${LANGORG} echo "...success"
  352. else #120126
  353. LANG=${LANGORG} echo "...skipped"
  354. fi
  355. fi
  356. done
  357. v1PATTERN="s%\\-[0-9.]*${DISTRO_BINARY_COMPAT}[0-9.]*$%%"
  358. v2PATTERN="s%\\+[0-9.]*${DISTRO_BINARY_COMPAT}[0-9.]*$%%"
  359. #130305 debdb2pupdb.bac now also check that deps exist, need this list of pkgs...
  360. if [ "$RUNNINGPUP" = "no" ];then #130316 debdb2pupdb does not read this file in a running pup.
  361. case ${DISTRO_BINARY_COMPAT} in
  362. ubuntu|debian|raspbian)
  363. echo -n " " > /tmp/0setupcompletelistpkgs
  364. COMPLETELISTPKGS="$(grep '^Package: ' Packages*pre | cut -f 2 -d ' ' | tr '\n' ' ')"
  365. echo "$COMPLETELISTPKGS" >> /tmp/0setupcompletelistpkgs
  366. [ -f /tmp/0setupnewinvaliddeps ] && rm -f /tmp/0setupnewinvaliddeps #see debdb2pupdb.
  367. ;;
  368. esac
  369. else
  370. [ -f /tmp/0setupcompletelistpkgs ] && rm -f /tmp/0setupcompletelistpkgs
  371. fi
  372. #w008 convert pkg database ${PKGLISTFILE}pre to a standard format...
  373. #120812 subcategory...
  374. #each line: pkgname|nameonly|version|pkgrelease|category[;subcategory]|size|path|fullfilename|dependencies|description|
  375. #ex: abiword-1.2.4|abiword|1.2.4|5|Document|999K|slackware/ab|abiword-1.2.4-5-i486.tgz|+aiksausus,+gtk2|a nice wordprocessor|
  376. PKGLISTS_COMPAT="`echo "$PKG_DOCS_DISTRO_COMPAT" | tr ' ' '\n' | cut -f 3 -d '|' | tr '\n' ' '`" #see file DISTRO_PKGS_SPECS-ubuntu
  377. #...format ex: 'Packages-ubuntu-intrepid-main Packages-ubuntu-intrepid-universe'
  378. for ONE_PKGLISTS_COMPAT in $PKGLISTS_COMPAT $PKGLISTS_COMPAT_UPDATES #120825
  379. do
  380. [ ! -f ${ONE_PKGLISTS_COMPAT}pre ] && continue
  381. echo
  382. LANG=${LANGORG} echo "Processing ${ONE_PKGLISTS_COMPAT} into a standard format..."
  383. echo -n "" > $ONE_PKGLISTS_COMPAT
  384. echo -n "" > /tmp/${ONE_PKGLISTS_COMPAT}temp #130126
  385. case ${DISTRO_BINARY_COMPAT} in
  386. ubuntu|debian|raspbian)
  387. if [ -f /usr/local/petget/debdb2pupdb ];then #121111
  388. #new fast compiled app...
  389. #create an intermediate-converted file...
  390. LANG=${LANGORG} echo " please wait..."
  391. #121113 added "Section"...
  392. #121113 insert STARTMARKER...
  393. MANIPULATED1="$(grep -E '^Package:|^Installed\-Size:|^Architecture:|^Version:|^Depends:|^Filename:|^Description:|^Homepage:|^Section:' ${ONE_PKGLISTS_COMPAT}pre | tr '[\t"|`]' ' ' | tr -s ' ' | sed -e 's%^Installed\-Size%InstalledSize%' -e 's%^Package:%STARTMARKER|PKG\nPackage:%' -e 's%: %|%' -e 's% $%%')" #`geany
  394. echo "$MANIPULATED1" > /tmp/woof-debdb.in
  395. #call new app. note, this in turn calls /usr/local/petget/find_pkgs...
  396. /usr/local/petget/debdb2pupdb ${DISTRO_BINARY_COMPAT} ${DISTRO_COMPAT_VERSION} > /tmp/${ONE_PKGLISTS_COMPAT}temp #130126 $ONE_PKGLISTS_COMPAT
  397. ${FIND_CAT} /tmp/${ONE_PKGLISTS_COMPAT}temp > $ONE_PKGLISTS_COMPAT #130126
  398. #homepages also get logged...
  399. if [ -f /tmp/woof-homepages.acc ];then
  400. if [ -f ./PKGS_HOMEPAGES ];then #running in woof.
  401. cat ./PKGS_HOMEPAGES >> /tmp/woof-homepages.acc
  402. sort --key=1,1 --field-separator=" " --unique /tmp/woof-homepages.acc > ./PKGS_HOMEPAGES #121113
  403. fi
  404. fi
  405. #130316 /tmp/0setupnewinvaliddeps is created by debdb2pupdb, when run in woof.
  406. # 3builddistro will have to copy this file 'invaliddepslist' into rootfs-complete/usr/local/petget/ ...
  407. # it is read by debdb2pupdb in a running puppy.
  408. if [ "$RUNNINGPUP" = "no" ];then
  409. echo -n ' ' > invaliddepslist
  410. NIDL1="$(sort -u /tmp/0setupnewinvaliddeps | tr '\n' ' ')"
  411. echo -n "$NIDL1" >> invaliddepslist
  412. fi
  413. else
  414. DB_category="" #130126
  415. #120719 debian squeeze and earlier has Description field last, wheezy has Filename field last...
  416. Description=''; Filename=''; Package=''; InstalledSize=''; Architecture=''; Version=''
  417. endflag=''
  418. while read DB_ONELINE
  419. do
  420. eval $DB_ONELINE
  421. case $DB_ONELINE in
  422. Description*)
  423. [ "$Filename" ] && endflag='yes'
  424. ;;
  425. Filename*)
  426. [ "$Description" ] && endflag='yes' #wheezy and later.
  427. ;;
  428. esac
  429. if [ "$endflag" = "yes" ];then
  430. DB_fullfilename="`echo -n "$Filename" | rev | cut -f 1 -d '/' | rev`"
  431. DB_path="`echo -n "$Filename" | rev | cut -f 2-9 -d '/' | rev`"
  432. DB_version="`echo -n "$Version" | sed -e 's%^[0-9]:%%' -e "$v1PATTERN" -e "$v2PATTERN"`"
  433. DB_pkgrelease="`echo -n "$Version" | sed -e 's%^[0-9]:%%' -e "s%${DB_version}%%" -e 's%^\\-%%' -e 's%^\\+%%'`"
  434. DB_pkgname="${Package}_${DB_version}"
  435. #120815 for debian, ubuntu, use the generic name provided in the $DB_path, instead of $Package, for find_cat... 130126...
  436. #xPackage="$Package"
  437. #[ "$DB_path" ] && xPackage="$(basename "$DB_path")"
  438. #DB_category="`${FIND_CAT} $xPackage "$Description"`" #120812 find_cat now returns category[;subcategory], ex: Document;edit
  439. DB_dependencies="`echo -n "$Depends" | sed -e 's%, %\n%g' | cut -f 1 -d ' ' | tr '\n' ' ' | sed -e 's% $%%' -e 's% %,+%g' -e 's%,$%%'`"
  440. [ "$DB_dependencies" != "" ] && DB_dependencies='+'"$DB_dependencies"
  441. echo "$DB_pkgname|$Package|$DB_version|$DB_pkgrelease|$DB_category|${InstalledSize}K|$DB_path|$DB_fullfilename|$DB_dependencies|$Description|$DISTRO_BINARY_COMPAT|$DISTRO_COMPAT_VERSION|" >> /tmp/${ONE_PKGLISTS_COMPAT}temp #130126 $ONE_PKGLISTS_COMPAT
  442. echo -n "$Package "
  443. Description=''; Filename=''; Package=''; InstalledSize=''; Architecture=''; Version=''
  444. endflag=''
  445. fi
  446. done<<_END1
  447. $(grep -E '^Package:|^Installed\-Size:|^Architecture:|^Version:|^Depends:|^Filename:|^Description:' ${ONE_PKGLISTS_COMPAT}pre | tr '[\t"|`]' ' ' | tr -s ' ' | grep -v '\\-dbg$' | sed -e 's%^Installed\-Size%InstalledSize%' -e 's%: %="%' -e 's% $%%' -e 's%$%"%')
  448. _END1
  449. ${FIND_CAT} /tmp/${ONE_PKGLISTS_COMPAT}temp > $ONE_PKGLISTS_COMPAT #130126
  450. fi
  451. ;;
  452. slackware)
  453. DB_category="" #130126
  454. #note stabellini site has PACKAGES.TXT for the official 12.2 repo, with dependency info.
  455. #however, there is an extra 'PACKAGE MIRROR' field so i have added this preprocess line...
  456. #some pipe (|) chars screw up dep info so replace with commas in the pre process #01micko 20110505
  457. sed -i 's%|%,%g' ${ONE_PKGLISTS_COMPAT}pre
  458. REPODATA0="`cat ${ONE_PKGLISTS_COMPAT}pre | grep -v '^PACKAGE MIRROR'`"
  459. REPODATA="`echo "$REPODATA0" | tr '\t' ' ' | tr -s ' ' | sed -e 's% $%%' | tr '\n' ' ' | sed -e 's% %\n%g'| grep -o '.*PACKAGE DESCRIPTION: [^ ]*: ' | sed -e 's%: $%%'`"
  460. #...each line ex: PACKAGE NAME: zsh-4.3.6-i486-1.tgz PACKAGE LOCATION: ./slackware/ap PACKAGE SIZE (compressed): 2302 K PACKAGE SIZE (uncompressed): 6870 K PACKAGE DESCRIPTION: zsh
  461. #...that last field is the actual package name without version.
  462. #the slacky repo has more information in its database, these fields:
  463. #PACKAGE NAME: PACKAGE LOCATION: PACKAGE SIZE (compressed): PACKAGE SIZE (uncompressed): PACKAGE REQUIRED: PACKAGE CONFLICTS: PACKAGE SUGGESTS: PACKAGE DESCRIPTION:
  464. echo "$REPODATA" |
  465. while read DB_ONELINE
  466. do
  467. [ "$DB_ONELINE" = "" ] && continue #w016 precaution.
  468. DB_fullfilename="`echo -n "$DB_ONELINE" | grep -o 'PACKAGE NAME: [^ ]* ' | cut -f 3 -d ' '`"
  469. DB_path="`echo -n "$DB_ONELINE" | grep -o 'PACKAGE LOCATION: [^ ]* ' | cut -f 3 -d ' ' | sed -e 's%^\./%%'`"
  470. DB_size="`echo -n "$DB_ONELINE" | grep -o 'PACKAGE SIZE (uncompressed): [^ ]* ' | cut -f 4 -d ' ' | sed -e 's% %%'`"'K'
  471. #DB_dependencies="`echo -n "$DB_ONELINE" | grep -o ' PACKAGE REQUIRED: .* PACKAGE ' | sed -e 's% PACKAGE %%' | cut -f 2-99 -d ' ' | sed -e 's% [^,]*%%g' | sed -e 's%,%,+%g' | sed -e 's/[^0-9a-zA-Z.+_=,-]//g'`" #100626
  472. DB_dependencies="`echo -n "$DB_ONELINE" | grep -o ' PACKAGE REQUIRED: .* PACKAGE ' | sed -e 's% PACKAGE %%' | cut -f 2-99 -d ' ' | sed -e 's% [^,]*%%g' -e 's%,%,+%g' -e 's/[^0-9a-zA-Z.+_=,-]//g'`" #100626 #110501 speed up sed
  473. [ "$DB_dependencies" != "" ]&& DB_dependencies='+'"$DB_dependencies"
  474. [ "$DB_dependencies" = "+PACKAGE" ]&& DB_dependencies="" #01micko 20110504 bug with "+PACKAGES" sneaking through
  475. #...processed to ex: +acl,+gcc,+glibc-solibs,+libXt,+libart_lgpl
  476. DB_nameonly="`echo -n "$DB_ONELINE" | grep -o 'PACKAGE DESCRIPTION: .*' | cut -f 3 -d ' '`"
  477. #get the actual one-line description...
  478. dbPATTERN='^'"$DB_nameonly"': '
  479. DB_description="`grep "$dbPATTERN" ${ONE_PKGLISTS_COMPAT}pre | head -n 1 | cut -f 2 -d '(' | cut -f 1 -d ')' | tr '\-' ' ' | sed -e 's/[^0-9a-zA-Z.+_= ]//g'`"
  480. #a problem, some entries in slacky db do not have a description in "( .... )" so look further...
  481. if [ "`grep "$dbPATTERN" ${ONE_PKGLISTS_COMPAT}pre | head -n 1 | grep '('`" = "" ];then
  482. DB_description="`grep "$dbPATTERN" ${ONE_PKGLISTS_COMPAT}pre | head -n 3 | tail -n 1 | cut -f 2-11 -d ' ' | tr '\-' ' ' | sed -e 's/[^0-9a-zA-Z.+_= ]//g'`"
  483. fi
  484. #get the category...
  485. #w015 find_cat_func replaced by compiled app... 130126...
  486. #xDB_description="$DB_description"
  487. #[ "$DB_description" = "" ] && xDB_description="nothing"
  488. #DB_category="`${FIND_CAT} $DB_nameonly "$xDB_description"`" #120812 see updated find_cat
  489. #pkgname, version...
  490. DB_pkgname="`echo -n "$DB_fullfilename" | sed -e 's%-i[3456]86.*%%' | sed -e 's%-noarch.*%%'`"
  491. noPATTERN="s%${DB_nameonly}%%"
  492. DB_version="`echo -n "$DB_pkgname" | sed -e "$noPATTERN" | sed -e 's%^\-%%'`"
  493. #add support for .txz pkgs...
  494. DB_pkgrelease="`echo -n "$DB_fullfilename" | sed -e 's%\.txz%%' | sed -e 's%\.tgz%%' | sed -e 's%.*\-i[3456]86%%' | sed -e 's%.*\-noarch%%' | sed -e 's%^\-%%'`"
  495. echo "$DB_pkgname|$DB_nameonly|$DB_version|$DB_pkgrelease|$DB_category|$DB_size|$DB_path|$DB_fullfilename|$DB_dependencies|$DB_description|$DISTRO_BINARY_COMPAT|$DISTRO_COMPAT_VERSION|" >> /tmp/${ONE_PKGLISTS_COMPAT}temp #130126 $ONE_PKGLISTS_COMPAT
  496. echo -n "$DB_nameonly "
  497. done
  498. ${FIND_CAT} /tmp/${ONE_PKGLISTS_COMPAT}temp > $ONE_PKGLISTS_COMPAT #130126
  499. ;;
  500. arch)
  501. LANG=${LANGORG} echo "...it's already in the Puppy standard format."
  502. ;;
  503. t2) #w017
  504. LANG=${LANGORG} echo "...it's already in the Puppy standard format."
  505. ;;
  506. puppy)
  507. echo "...it's already in the Puppy standard format."
  508. ;;
  509. scientific) #110523 Iguleder
  510. [ -f $ONE_PKGLISTS_COMPAT ] && rm -f $ONE_PKGLISTS_COMPAT
  511. ${RPM2PPM} ${ONE_PKGLISTS_COMPAT}pre $ONE_PKGLISTS_COMPAT $DISTRO_BINARY_COMPAT $DISTRO_COMPAT_VERSION #110612 fix
  512. temp_file=`mktemp -u`
  513. cat $ONE_PKGLISTS_COMPAT | sort | uniq > $temp_file
  514. mv $temp_file $ONE_PKGLISTS_COMPAT
  515. ;;
  516. mageia) #110612
  517. [ -f $ONE_PKGLISTS_COMPAT ] && mv -f $ONE_PKGLISTS_COMPAT /tmp/${ONE_PKGLISTS_COMPAT}-OLD
  518. ${MAGEIA2PPM} ${ONE_PKGLISTS_COMPAT}pre $DISTRO_COMPAT_VERSION
  519. mv -f /tmp/mageia2ppm-ppm-temp4 ${ONE_PKGLISTS_COMPAT}
  520. ;;
  521. esac
  522. echo
  523. #rm -f ${ONE_PKGLISTS_COMPAT}pre 2>/dev/null
  524. mv -f ${ONE_PKGLISTS_COMPAT}pre /tmp/ 2>/dev/null
  525. sort --field-separator='|' --key=1 ${ONE_PKGLISTS_COMPAT} > /tmp/$PKGLISTFILE
  526. mv -f /tmp/$PKGLISTFILE ${ONE_PKGLISTS_COMPAT}
  527. done
  528. echo
  529. ####################################
  530. #120825 merge updates into original db files...
  531. if [ "$DBUPDATEFLAG" = "" ];then #121113 empty now means yes.
  532. for ONE_PKGLISTS_COMPAT in $PKGLISTS_COMPAT
  533. do
  534. REPOFIELD="`echo -n "$ONE_PKGLISTS_COMPAT" | rev | cut -f 1 -d '-' | rev`" #ex: main
  535. PKGUPDATES="`echo -n "$PKGLISTS_COMPAT_UPDATES" | tr ' ' '\n' | grep "\-${REPOFIELD}$" | head -n 1`" #ex: Packages-ubuntu-precise_updates-main
  536. cat $PKGUPDATES > /tmp/0setup_xxx1
  537. cat $ONE_PKGLISTS_COMPAT >> /tmp/0setup_xxx1
  538. sync
  539. #want to discard the older package...
  540. sort --unique --field-separator='|' --key=2,2 /tmp/0setup_xxx1 > $ONE_PKGLISTS_COMPAT
  541. #...assumes pkg names remain the same, ex "firefox" (2nd field in db).
  542. mv -f $PKGUPDATES /tmp/$PKGUPDATES #dump -updates db file.
  543. done
  544. fi
  545. sync
  546. #120909 moved down...
  547. if [ "$RUNNINGPUP" = "yes" ];then
  548. echo
  549. LANG=${LANGORG} echo "FINISHED"
  550. LANG=${LANGORG} echo "After restarting Puppy Package Manager (PPM),"
  551. LANG=${LANGORG} echo "it will be reading the updated database files."
  552. LANG=${LANGORG} echo -n "Press ENTER key to exit: "
  553. read enditnow
  554. exit
  555. fi
  556. ####################################
  557. #extract all the package names of compat-distro, without version info...
  558. PKGNAMES="`cat $PKGLISTS_COMPAT | cut -f 1,2,3 -d '|'`"
  559. #...on separate lines, ex: gdb-6.8 gdbm-1.8.3 genpower-1.0.5
  560. #check the entries in PKGS_SPECS_TABLE against those in Packages-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}.
  561. #that is, need to verify that pkgs specified in table do actually exist.
  562. echo
  563. echo "Checking that compat-distro pkgs specified in PKGS_SPECS_TABLE actually exist..."
  564. echo "
  565. Checking that compat-distro pkgs specified in PKGS_SPECS_TABLE actually exist..." >> /var/woof/0setup_fail_report_$RUNNINGPUP
  566. FAILCHK="no"
  567. #BINARYPARTNAMES="`echo "$PKGS_SPECS_TABLE" | grep '^yes' | cut -f 3 -d '|' | tr ',' '\n' | grep -v '^-' | tr '\n' ' '`"
  568. #120315 extra field on end to force repo...
  569. FIELDS2345="`echo "$PKGS_SPECS_TABLE" | grep '^yes' | cut -f 2,3,4,5 -d '|' | cut -f 1 -d ' ' | grep -v '|pet:' | tr '\n' ' '`"
  570. for AFIELD2345 in $FIELDS2345
  571. do
  572. ASSIGNFIELD="`echo -n "$AFIELD2345" | cut -f 3 -d '|'`" #120804 ex: exe>dev,dev,doc,nls
  573. AFIELD235="`echo -n "$AFIELD2345" | cut -f 1,2,4 -d '|'`" #120804
  574. if [ "`echo -n "$AFIELD235" | grep '||[a-zA-Z0-9]*:'`" = "" ];then #ex: abiword||wary5:
  575. BINARYPARTNAMES="`echo -n "$AFIELD235" | cut -f 2 -d '|' | tr ',' '\n' | grep -v '^-' | tr '\n' ' '`" #ex: "abiword|abiword0,libabiword|" becomes "abiword0 libabiword"
  576. else
  577. BINARYPARTNAMES="`echo -n "$AFIELD235" | cut -f 1 -d '|'`" #use the generic name.
  578. fi
  579. for ONEBINARYPARTNAME in $BINARYPARTNAMES
  580. do
  581. #ONEBINARYPARTNAME may match multiple pkgs...
  582. #i think that dashes need to be backslashed...
  583. multiPATTERN="`echo -n "$ONEBINARYPARTNAME" | sed -e 's%\\-%\\\\-%g'`"
  584. #may have blob * wildcard, change to reg.expr....
  585. multiPATTERN="`echo -n "$multiPATTERN" | sed -e 's%\\*%.*%g'`"
  586. xPATTERN='|'"$multiPATTERN"'|'
  587. [ "`echo "$PKGNAMES" | grep "$xPATTERN"`" != "" ] && continue #success.
  588. if [ "$ASSIGNFIELD" ];then #120804
  589. #this will find entry in PKGS_SPECS_TABLE like 'yes|apr|apr|exe>dev,dev,doc,nls', where pkg apr-123 does not exist, only apr_DEV-123...
  590. EXEASSIGNED=''
  591. [ "`echo -n "$ASSIGNFIELD" | grep 'exe>dev'`" != "" ] && EXEASSIGNED='dev'
  592. [ "`echo -n "$ASSIGNFIELD" | grep 'exe>null'`" != "" ] && EXEASSIGNED='null'
  593. if [ "$EXEASSIGNED" ];then
  594. xxPATTERN='^'"${ONEBINARYPARTNAME}_DEV"
  595. [ "`echo "$PKGNAMES" | grep "$xxPATTERN"`" != "" ] && continue #success.
  596. fi
  597. #this entry 'yes|perl-digest-sha1|perl-digest-sha1|exe,dev>null,doc>null,nls>null' also only has a _DEV pkg...
  598. DEVASSIGNED=''
  599. [ "`echo -n "$ASSIGNFIELD" | grep 'dev>exe'`" != "" ] && DEVASSIGNED='exe'
  600. if [ "$DEVASSIGNED" = "exe" ];then
  601. xxPATTERN='^'"${ONEBINARYPARTNAME}_DEV"
  602. [ "`echo "$PKGNAMES" | grep "$xxPATTERN"`" != "" ] && continue #success.
  603. fi
  604. fi
  605. #if [ "`echo -n "$ONEBINARYPARTNAME" | grep '[a-z]\\-[0-9]'`" != "" ];then
  606. if [ "`echo -n "$ONEBINARYPARTNAME" | grep '\\*'`" != "" ];then
  607. zPATTERN='^'"$multiPATTERN"
  608. [ "`echo "$PKGNAMES" | grep "$zPATTERN"`" != "" ] && continue #success.
  609. fi
  610. #failure...
  611. echo "FAIL: $ONEBINARYPARTNAME"
  612. echo "FAIL: $ONEBINARYPARTNAME" >> /var/woof/0setup_fail_report_$RUNNINGPUP
  613. FAILCHK="yes"
  614. done
  615. done
  616. if [ "$FAILCHK" = "yes" ];then
  617. echo
  618. echo "Finished, but some failures. You need to fix the above entries in"
  619. echo "PKGS_SPECS_TABLE in file ${DPSFILE}."
  620. echo "Search for suitable packages in these files:"
  621. echo "`echo "$PKG_DOCS_DISTRO_COMPAT" | tr ' ' '\n' | cut -f 3 -d '|'`"
  622. echo "Or, search online. In the case of Debian or Ubuntu, you can search"
  623. echo "at packages.debian.org or packages.ubuntu.com."
  624. echo "After you have fixed PKGS_SPECS_TABLE, run this script again."
  625. echo "
  626. Finished, but some failures. You need to fix the above entries in variable
  627. PKGS_SPECS_TABLE in file ${DPSFILE}.
  628. Search for suitable packages in these files:
  629. `echo "$PKG_DOCS_DISTRO_COMPAT" | tr ' ' '\n' | cut -f 3 -d '|'`
  630. Or, search online. In the case of Debian or Ubuntu, you can search
  631. at packages.debian.org or packages.ubuntu.com.
  632. After you have fixed PKGS_SPECS_TABLE, run this script again." >> /var/woof/0setup_fail_report_$RUNNINGPUP
  633. else
  634. echo
  635. echo "Finished, successful."
  636. echo "...finished, successful." >> /var/woof/0setup_fail_report_$RUNNINGPUP
  637. fi
  638. echo
  639. echo "The log of '0setup', as reported above, is saved for future reference."
  640. echo "(In file /var/woof/0setup_fail_report_${RUNNINGPUP})"
  641. echo "In the Woof GUI, tab 'Download dbs', click the 'REPORT' button to"
  642. echo "retrieve this log."
  643. echo -n "Press ENTER key to finish '0setup' script: "
  644. read yepgetout
  645. ###END###