1download 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  64. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_xz-${DISTRO_COMPAT_VERSION}. 130306
  65. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  66. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  67. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  68. [ "$DISTRO_BINARY_COMPAT" = "gentoo" ] && BINARIES="gentoo" #120515 download to packages-gentoo-gap6
  69. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  70. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  71. mkdir -p packages-${BINARIES}
  72. mkdir -p packages-pet
  73. #find out what pet repos are working...
  74. echo "Finding what PET repos are working..."
  75. PET_URLS=""
  76. for ONE_PET_REPO in $PET_REPOS
  77. do
  78. ONE_PET_SITE="`echo -n "$ONE_PET_REPO" | cut -f 1 -d '|'`"
  79. ONE_PET_URL="`echo -n "$ONE_PET_REPO" | cut -f 2 -d '|'`"
  80. #w013 changed timeout from 20 to 30 seconds...
  81. #if wget -t 2 -T 20 --waitretry=20 --spider -S $ONE_PET_SITE -o /dev/stdout | grep '200 OK'
  82. if [ "`wget -t 2 -T 30 --waitretry=20 --spider -S $ONE_PET_SITE -o /dev/stdout 2>/dev/null | grep '200 OK'`" != "" ];then
  83. echo "Okay: $ONE_PET_URL"
  84. PET_URLS="$PET_URLS$ONE_PET_URL " #success.
  85. fi
  86. done
  87. if [ "$PET_URLS" = "" ];then
  88. echo "Failure. Is Internet working?"
  89. echo -n "Press ENTER key to quit script: "
  90. read yesgetout
  91. exit
  92. fi
  93. echo "Finding what $BINARIES repos are working..."
  94. BIN_URLS=""
  95. for ONE_BIN_REPO in $REPOS_DISTRO_COMPAT #from DISTRO_PKGS_SPECS-$DISTRO_BINARY_COMPAT.
  96. do
  97. ONE_BIN_SITE="`echo -n "$ONE_BIN_REPO" | cut -f 1 -d '|'`"
  98. ONE_BIN_URL="`echo -n "$ONE_BIN_REPO" | cut -f 2 -d '|'`"
  99. #w013 ditto...
  100. if [ "`wget -t 2 -T 30 --waitretry=20 --spider -S $ONE_BIN_SITE -o /dev/stdout 2>/dev/null | grep '200 OK'`" != "" ];then
  101. echo "Okay: $ONE_BIN_URL"
  102. BIN_URLS="$BIN_URLS$ONE_BIN_URL " #success.
  103. fi
  104. done
  105. if [ "$BIN_URLS" = "" ];then
  106. echo "Failure. Is Internet working?"
  107. echo -n "Press ENTER key to quit script: "
  108. read yesgetout
  109. exit
  110. fi
  111. rm -f DOWNLOAD-FAILS-PET 2>/dev/null
  112. rm -f DOWNLOAD-FAILS-${BINARIES} 2>/dev/null
  113. rm -f DOWNLOAD-ERRORS
  114. #start the gui controlpanel...
  115. echo 'Run' > /tmp/1download-status-request
  116. ./support/1download_controlpanel &
  117. ######################
  118. #110823 moved downloading kernels PETs up here.
  119. #download all the linux kernel pkgs from pet repo...
  120. echo
  121. echo "Downloading Linux kernel packages..."
  122. for PKGLISTFILE in $PACKAGELISTS_PET_PRIMARY $PACKAGELISTS_PET_2NDARCH #$PACKAGELISTS_PET_SECOND #$PACKAGELISTS_PET_THIRD #110616
  123. do
  124. SUBDIRTRAIL="`echo -n "$PKGLISTFILE" | cut -f 3 -d '-'`" #ex: common
  125. SPEC_LINUXKERNELS="`cat $PKGLISTFILE | grep '^linux_kernel\-' | cut -f 2-99 -d ':' | cut -f 7,8 -d '|' | tr '\n' ' '`"
  126. for SPEC_ONEKERNEL in $SPEC_LINUXKERNELS
  127. do
  128. ONEKERNEL="`echo -n "$SPEC_ONEKERNEL" | cut -f 2 -d '|'`"
  129. ONEKERNEL="`basename $ONEKERNEL .pet`"
  130. PATHKERNEL="`echo -n "$SPEC_ONEKERNEL" | cut -f 1 -d '|'`"
  131. [ "$PATHKERNEL" = "" ] && PATHKERNEL="pet_packages-${SUBDIRTRAIL}" #110616
  132. SUCCESS="no"
  133. [ -f packages-pet/${ONEKERNEL}.pet ] && continue
  134. for ONE_PET_URL in $PET_URLS
  135. do
  136. wget --spider --tries=1 --timeout=20 ${ONE_PET_URL}/${PATHKERNEL}/${ONEKERNEL}.pet
  137. [ $? -ne 0 ] && continue
  138. cd packages-pet
  139. wget ${ONE_PET_URL}/${PATHKERNEL}/${ONEKERNEL}.pet
  140. sync
  141. #check file downloaded correctly...
  142. if [ -f ${ONEKERNEL}.pet ];then
  143. cp -f ${ONEKERNEL}.pet tempfileonly.pet
  144. pet2tgz tempfileonly.pet
  145. [ $? -eq 0 ] && SUCCESS='yes'
  146. rm -f tempfileonly.pet 2>/dev/null
  147. rm -f tempfileonly.tar.gz 2>/dev/null
  148. [ "$SUCCESS" = "no" ] && rm -f ${ONEKERNEL}.pet
  149. fi
  150. cd ..
  151. #check controlpanel, whether need to pause, resume or quit...
  152. CP_STATUS_REQ="`cat /tmp/1download-status-request`" #Run, Pause, Resume, Quit
  153. pausecnt=0; PIDCP=0
  154. while [ "$CP_STATUS_REQ" = "Pause" ];do
  155. #echo "Status: paused ${pausecnt}seconds"
  156. if [ $PIDCP -eq 0 ];then
  157. yaf-splash -close never -placement top -bg orange -text "1download script is currently in paused state" &
  158. PIDCP=$!
  159. fi
  160. sleep 5
  161. pausecnt=`expr $pausecnt + 5`
  162. CP_STATUS_REQ="`cat /tmp/1download-status-request`"
  163. done
  164. [ $PIDCP -ne 0 ] && kill $PIDCP
  165. if [ "$CP_STATUS_REQ" = "Quit" ];then
  166. sync
  167. kill `cat /tmp/1download_controlpanel_pid` #1download_controlpanel
  168. rm -f /tmp/1download_controlpanel_pid
  169. echo
  170. echo "1download aborted."
  171. echo -n "Press ENTER key to quit script: "
  172. read yesgetout
  173. exit
  174. fi
  175. [ "$SUCCESS" = "yes" ] && continue 2
  176. done
  177. echo "Failed to download ${ONEKERNEL}.pet."
  178. done
  179. done
  180. ####choose kernel####
  181. KERNELPKG="$DISTRO_KERNEL_PET"
  182. if [ -f packages-pet/$DISTRO_KERNEL_PET ];then
  183. KMSG="This package exists in directory packages-pet, so ok. But you can change
  184. it now if you wish."
  185. KOK=''
  186. else
  187. KMSG="This package does not exist in directory packages-pet, so you cannot use it.
  188. You must choose a linux kernel PET package from those available."
  189. KOK='no'
  190. fi
  191. echo
  192. echo "The kernel to be used is specified in variable DISTRO_KERNEL_PET in file"
  193. echo "DISTRO_SPECS. Currently DISTRO_KERNEL_PET=${DISTRO_KERNEL_PET}"
  194. echo "$KMSG"
  195. if [ "$KOK" = "" ];then
  196. echo -n "Press ENTER only to use this kernel, press any other char to change: "
  197. read KOK
  198. fi
  199. if [ "$KOK" ];then
  200. CNTLOOP=1
  201. AVAILKERNELS="`ls -1 packages-pet/linux_kernel-*.pet`"
  202. [ "$AVAILKERNELS" = "" ] && echo 'No linux_kernel pkgs avail in packages-pet. Press CTRL-C.'
  203. for ONEKERNEL in $AVAILKERNELS
  204. do
  205. echo "$CNTLOOP $ONEKERNEL"
  206. CNTLOOP=`expr $CNTLOOP + 1`
  207. done
  208. echo
  209. echo -n 'Type number for kernel you want to use [1]: '
  210. read numkernel
  211. [ "$numkernel" = "" ] && numkernel=1
  212. KERNELPKG="`echo "$AVAILKERNELS" | head -n $numkernel | tail -n 1 | rev | cut -f 1 -d '/' | rev`"
  213. fi
  214. if [ "$KERNELPKG" != "$DISTRO_KERNEL_PET" ];then
  215. dkpPATTERN="s%^DISTRO_KERNEL_PET.*%DISTRO_KERNEL_PET='${KERNELPKG}'%"
  216. sed -i -e "$dkpPATTERN" ./DISTRO_SPECS
  217. echo "...DISTRO_SPECS now set to use $KERNELPKG"
  218. fi
  219. ##################################
  220. #120501 support arm build, download sd images...
  221. if [ "$DISTRO_TARGETARCH" = "arm" ];then
  222. mkdir -p sd-skeleton-images
  223. echo
  224. echo 'Please wait, probing for online SD skeleton image files...'
  225. 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
  226. sync
  227. if [ ! -s /tmp/1download-sd-images-probe ];then
  228. echo 'Sorry, could not access any SD images at http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/'
  229. echo 'Press ENTER to continue script regardless: '
  230. read keepgoing
  231. [ "$keepgoing" != "" ] && exit
  232. else
  233. #ask which sd-image to download...
  234. ALREADYDOWN="`ls -1 sd-skeleton-images | grep 'xz$'`"
  235. [ "$ALREADYDOWN" = "" ] && ALREADYDOWN='none'
  236. SDIMAGEBUTTONS=''
  237. for ONESDIMAGE in `cat /tmp/1download-sd-images-probe | sort -u | tr '\n' ' '`
  238. do
  239. #SDIMAGENAME="`basename $ONESDIMAGE .xz`"
  240. [ -f sd-skeleton-images/$ONESDIMAGE ] && continue #already downloaded.
  241. SDIMAGEBUTTONS="${SDIMAGEBUTTONS}<radiobutton><label>${ONESDIMAGE}</label><variable>RADIO_URL_${ONESDIMAGE}</variable></radiobutton>"
  242. done
  243. if [ "$SDIMAGEBUTTONS" != "" ];then
  244. export SDIMAGE_DIALOG="<window title=\"SD Image Downloader: choose file\" icon-name=\"gtk-about\" window_position=\"1\">
  245. <vbox>
  246. <text><label>These are already downloaded:</label></text>
  247. <text><label>\"${ALREADYDOWN}\"</label></text>
  248. <text><label>Please choose an SD-image file that you would like to download (Click Cancel button to not download any):</label></text>
  249. <frame>
  250. ${SDIMAGEBUTTONS}
  251. </frame>
  252. <hbox>
  253. <button ok></button>
  254. <button cancel></button>
  255. </hbox>
  256. </vbox>
  257. </window>"
  258. while [ 1 ];do
  259. RETPARAMS="`gtkdialog3 --program=SDIMAGE_DIALOG`"
  260. SDIMAGE_FILE=''
  261. [ "`echo "$RETPARAMS" | grep '^EXIT' | grep 'OK'`" != "" ] && SDIMAGE_FILE="`echo "$RETPARAMS" | grep 'RADIO_URL_' | grep '"true"' | cut -f 1 -d '=' | cut -f 3-9 -d '_'`"
  262. if [ "$SDIMAGE_FILE" ];then
  263. cd sd-skeleton-images
  264. wget -4 http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/$SDIMAGE_FILE
  265. sync
  266. wget -4 http://distro.ibiblio.org/quirky/arm/sd-skeleton-images/${SDIMAGE_FILE}.md5.txt
  267. sync
  268. cd ..
  269. echo "...${SDIMAGE_FILE} downloaded to folder sd-skeleton-images"
  270. if [ -s ${SDIMAGE_FILE}.md5.txt ];then
  271. CORRECTMD5="`cat ${SDIMAGE_FILE}.md5.txt | cut -f 1 -d ' '`"
  272. DLMD5="`md5sum ${SDIMAGE_FILE} | cut -f 1 -d ' '`"
  273. if [ "$CORRECTMD5" != "$DLMD5" ];then
  274. echo "...however, the md5sum is incorrect. Deleting downloaded file..."
  275. rm -f $SDIMAGE_FILE
  276. echo -n "Press ENTER only to continue script, any other key to try download again..."
  277. read tryagain
  278. [ "$tryagain" != "" ] && continue
  279. fi
  280. fi
  281. fi
  282. break
  283. done
  284. fi
  285. fi
  286. fi
  287. ##################################
  288. #110817 new script to find all pkgs for build...
  289. ./support/findpkgs
  290. #...returns file status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  291. # each line is full db entry for pkg, prefixed with :generic-name:, pet/compat and repo-filename.
  292. # 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||
  293. if [ $? -ne 0 ];then
  294. echo
  295. echo "ERROR: Script support/findpkgs aborted with an error, exiting."
  296. exit 1
  297. fi
  298. if [ ! -f status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  299. echo
  300. echo "ERROR: Something went wrong with support/findpkgs, exiting."
  301. exit 1
  302. fi
  303. echo
  304. echo "Downloading packages..."
  305. LINECNT=1
  306. cat status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} |
  307. while read ONEDBENTRY
  308. do
  309. #120812 optional subcategory...
  310. #ONEDBENTRY=:GENERICNAME:|PETorCOMPAT|DBFILE|pkgname|nameonly|version|pkgrelease|category[;subcategory]|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  311. #...pkgname onwards is the full db entry for a package.
  312. LINECNT=$(($LINECNT + 1))
  313. PETorCOMPAT="`echo -n "$ONEDBENTRY" | cut -f 2 -d '|'`" #ex: compat
  314. if [ "$PETorCOMPAT" != "pet" -a "$PETorCOMPAT" != "compat" ];then
  315. echo
  316. echo "Syntax ERROR in status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION},"
  317. echo "line number ${LINECNT}:"
  318. echo "$ONEDBENTRY"
  319. echo -n "Ignoring this line, press ENTER to continue (CTRL-C to abort): "
  320. read KEEPITGOING
  321. continue
  322. fi
  323. DBFILE="`echo -n "$ONEDBENTRY" | cut -f 3 -d '|'`" #ex: Packages-puppy-5-official
  324. DB_pkgname="`echo -n "$ONEDBENTRY" | cut -f 4 -d '|'`" #ex: abiword-2.3.4-w5
  325. DB_fullfilename="`echo -n "$ONEDBENTRY" | cut -f 11 -d '|'`" #ex: abiword-2.3.4-w5.pet
  326. DB_path="`echo -n "$ONEDBENTRY" | cut -f 10 -d '|'`" #ex: pet_packages-5
  327. if [ ! "$DB_path" ];then
  328. ONLINESUBDIR="`echo -n "$DBFILE" | cut -f 3 -d '-'`" #ex: 5
  329. if [ "$PETorCOMPAT" = "pet" ];then #120515
  330. DB_path="pet_packages-${ONLINESUBDIR}"
  331. else
  332. DB_path="compat_packages-${ONLINESUBDIR}"
  333. fi
  334. fi
  335. echo -n "$DB_fullfilename "
  336. if [ "$PETorCOMPAT" = "pet" ];then
  337. #see if pkg already downloaded...
  338. PETPKG="`basename $DB_fullfilename .pet`"
  339. [ -f packages-pet/${PETPKG}.pet ] && continue
  340. echo "Downloading ${DB_fullfilename}..."
  341. SUCCESS='no'
  342. for ONE_PET_URL in $PET_URLS
  343. do
  344. wget --spider --tries=1 --timeout=30 ${ONE_PET_URL}/${DB_path}/${PETPKG}.pet #w013 was 20
  345. [ $? -ne 0 ] && continue
  346. cd packages-pet
  347. #rxvt -name pet -bg orange -geometry 80x10 -e wget ${ONE_PET_URL}/${DB_path}/${PETPKG}.pet
  348. wget ${ONE_PET_URL}/${DB_path}/${PETPKG}.pet
  349. sync
  350. #check file downloaded correctly...
  351. if [ -f ${PETPKG}.pet ];then
  352. cp -f ${PETPKG}.pet tempfileonly.pet
  353. pet2tgz tempfileonly.pet
  354. [ $? -eq 0 ] && SUCCESS='yes'
  355. rm -f tempfileonly.pet 2>/dev/null
  356. rm -f tempfileonly.tar.gz 2>/dev/null
  357. [ "$SUCCESS" = "no" ] && rm -f ${PETPKG}.pet
  358. fi
  359. cd ..
  360. [ "$SUCCESS" = "yes" ] && break
  361. done
  362. #if fail to find it, log failure, request manual download.
  363. [ "$SUCCESS" = "no" ] && echo "DOWNLOAD FAIL: ${PETPKG}.pet"
  364. [ "$SUCCESS" = "no" ] && echo "${PETPKG}.pet" >> DOWNLOAD-FAILS-PET
  365. else #compat
  366. #check if already downloaded...
  367. [ -f packages-${BINARIES}/$DB_fullfilename ] && continue
  368. #arch is a bit awkward, as the pkg may or may not have '-i686' in the name...
  369. if [ "$DISTRO_BINARY_COMPAT" = "arch" ];then
  370. altDB_fullfilename="`echo -n "$DB_fullfilename" | sed -e 's%\-i686\.pkg%.pkg%'`"
  371. [ -f packages-${BINARIES}/$altDB_fullfilename ] && continue
  372. fi
  373. #...probably don't need this anymore ###NOTE###
  374. #use wget to see if pkg on a repository, if not try a secondary repo, then a third.
  375. #if found, download to packages-${BINARIES} (packages-deb).
  376. #if fail, log failure, request manual download.
  377. SUCCESS='no'
  378. ONEFILE="${DB_path}/${DB_fullfilename}"
  379. for ONE_BIN_URL in $BIN_URLS
  380. do
  381. wget --spider --tries=1 --timeout=20 ${ONE_BIN_URL}/${ONEFILE} > /dev/null 2>&1
  382. RETSPIDER=$?
  383. if [ "$DISTRO_BINARY_COMPAT" = "arch" -a $RETSPIDER -ne 0 ];then #pkg naming inconsistency problem.
  384. altONEFILE="`echo -n "$ONEFILE" | sed -e 's%\-i686\.pkg%.pkg%'`"
  385. wget --spider --tries=1 --timeout=20 ${ONE_BIN_URL}/${altONEFILE} > /dev/null 2>&1
  386. RETSPIDER=$?
  387. if [ $RETSPIDER -eq 0 ];then
  388. ONEFILE="$altONEFILE"
  389. DB_fullfilename="$altDB_fullfilename"
  390. fi
  391. fi
  392. #...probably don't need this anymore ###NOTE###
  393. [ $RETSPIDER -ne 0 ] && continue
  394. cd packages-${BINARIES}
  395. #rxvt -name pet -bg orange -geometry 80x10 -e wget ${ONE_BIN_URL}/${ONEFILE}
  396. wget ${ONE_BIN_URL}/${ONEFILE}
  397. sync
  398. #check file downloaded correctly...
  399. if [ -f $DB_fullfilename ];then
  400. case $DISTRO_BINARY_COMPAT in #exs: ubuntu, debian
  401. ubuntu|debian|raspbian)
  402. dpkg-deb --extract $DB_fullfilename tempdironly
  403. [ $? -eq 0 ] && SUCCESS='yes'
  404. ;;
  405. arch)
  406. xz --test $DB_fullfilename > /dev/null 2>&1
  407. if [ $? -eq 0 ];then
  408. SUCCESS='yes'
  409. else
  410. gzip --test $DB_fullfilename > /dev/null 2>&1
  411. [ $? -eq 0 ] && SUCCESS='yes'
  412. fi
  413. ;;
  414. slackware) #100617 support .txz...
  415. xz --test $DB_fullfilename > /dev/null 2>&1
  416. if [ $? -eq 0 ];then
  417. SUCCESS='yes'
  418. else
  419. gzip --test $DB_fullfilename > /dev/null 2>&1
  420. [ $? -eq 0 ] && SUCCESS='yes'
  421. fi
  422. ;;
  423. puppy) #w017
  424. PETPKG="`basename $DB_fullfilename .pet`"
  425. cp -f ${PETPKG}.pet tempfileonly.pet
  426. pet2tgz tempfileonly.pet
  427. [ $? -eq 0 ] && SUCCESS='yes'
  428. rm -f tempfileonly.pet 2>/dev/null
  429. rm -f tempfileonly.tar.gz 2>/dev/null
  430. ;;
  431. t2)
  432. bzip2 --test $DB_fullfilename > /dev/null 2>&1
  433. [ $? -eq 0 ] && SUCCESS='yes'
  434. ;;
  435. scientific|mageia) #110523 Iguleder. 110615
  436. busybox rpm -qpl $DB_fullfilename > /dev/null 2>&1
  437. [ $? -eq 0 ] && SUCCESS='yes'
  438. ;;
  439. gentoo) #120515
  440. bzip2 --test $DB_fullfilename > /dev/null 2>&1
  441. [ $? -eq 0 ] && SUCCESS='yes'
  442. ;;
  443. esac
  444. fi
  445. rm -rf tempdironly 2>/dev/null
  446. [ "$SUCCESS" = "no" ] && rm -f ${DB_fullfilename} 2>/dev/null
  447. cd ..
  448. [ "$SUCCESS" = "yes" ] && break
  449. done
  450. #if failed to find it, log failure, request manual download...
  451. [ "$SUCCESS" = "no" ] && echo "$DB_fullfilename" >> DOWNLOAD-FAILS-${BINARIES}
  452. fi #end if PETorCOMPAT
  453. #check controlpanel, whether need to pause, resume or quit...
  454. CP_STATUS_REQ="`cat /tmp/1download-status-request`" #Run, Pause, Resume, Quit
  455. pausecnt=0; PIDCP=0
  456. while [ "$CP_STATUS_REQ" = "Pause" ];do
  457. #echo "Status: paused ${pausecnt}seconds"
  458. if [ $PIDCP -eq 0 ];then
  459. yaf-splash -close never -placement top -bg orange -text "1download script is currently in paused state" &
  460. PIDCP=$!
  461. fi
  462. sleep 5
  463. pausecnt=`expr $pausecnt + 5`
  464. CP_STATUS_REQ="`cat /tmp/1download-status-request`"
  465. done
  466. [ $PIDCP -ne 0 ] && kill $PIDCP
  467. [ "$CP_STATUS_REQ" = "Quit" ] && break 2 #pipe into while above is a separate process, need '2' to break out.
  468. done
  469. if [ "$CP_STATUS_REQ" = "Quit" ];then
  470. sync
  471. kill `cat /tmp/1download_controlpanel_pid` #1download_controlpanel
  472. rm -f /tmp/1download_controlpanel_pid
  473. echo
  474. echo "1download aborted."
  475. echo -n "Press ENTER key to quit script: "
  476. read yesgetout
  477. exit
  478. fi
  479. ############################
  480. sync
  481. kill `cat /tmp/1download_controlpanel_pid` #1download_controlpanel
  482. rm -f /tmp/1download_controlpanel_pid
  483. echo
  484. echo
  485. echo "Finished."
  486. echo -n "Press ENTER key to quit script: "
  487. read yesgetout
  488. ###END###