1download 21 KB

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