0setup 32 KB

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