1download 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. #!/bin/sh
  2. #(c) Copyright 2009 Barry Kauler.
  3. #100331 bad hack for t2 8.0rc/8.0rcXorg7.3 variants. 100412 removed.
  4. #100617 add support for slackware .txz pkgs.
  5. #100622 fixed control panel.
  6. #100622 hack for pet search.
  7. #100730 if subdir field not specified in pet.specs, use pet_packages-${DISTRO_COMPAT_VERSION}.
  8. #100801 some common code extracted to support/inline_get_pet,inline_get_compat.
  9. #100911 fix so will download more kernel pets.
  10. #110523 Iguleder: support Scientific Linux rpm pkgs.
  11. #110607 replace 'quirky' with 'common' repo.
  12. #110615 support mageia
  13. #110616 fix path for downloading kernel pets.
  14. #110724 optional execute support/1buildversiondeps. 110817 removed.
  15. #110725 handle exception host folder pet_packages-drake
  16. #110819 support/findpkgs is new script to find all pkgs to be used in Puppy build.
  17. #110823 moved kernel pet download code up, choose which kernel, fix control panel.
  18. #111121 noryb009: improve arch linux support, patched: 0setup, 1download, 2createpackages, 3builddistro, DISTRO_COMPAT_REPOS-arch, support/arch/runDotInstalls
  19. #111127 no longer check if host has 'printcols', 'vercmp', it is done in 'merge2out' script.
  20. #120501 support arm build.
  21. #120515 build from "gentoo" binary tarballs (refer support/gentoo).
  22. #120719 support raspbian.
  23. #120812 db category now allows optional subcategory (for which an icons exists in /usr/local/lib/X11/mini-icons).
  24. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  25. #121102 pet_packages-${DISTRO_COMPAT_VERSION} (or pet_packages-${DISTRO_FILE_PREFIX}) is now pet_packages-${DISTRO_DB_SUBNAME.
  26. #130306 arch linux: gz now xz. maybe only 'DISTRO_COMPAT_REPOS-arch'.
  27. export LANG=C #faster.
  28. . ./DISTRO_SPECS
  29. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  30. if [ -f ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  31. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  32. else
  33. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT} #130306
  34. fi
  35. if [ -f ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #w478
  36. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} #has FALLBACKS_COMPAT_VERSIONS
  37. else
  38. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT} #has FALLBACKS_COMPAT_VERSIONS
  39. fi
  40. . ./DISTRO_PET_REPOS #has PACKAGELISTS_PET_ORDER
  41. #the files that have compatible-distro pkg docs (these were downloaded by 0setup)...
  42. PKGLISTS_COMPAT="`echo "$PKG_DOCS_DISTRO_COMPAT" | tr ' ' '\n' | cut -f 3 -d '|' | tr '\n' ' '`" #see file DISTRO_PKGS_SPECS-ubuntu
  43. #...format ex: 'Packages-ubuntu-intrepid-main packages-ubuntu-intrepid-universe'
  44. #w469 modify compat-distro fallback list...
  45. if [ "$FALLBACKS_COMPAT_VERSIONS" != "" ];then
  46. FALLBACKS_COMPAT_VERSIONS="`echo -n "$FALLBACKS_COMPAT_VERSIONS" | grep -o "${DISTRO_COMPAT_VERSION}.*"`"
  47. #ex: 'koala jaunty intrepid' gets reduced to 'jaunty intrepid' if DISTRO_COMPAT_VERSION=jaunty
  48. fi
  49. #w469 refer to file DISTRO_PET_REPOS...
  50. PACKAGELISTS_PET_PRIMARY="`echo -n "$PACKAGELISTS_PET_ORDER" | cut -f 1 -d ' '`"
  51. PACKAGELISTS_PET_SECOND="`echo -n "$PACKAGELISTS_PET_ORDER" | cut -f 2 -d ' '`" #100911
  52. if [ "$DISTRO_TARGETARCH" = "arm" ];then #120501
  53. PACKAGELISTS_PET_2NDARCH="`echo -n "$PACKAGELISTS_PET_ORDER" | tr ' ' '\n' | grep -v '\-noarch' | tr '\n' ' ' | cut -f 2 -d ' '`"
  54. [ "$PACKAGELISTS_PET_2NDARCH" = "$PACKAGELISTS_PET_PRIMARY" ] && PACKAGELISTS_PET_2NDARCH=''
  55. else
  56. PACKAGELISTS_PET_2NDARCH='Packages-puppy-common-official'
  57. fi
  58. #remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  59. 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%||$%|%'`"
  60. BINARIES='deb' #download to packages-deb.
  61. [ "$DISTRO_BINARY_COMPAT" = "t2" ] && BINARIES="bz2" #download to packages-bz2-${DISTRO_COMPAT_VERSION}.
  62. [ "$DISTRO_BINARY_COMPAT" = "slackware" ] && BINARIES="tgz_txz" #100617 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  63. [ "$DISTRO_BINARY_COMPAT" = "slackware64" ] && BINARIES="tgz_txz" #140716 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  64. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  65. [ "$DISTRO_BINARY_COMPAT" = "devuan" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  66. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_xz-${DISTRO_COMPAT_VERSION}. 130306
  67. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  68. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  69. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  70. [ "$DISTRO_BINARY_COMPAT" = "gentoo" ] && BINARIES="gentoo" #120515 download to packages-gentoo-gap6
  71. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  72. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  73. mkdir -p packages-${BINARIES}
  74. mkdir -p packages-pet
  75. #find out what pet repos are working...
  76. echo "Finding what PET repos are working..."
  77. PET_URLS=""
  78. for ONE_PET_REPO in $PET_REPOS
  79. do
  80. ONE_PET_SITE="`echo -n "$ONE_PET_REPO" | cut -f 1 -d '|'`"
  81. ONE_PET_URL="`echo -n "$ONE_PET_REPO" | cut -f 2 -d '|'`"
  82. #w013 changed timeout from 20 to 30 seconds...
  83. #if wget -t 2 -T 20 --waitretry=20 --spider -S $ONE_PET_SITE -o /dev/stdout | grep '200 OK'
  84. if [ "`wget -t 2 -T 30 --waitretry=20 --spider -S $ONE_PET_SITE -o /dev/stdout 2>/dev/null | grep '200 OK'`" != "" ];then
  85. echo "Okay: $ONE_PET_URL"
  86. PET_URLS="$PET_URLS$ONE_PET_URL " #success.
  87. fi
  88. done
  89. if [ "$PET_URLS" = "" ];then
  90. echo "Failure. Is Internet working?"
  91. echo -n "Press ENTER key to quit script: "
  92. read yesgetout
  93. exit
  94. fi
  95. echo "Finding what $BINARIES repos are working..."
  96. BIN_URLS=""
  97. for ONE_BIN_REPO in $REPOS_DISTRO_COMPAT #from DISTRO_PKGS_SPECS-$DISTRO_BINARY_COMPAT.
  98. do
  99. ONE_BIN_SITE="`echo -n "$ONE_BIN_REPO" | cut -f 1 -d '|'`"
  100. ONE_BIN_URL="`echo -n "$ONE_BIN_REPO" | cut -f 2 -d '|'`"
  101. #w013 ditto...
  102. if [ "`wget -t 2 -T 30 --waitretry=20 --spider -S $ONE_BIN_SITE -o /dev/stdout 2>/dev/null | grep '200 OK'`" != "" ];then
  103. echo "Okay: $ONE_BIN_URL"
  104. BIN_URLS="$BIN_URLS$ONE_BIN_URL " #success.
  105. fi
  106. done
  107. if [ "$BIN_URLS" = "" ];then
  108. echo "Failure. Is Internet working?"
  109. echo -n "Press ENTER key to quit script: "
  110. read yesgetout
  111. exit
  112. fi
  113. rm -f DOWNLOAD-FAILS-PET 2>/dev/null
  114. rm -f DOWNLOAD-FAILS-${BINARIES} 2>/dev/null
  115. rm -f DOWNLOAD-ERRORS
  116. #start the gui controlpanel...
  117. echo 'Run' > /tmp/1download-status-request
  118. ./support/1download_controlpanel &
  119. ######################
  120. #110823 moved downloading kernels PETs up here.
  121. #download all the linux kernel pkgs from pet repo...
  122. echo
  123. echo "Downloading Linux kernel packages..."
  124. for PKGLISTFILE in $PACKAGELISTS_PET_PRIMARY #$PACKAGELISTS_PET_2NDARCH #$PACKAGELISTS_PET_SECOND #$PACKAGELISTS_PET_THIRD #110616
  125. do
  126. if [ "$DISTRO_KERNEL_PET" = "Huge_Kernel" ];then
  127. echo "You are doing a Huge style build, not downloading a kernel now."
  128. echo "This will occur when you run 3builddistro-Z or click 'HUGE BUILD DISTRO'"
  129. echo "in the Woof GUI."
  130. echo
  131. break
  132. fi
  133. if [ "$DISTRO_KERNEL_PET" != "" ] ; then
  134. SUBDIRTRAIL="`echo -n "$PKGLISTFILE" | cut -f 3 -d '-'`" #ex: common
  135. SPEC_LINUXKERNELS="`cat $PKGLISTFILE | grep $DISTRO_KERNEL_PET | cut -f 2-99 -d ':' | cut -f 7,8 -d '|' | tr '\n' ' '`"
  136. if [ "$SPEC_LINUXKERNELS" = "" ]; then
  137. echo
  138. echo "WARNING: Can not find the kernel pet specified in"
  139. echo "DISTRO_SPECS file"
  140. echo "Please update your DISTRO_SPECS file with one"
  141. echo "of the available kernels."
  142. echo "Will now download ALL the kernels available in the repos..."
  143. echo
  144. sleep 5
  145. SUBDIRTRAIL="`echo -n "$PKGLISTFILE" | cut -f 3 -d '-'`" #ex: common
  146. SPEC_LINUXKERNELS="`cat $PKGLISTFILE | grep '^linux_kernel\-' | cut -f 2-99 -d ':' | cut -f 7,8 -d '|' | tr '\n' ' '`"
  147. fi
  148. else
  149. SUBDIRTRAIL="`echo -n "$PKGLISTFILE" | cut -f 3 -d '-'`" #ex: common
  150. SPEC_LINUXKERNELS="`cat $PKGLISTFILE | grep '^linux_kernel\-' | cut -f 2-99 -d ':' | cut -f 7,8 -d '|' | tr '\n' ' '`"
  151. fi
  152. for SPEC_ONEKERNEL in $SPEC_LINUXKERNELS
  153. do
  154. ONEKERNEL="`echo -n "$SPEC_ONEKERNEL" | cut -f 2 -d '|'`"
  155. ONEKERNEL="`basename $ONEKERNEL .pet`"
  156. PATHKERNEL="`echo -n "$SPEC_ONEKERNEL" | cut -f 1 -d '|'`"
  157. [ "$PATHKERNEL" = "" ] && PATHKERNEL="pet_packages-${SUBDIRTRAIL}" #110616
  158. SUCCESS="no"
  159. [ -f packages-pet/${ONEKERNEL}.pet ] && continue
  160. for ONE_PET_URL in $PET_URLS
  161. do
  162. wget --spider --tries=1 --timeout=20 ${ONE_PET_URL}/${PATHKERNEL}/${ONEKERNEL}.pet
  163. [ $? -ne 0 ] && continue
  164. cd packages-pet
  165. wget ${ONE_PET_URL}/${PATHKERNEL}/${ONEKERNEL}.pet
  166. sync
  167. #check file downloaded correctly...
  168. if [ -f ${ONEKERNEL}.pet ];then
  169. cp -f ${ONEKERNEL}.pet tempfileonly.pet
  170. pet2tgz tempfileonly.pet
  171. [ $? -eq 0 ] && SUCCESS='yes'
  172. rm -f tempfileonly.pet 2>/dev/null
  173. rm -f tempfileonly.tar.gz 2>/dev/null
  174. [ "$SUCCESS" = "no" ] && rm -f ${ONEKERNEL}.pet
  175. fi
  176. cd ..
  177. #check controlpanel, whether need to pause, resume or quit...
  178. CP_STATUS_REQ="`cat /tmp/1download-status-request`" #Run, Pause, Resume, Quit
  179. pausecnt=0; PIDCP=0
  180. while [ "$CP_STATUS_REQ" = "Pause" ];do
  181. #echo "Status: paused ${pausecnt}seconds"
  182. if [ $PIDCP -eq 0 ];then
  183. yaf-splash -close never -placement top -bg orange -text "1download script is currently in paused state" &
  184. PIDCP=$!
  185. fi
  186. sleep 5
  187. pausecnt=`expr $pausecnt + 5`
  188. CP_STATUS_REQ="`cat /tmp/1download-status-request`"
  189. done
  190. [ $PIDCP -ne 0 ] && kill $PIDCP
  191. if [ "$CP_STATUS_REQ" = "Quit" ];then
  192. sync
  193. kill `cat /tmp/1download_controlpanel_pid` #1download_controlpanel
  194. rm -f /tmp/1download_controlpanel_pid
  195. echo
  196. echo "1download aborted."
  197. echo -n "Press ENTER key to quit script: "
  198. read yesgetout
  199. exit
  200. fi
  201. [ "$SUCCESS" = "yes" ] && continue 2
  202. done
  203. echo "Failed to download ${ONEKERNEL}.pet."
  204. done
  205. done
  206. ####choose kernel####
  207. case "$DISTRO_KERNEL_PET" in
  208. Huge*)echo "" ;;
  209. *)KERNELPKG="$DISTRO_KERNEL_PET"
  210. if [ -f packages-pet/$DISTRO_KERNEL_PET ];then
  211. KMSG="This package exists in directory packages-pet, so ok. But you can change
  212. it now if you wish."
  213. KOK=''
  214. else
  215. KMSG="This package does not exist in directory packages-pet, so you cannot use it.
  216. You must choose a linux kernel PET package from those available."
  217. KOK='no'
  218. fi
  219. echo
  220. echo "The kernel to be used is specified in variable DISTRO_KERNEL_PET in file"
  221. echo "DISTRO_SPECS. Currently DISTRO_KERNEL_PET=${DISTRO_KERNEL_PET}"
  222. echo "$KMSG"
  223. if [ "$KOK" = "" ];then
  224. echo -n "Press ENTER only to use this kernel, press any other char to change: "
  225. read KOK
  226. fi
  227. if [ "$KOK" ];then
  228. CNTLOOP=1
  229. AVAILKERNELS="`ls -1 packages-pet/linux_kernel-*.pet`"
  230. [ "$AVAILKERNELS" = "" ] && echo 'No linux_kernel pkgs avail in packages-pet. Press CTRL-C.'
  231. for ONEKERNEL in $AVAILKERNELS
  232. do
  233. echo "$CNTLOOP $ONEKERNEL"
  234. CNTLOOP=`expr $CNTLOOP + 1`
  235. done
  236. echo
  237. echo -n 'Type number for kernel you want to use [1]: '
  238. read numkernel
  239. [ "$numkernel" = "" ] && numkernel=1
  240. KERNELPKG="`echo "$AVAILKERNELS" | head -n $numkernel | tail -n 1 | rev | cut -f 1 -d '/' | rev`"
  241. fi
  242. if [ "$KERNELPKG" != "$DISTRO_KERNEL_PET" ];then
  243. dkpPATTERN="s%^DISTRO_KERNEL_PET.*%DISTRO_KERNEL_PET='${KERNELPKG}'%"
  244. sed -i -e "$dkpPATTERN" ./DISTRO_SPECS
  245. echo "...DISTRO_SPECS now set to use $KERNELPKG"
  246. fi
  247. ;;
  248. esac
  249. ##################################
  250. #120501 support arm build, download sd images...
  251. if [ "$DISTRO_TARGETARCH" = "arm" ];then
  252. mkdir -p sd-skeleton-images
  253. echo
  254. echo 'Please wait, probing for online SD skeleton image files...'
  255. wget -4 -t 2 -T 20 --waitretry=20 --spider --recursive --level=1 --accept '*.xz' -S http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/ 2>&1 | grep '\.xz$' | rev | cut -f 1 -d '/' | rev > /tmp/1download-sd-images-probe
  256. sync
  257. if [ ! -s /tmp/1download-sd-images-probe ];then
  258. echo 'Sorry, could not access any SD images at http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/'
  259. echo 'Press ENTER to continue script regardless: '
  260. read keepgoing
  261. [ "$keepgoing" != "" ] && exit
  262. else
  263. #ask which sd-image to download...
  264. ALREADYDOWN="`ls -1 sd-skeleton-images | grep 'xz$'`"
  265. [ "$ALREADYDOWN" = "" ] && ALREADYDOWN='none'
  266. SDIMAGEBUTTONS=''
  267. for ONESDIMAGE in `cat /tmp/1download-sd-images-probe | sort -u | tr '\n' ' '`
  268. do
  269. #SDIMAGENAME="`basename $ONESDIMAGE .xz`"
  270. [ -f sd-skeleton-images/$ONESDIMAGE ] && continue #already downloaded.
  271. SDIMAGEBUTTONS="${SDIMAGEBUTTONS}<radiobutton><label>${ONESDIMAGE}</label><variable>RADIO_URL_${ONESDIMAGE}</variable></radiobutton>"
  272. done
  273. if [ "$SDIMAGEBUTTONS" != "" ];then
  274. export SDIMAGE_DIALOG="<window title=\"SD Image Downloader: choose file\" icon-name=\"gtk-about\" window_position=\"1\">
  275. <vbox>
  276. <text><label>These are already downloaded:</label></text>
  277. <text><label>\"${ALREADYDOWN}\"</label></text>
  278. <text><label>Please choose an SD-image file that you would like to download (Click Cancel button to not download any):</label></text>
  279. <frame>
  280. ${SDIMAGEBUTTONS}
  281. </frame>
  282. <hbox>
  283. <button ok></button>
  284. <button cancel></button>
  285. </hbox>
  286. </vbox>
  287. </window>"
  288. while [ 1 ];do
  289. RETPARAMS="`gtkdialog3 --program=SDIMAGE_DIALOG`"
  290. SDIMAGE_FILE=''
  291. [ "`echo "$RETPARAMS" | grep '^EXIT' | grep 'OK'`" != "" ] && SDIMAGE_FILE="`echo "$RETPARAMS" | grep 'RADIO_URL_' | grep '"true"' | cut -f 1 -d '=' | cut -f 3-9 -d '_'`"
  292. if [ "$SDIMAGE_FILE" ];then
  293. cd sd-skeleton-images
  294. wget -4 http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/$SDIMAGE_FILE
  295. sync
  296. wget -4 http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/${SDIMAGE_FILE}.md5.txt
  297. sync
  298. cd ..
  299. echo "...${SDIMAGE_FILE} downloaded to folder sd-skeleton-images"
  300. if [ -s ${SDIMAGE_FILE}.md5.txt ];then
  301. CORRECTMD5="`cat ${SDIMAGE_FILE}.md5.txt | cut -f 1 -d ' '`"
  302. DLMD5="`md5sum ${SDIMAGE_FILE} | cut -f 1 -d ' '`"
  303. if [ "$CORRECTMD5" != "$DLMD5" ];then
  304. echo "...however, the md5sum is incorrect. Deleting downloaded file..."
  305. rm -f $SDIMAGE_FILE
  306. echo -n "Press ENTER only to continue script, any other key to try download again..."
  307. read tryagain
  308. [ "$tryagain" != "" ] && continue
  309. fi
  310. fi
  311. fi
  312. break
  313. done
  314. fi
  315. fi
  316. fi
  317. ##################################
  318. #110817 new script to find all pkgs for build...
  319. ./support/findpkgs
  320. #...returns file status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  321. # each line is full db entry for pkg, prefixed with :generic-name:, pet/compat and repo-filename.
  322. # 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||
  323. if [ $? -ne 0 ];then
  324. echo
  325. echo "ERROR: Script support/findpkgs aborted with an error, exiting."
  326. exit 1
  327. fi
  328. if [ ! -f status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  329. echo
  330. echo "ERROR: Something went wrong with support/findpkgs, exiting."
  331. exit 1
  332. fi
  333. echo
  334. echo "Downloading packages..."
  335. LINECNT=1
  336. cat status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} |
  337. while read ONEDBENTRY
  338. do
  339. #120812 optional subcategory...
  340. #ONEDBENTRY=:GENERICNAME:|PETorCOMPAT|DBFILE|pkgname|nameonly|version|pkgrelease|category[;subcategory]|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  341. #...pkgname onwards is the full db entry for a package.
  342. LINECNT=$(($LINECNT + 1))
  343. PETorCOMPAT="`echo -n "$ONEDBENTRY" | cut -f 2 -d '|'`" #ex: compat
  344. if [ "$PETorCOMPAT" != "pet" -a "$PETorCOMPAT" != "compat" ];then
  345. echo
  346. echo "Syntax ERROR in status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION},"
  347. echo "line number ${LINECNT}:"
  348. echo "$ONEDBENTRY"
  349. echo -n "Ignoring this line, press ENTER to continue (CTRL-C to abort): "
  350. read KEEPITGOING
  351. continue
  352. fi
  353. DBFILE="`echo -n "$ONEDBENTRY" | cut -f 3 -d '|'`" #ex: Packages-puppy-5-official
  354. DB_pkgname="`echo -n "$ONEDBENTRY" | cut -f 4 -d '|'`" #ex: abiword-2.3.4-w5
  355. DB_fullfilename="`echo -n "$ONEDBENTRY" | cut -f 11 -d '|'`" #ex: abiword-2.3.4-w5.pet
  356. DB_path="`echo -n "$ONEDBENTRY" | cut -f 10 -d '|'`" #ex: pet_packages-5
  357. if [ ! "$DB_path" ];then
  358. ONLINESUBDIR="`echo -n "$DBFILE" | cut -f 3 -d '-'`" #ex: 5
  359. if [ "$PETorCOMPAT" = "pet" ];then #120515
  360. DB_path="pet_packages-${ONLINESUBDIR}"
  361. else
  362. DB_path="compat_packages-${ONLINESUBDIR}"
  363. fi
  364. fi
  365. echo -n "$DB_fullfilename "
  366. if [ "$PETorCOMPAT" = "pet" ];then
  367. #see if pkg already downloaded...
  368. PETPKG="`basename $DB_fullfilename .pet`"
  369. [ -f packages-pet/${PETPKG}.pet ] && continue
  370. echo "Downloading ${DB_fullfilename}..."
  371. SUCCESS='no'
  372. for ONE_PET_URL in $PET_URLS
  373. do
  374. wget --spider --tries=1 --timeout=30 ${ONE_PET_URL}/${DB_path}/${PETPKG}.pet #w013 was 20
  375. [ $? -ne 0 ] && continue
  376. cd packages-pet
  377. #rxvt -name pet -bg orange -geometry 80x10 -e wget ${ONE_PET_URL}/${DB_path}/${PETPKG}.pet
  378. wget ${ONE_PET_URL}/${DB_path}/${PETPKG}.pet
  379. sync
  380. #check file downloaded correctly...
  381. if [ -f ${PETPKG}.pet ];then
  382. cp -f ${PETPKG}.pet tempfileonly.pet
  383. pet2tgz tempfileonly.pet
  384. [ $? -eq 0 ] && SUCCESS='yes'
  385. rm -f tempfileonly.pet 2>/dev/null
  386. rm -f tempfileonly.tar.gz 2>/dev/null
  387. [ "$SUCCESS" = "no" ] && rm -f ${PETPKG}.pet
  388. fi
  389. cd ..
  390. [ "$SUCCESS" = "yes" ] && break
  391. done
  392. #if fail to find it, log failure, request manual download.
  393. [ "$SUCCESS" = "no" ] && echo "DOWNLOAD FAIL: ${PETPKG}.pet"
  394. [ "$SUCCESS" = "no" ] && echo "${PETPKG}.pet" >> DOWNLOAD-FAILS-PET
  395. else #compat
  396. #check if already downloaded...
  397. [ -f packages-${BINARIES}/$DB_fullfilename ] && continue
  398. #arch is a bit awkward, as the pkg may or may not have '-i686' in the name...
  399. if [ "$DISTRO_BINARY_COMPAT" = "arch" ];then
  400. altDB_fullfilename="`echo -n "$DB_fullfilename" | sed -e 's%\-i686\.pkg%.pkg%'`"
  401. [ -f packages-${BINARIES}/$altDB_fullfilename ] && continue
  402. fi
  403. #...probably don't need this anymore ###NOTE###
  404. #use wget to see if pkg on a repository, if not try a secondary repo, then a third.
  405. #if found, download to packages-${BINARIES} (packages-deb).
  406. #if fail, log failure, request manual download.
  407. SUCCESS='no'
  408. ONEFILE="${DB_path}/${DB_fullfilename}"
  409. for ONE_BIN_URL in $BIN_URLS
  410. do
  411. wget --spider --tries=1 --timeout=20 ${ONE_BIN_URL}/${ONEFILE} > /dev/null 2>&1
  412. RETSPIDER=$?
  413. if [ "$DISTRO_BINARY_COMPAT" = "arch" -a $RETSPIDER -ne 0 ];then #pkg naming inconsistency problem.
  414. altONEFILE="`echo -n "$ONEFILE" | sed -e 's%\-i686\.pkg%.pkg%'`"
  415. wget --spider --tries=1 --timeout=20 ${ONE_BIN_URL}/${altONEFILE} > /dev/null 2>&1
  416. RETSPIDER=$?
  417. if [ $RETSPIDER -eq 0 ];then
  418. ONEFILE="$altONEFILE"
  419. DB_fullfilename="$altDB_fullfilename"
  420. fi
  421. fi
  422. #...probably don't need this anymore ###NOTE###
  423. [ $RETSPIDER -ne 0 ] && continue
  424. cd packages-${BINARIES}
  425. #rxvt -name pet -bg orange -geometry 80x10 -e wget ${ONE_BIN_URL}/${ONEFILE}
  426. wget ${ONE_BIN_URL}/${ONEFILE}
  427. sync
  428. #check file downloaded correctly...
  429. if [ -f $DB_fullfilename ];then
  430. case $DISTRO_BINARY_COMPAT in #exs: ubuntu, debian
  431. ubuntu|trisquel|debian|devuan|raspbian)
  432. dpkg-deb --extract $DB_fullfilename tempdironly
  433. [ $? -eq 0 ] && SUCCESS='yes'
  434. ;;
  435. arch)
  436. xz --test $DB_fullfilename > /dev/null 2>&1
  437. if [ $? -eq 0 ];then
  438. SUCCESS='yes'
  439. else
  440. gzip --test $DB_fullfilename > /dev/null 2>&1
  441. [ $? -eq 0 ] && SUCCESS='yes'
  442. fi
  443. ;;
  444. slackware*) #100617 support .txz... #140716 support 64 bit
  445. xz --test $DB_fullfilename > /dev/null 2>&1
  446. if [ $? -eq 0 ];then
  447. SUCCESS='yes'
  448. else
  449. gzip --test $DB_fullfilename > /dev/null 2>&1
  450. [ $? -eq 0 ] && SUCCESS='yes'
  451. fi
  452. ;;
  453. puppy) #w017
  454. PETPKG="`basename $DB_fullfilename .pet`"
  455. cp -f ${PETPKG}.pet tempfileonly.pet
  456. pet2tgz tempfileonly.pet
  457. [ $? -eq 0 ] && SUCCESS='yes'
  458. rm -f tempfileonly.pet 2>/dev/null
  459. rm -f tempfileonly.tar.gz 2>/dev/null
  460. ;;
  461. t2)
  462. bzip2 --test $DB_fullfilename > /dev/null 2>&1
  463. [ $? -eq 0 ] && SUCCESS='yes'
  464. ;;
  465. scientific|mageia) #110523 Iguleder. 110615
  466. busybox rpm -qpl $DB_fullfilename > /dev/null 2>&1
  467. [ $? -eq 0 ] && SUCCESS='yes'
  468. ;;
  469. gentoo) #120515
  470. bzip2 --test $DB_fullfilename > /dev/null 2>&1
  471. [ $? -eq 0 ] && SUCCESS='yes'
  472. ;;
  473. esac
  474. fi
  475. rm -rf tempdironly 2>/dev/null
  476. [ "$SUCCESS" = "no" ] && rm -f ${DB_fullfilename} 2>/dev/null
  477. cd ..
  478. [ "$SUCCESS" = "yes" ] && break
  479. done
  480. #if failed to find it, log failure, request manual download...
  481. [ "$SUCCESS" = "no" ] && echo "$DB_fullfilename" >> DOWNLOAD-FAILS-${BINARIES}
  482. fi #end if PETorCOMPAT
  483. #check controlpanel, whether need to pause, resume or quit...
  484. CP_STATUS_REQ="`cat /tmp/1download-status-request`" #Run, Pause, Resume, Quit
  485. pausecnt=0; PIDCP=0
  486. while [ "$CP_STATUS_REQ" = "Pause" ];do
  487. #echo "Status: paused ${pausecnt}seconds"
  488. if [ $PIDCP -eq 0 ];then
  489. yaf-splash -close never -placement top -bg orange -text "1download script is currently in paused state" &
  490. PIDCP=$!
  491. fi
  492. sleep 5
  493. pausecnt=`expr $pausecnt + 5`
  494. CP_STATUS_REQ="`cat /tmp/1download-status-request`"
  495. done
  496. [ $PIDCP -ne 0 ] && kill $PIDCP
  497. [ "$CP_STATUS_REQ" = "Quit" ] && break 2 #pipe into while above is a separate process, need '2' to break out.
  498. done
  499. if [ "$CP_STATUS_REQ" = "Quit" ];then
  500. sync
  501. kill `cat /tmp/1download_controlpanel_pid` #1download_controlpanel
  502. rm -f /tmp/1download_controlpanel_pid
  503. echo
  504. echo "1download aborted."
  505. echo -n "Press ENTER key to quit script: "
  506. read yesgetout
  507. exit
  508. fi
  509. ############################
  510. sync
  511. kill `cat /tmp/1download_controlpanel_pid` #1download_controlpanel
  512. rm -f /tmp/1download_controlpanel_pid
  513. echo
  514. echo
  515. echo "Finished."
  516. echo -n "Press ENTER key to quit script: "
  517. read yesgetout
  518. ###END###