2createpackages 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2009.
  3. #grab binary ubuntu/debian/slackware packages and build puppy packages.
  4. #each binary package is expanded in sandbox2/ then copied as split pkgs
  5. #to packages-$DISTRO_FILE_PREFIX/, into the "generic name". Note that one generic
  6. #name can have one or more binary pkgs.
  7. #Note, DISTRO_FILE_PREFIX is specified in DISTRO_SPECS file.
  8. #100617 add support for slackware .txz pkgs.
  9. #100622 hack for pet search.
  10. #100723 create /var/cache/woof/2createpackages_4_compat2pets-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  11. #100801 some common code extracted to support/inline_pet_get.
  12. #100820 replace /var/cache/woof path with /var/local/woof
  13. #110523 Iguleder: support Scientific Linux rpm pkgs.
  14. #110615 support mageia
  15. #110616 remove trailing comments.
  16. #110618 rpm2cpio cannot handle mageia rpms, use 7z (see support/inline_get_compat).
  17. #110619 no, exploderpm handles mageia rpms, builtin to rootfs-skeleton/usr/sbin/exploderpm.
  18. #110723 test dotted-version compare utility in path.
  19. #110724 optional execute support/1buildversiondeps. 110820 removed.
  20. #110820 support/findpkgs is new script to find all pkgs to be used in Puppy build. Major changes!
  21. #110823 fix finding compat PETs in wary.
  22. #110830 fix if 3rd field specifies multiple pet pkgs.
  23. #111121 noryb009: improve arch linux support, patched: 0setup, 1download, 2createpackages, 3builddistro, DISTRO_COMPAT_REPOS-arch, support/arch/runDotInstalls
  24. #111127 no longer check if host has 'printcols', 'vercmp', it is done in 'merge2out' script.
  25. #111204 do not use /var/local/woof, instead 'status' directory (better for running from different save-files).
  26. #111204 do not execute post-install script if FIXUPHACK has DISABLE_POST_INSTALL_SCRIPT=yes. (this existed before, but was broken)
  27. #111207 improve searching for menu icon.
  28. #111210 01micko: FIXUPHACK wasn't copied to packages/$(DISTRO_FILE_PREFIX}/$GENERICNAME/
  29. #120316 problems with ubuntu multiarch. also see 120315 in 3builddistro.
  30. #120502 do not strip if a cross-build.
  31. #120515 build from "gentoo" binary tarballs (refer support/gentoo).
  32. #120517 export DISTRO_BINARY_COMPAT so can reference in FIXUPHACK scripts.
  33. #120628 fix Categories= assignment in .desktop files. see also usr/local/petget/installpkg.sh.
  34. #120719 support raspbian.
  35. #120720 raspbian wheezy has files in /lib/arm-linux-gnueabihf and /usr/lib/arm-linux-gnueabihf
  36. #120721 support ubuntu and debian arm multiarch.
  37. #120812 db category now allows optional subcategory (for which an icons exists in /usr/local/lib/X11/mini-icons).
  38. #120818 Categories management improved. pkg db now has category[;subcategory] (see 0setup), xdg enhanced (see /etc/xdg and /usr/share/desktop-directories), and generic icons for all subcategories (see /usr/local/lib/X11/mini-icons).
  39. #120824 UPKGVERSION variable is no longer used.
  40. #120909 support multiarch for /usr/bin.
  41. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  42. #121119 above may fail, as DB_category field may not match that in .desktop file, so leave out that $tPATTERN match in $PUPHIERARCHY.
  43. #121120 if only one .desktop file, first check if a match in /usr/local/petget/categories.dat (see also installpkg.sh).
  44. #121122 trying a generic fix for this weird problem (based on solution by zul): http://www.murga-linux.com/puppy/viewtopic.php?t=81773
  45. #121123 ...revert 121122. my thinking was incredibly fuzzy. the problem is with a full-installation, the /usr/lib/i386-linux-gnu is getting changed from symlink to a directory.
  46. #130111 proper handling of multiarch for mageia.
  47. #130112 multiarch symlinks now optional. see also 3builddistro, /usr/local/petget/installpkg.sh.
  48. #130114 revert 130112.
  49. #130219 categories.dat format changed slightly. see also /usr/local/petget/installpkg.sh.
  50. #130306 arch linux: gz now xz. maybe only 'DISTRO_COMPAT_REPOS-arch'.
  51. #130313 arch linux is relocating many files to /usr, providing symlinks, very annoying.
  52. #130421 export DISTRO_FILE_PREFIX, i want this in FIXUPHACK.
  53. #130510 support multiarch for debian wheezy.
  54. export LANG=C #faster.
  55. . /etc/xdg/menus/hierarchy #w478 has PUPHIERARCHY variable.
  56. . ./DISTRO_SPECS #has DISTRO_BINARY_COMPAT, DISTRO_COMPAT_VERSION
  57. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  58. export DISTRO_BINARY_COMPAT #120517 i want this in FIXUPHACK scripts.
  59. export DISTRO_FILE_PREFIX #130421 ditto.
  60. if [ -f ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  61. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  62. else
  63. . ./DISTRO_COMPAT_REPOS-${DISTRO_BINARY_COMPAT} #130306
  64. fi
  65. if [ -f ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then #w478
  66. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} #has FALLBACKS_COMPAT_VERSIONS
  67. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}"
  68. else
  69. . ./DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT} #has FALLBACKS_COMPAT_VERSIONS
  70. DPSFILE="DISTRO_PKGS_SPECS-${DISTRO_BINARY_COMPAT}"
  71. fi
  72. . ./DISTRO_PET_REPOS #has PET_REPOS, PACKAGELISTS_PET_ORDER
  73. if [ -f WOOFMERGEVARS ];then #120316
  74. . ./WOOFMERGEVARS #has variables WOOF_HOSTARCH, WOOF_TARGETARCH, WOOF_COMPATDISTRO, WOOF_COMPATVERSION
  75. else
  76. echo 'File WOOFMERGEVARS does not exist. This is created by script
  77. merge2out. Your setup is wrong, quiting.'
  78. exit
  79. fi
  80. #this is for ubuntu (Precise Pangolin) only so far... note, same code in 3builddistro
  81. ARCHDIR=''
  82. if [ "$WOOF_COMPATDISTRO" = "ubuntu" ];then
  83. case $WOOF_COMPATVERSION in
  84. jaunty|karmic|lucid) #old releases.
  85. true
  86. ;;
  87. *) #precise, raring, and later...
  88. case $WOOF_TARGETARCH in
  89. x86) ARCHDIR='i386-linux-gnu' ;;
  90. x86_64) ARCHDIR='x86_64-linux-gnu' ;;
  91. esac
  92. ;;
  93. esac
  94. fi
  95. if [ "$WOOF_COMPATDISTRO" = "debian" ];then #130510
  96. case $WOOF_COMPATVERSION in
  97. squeeze|lenny|etch|sarge|woody) #old releases.
  98. true
  99. ;;
  100. *) #wheezy and later...
  101. case $WOOF_TARGETARCH in
  102. x86) ARCHDIR='i386-linux-gnu' ;;
  103. x86_64) ARCHDIR='x86_64-linux-gnu' ;;
  104. esac
  105. ;;
  106. esac
  107. fi
  108. if [ "$WOOF_COMPATDISTRO" = "mageia" ];then #130111
  109. case $WOOF_TARGETARCH in
  110. x86) ARCHDIR='multiarch-i386-linux' ;;
  111. *) ARCHDIR=''; echo 'dunno'; exit ;;
  112. esac
  113. fi
  114. case $WOOF_TARGETARCH in #120720 120721
  115. arm)
  116. case $WOOF_COMPATDISTRO in #see file WOOFMERGEVARS
  117. raspbian) ARCHDIR='arm-linux-gnueabihf' ;; #different from debian/ubuntu, compiled for armv6 hf.
  118. debian)
  119. case $WOOF_COMPATVERSION in
  120. squeeze) true ;; #old release
  121. *) ARCHDIR='arm-linux-gnueabihf' ;;
  122. esac
  123. ;;
  124. ubuntu)
  125. case $WOOF_COMPATVERSION in
  126. jaunty|karmic|lucid) true ;; #old releases.
  127. *) ARCHDIR='arm-linux-gnueabihf' ;;
  128. esac
  129. ;;
  130. esac
  131. ;;
  132. esac
  133. #130114 revert 130112...
  134. ##130112 make multiarch symlinks optional...
  135. ##see also code in 3builddistro.
  136. #if [ "$ARCHDIR" ];then #ex: i386-linux-gnu
  137. # if [ "$DISTRO_ARCHDIR_SYMLINKS" = "" ];then #in /etc/DISTRO_SPECS
  138. # echo
  139. # echo "Woof-built puppies up until Dec 2012 have multiarch dirs as symlinks,
  140. #for example /usr/lib/i386-linux-gnu is a symlink to /usr/lib in Debian/Ubuntu
  141. #based pups. However, in future builds will by default retain the multiarch
  142. #sub-directories."
  143. # echo -n "ENTER only to retain multiarch dirs: "
  144. # read flagmultiarchdirs
  145. # if [ "$flagmultiarchdirs" = "" ];then
  146. # echo "DISTRO_ARCHDIR_SYMLINKS='no'" >> DISTRO_SPECS
  147. # DISTRO_ARCHDIR_SYMLINKS='no'
  148. # echo "...DISTRO_ARCHDIR_SYMLINKS='no' written to file DISTRO_SPECS"
  149. # else
  150. # echo "DISTRO_ARCHDIR_SYMLINKS='yes'" >> DISTRO_SPECS
  151. # DISTRO_ARCHDIR_SYMLINKS='yes'
  152. # echo "...DISTRO_ARCHDIR_SYMLINKS='yes' written to file DISTRO_SPECS"
  153. # fi
  154. # fi
  155. #fi
  156. #w469 modify compat-distro fallback list...
  157. if [ "$FALLBACKS_COMPAT_VERSIONS" != "" ];then
  158. FALLBACKS_COMPAT_VERSIONS="`echo -n "$FALLBACKS_COMPAT_VERSIONS" | grep -o "${DISTRO_COMPAT_VERSION}.*"`"
  159. #ex: 'koala jaunty intrepid' gets reduced to 'jaunty intrepid' if DISTRO_COMPAT_VERSION=jaunty
  160. fi
  161. BINARIES='deb' #get them from packages-deb.
  162. [ "$DISTRO_BINARY_COMPAT" = "t2" ] && BINARIES="bz2" #get them from packages-bz2-${DISTRO_COMPAT_VERSION}.
  163. [ "$DISTRO_BINARY_COMPAT" = "slackware" ] && BINARIES="tgz_txz" #100617 download to packages-tgz_txz-${DISTRO_COMPAT_VERSION}.
  164. [ "$DISTRO_BINARY_COMPAT" = "debian" ] && BINARIES="deb" #download to packages-deb-${DISTRO_COMPAT_VERSION}.
  165. [ "$DISTRO_BINARY_COMPAT" = "arch" ] && BINARIES="tar_xz" #download to packages-tar_xz-${DISTRO_COMPAT_VERSION}. 130306
  166. [ "$DISTRO_BINARY_COMPAT" = "puppy" ] && BINARIES="pet" #w018 built entirely from pet pkgs.
  167. [ "$DISTRO_BINARY_COMPAT" = "scientific" ] && BINARIES="rpm" #110523 Iguleder: download to packages-rpm-${DISTRO_COMPAT_VERSION}.
  168. [ "$DISTRO_BINARY_COMPAT" = "mageia" ] && BINARIES="rpm" #110615
  169. [ "$DISTRO_BINARY_COMPAT" = "gentoo" ] && BINARIES="gentoo" #120515 download to packages-gentoo-gap6
  170. [ "$DISTRO_BINARY_COMPAT" = "raspbian" ] && BINARIES="deb_raspbian" #download to packages-deb_raspbian-${DISTRO_COMPAT_VERSION}.
  171. BINARIES="${BINARIES}-${DISTRO_COMPAT_VERSION}" #w478
  172. #the files that have compatible-distro pkg docs (these were downloaded by 0setup)...
  173. echo "Preprocessing $DISTRO_BINARY_COMPAT $DISTRO_COMPAT_VERSION pkgs database..."
  174. PKGLISTS_COMPAT="`echo "$PKG_DOCS_DISTRO_COMPAT" | tr ' ' '\n' | cut -f 3 -d '|' | tr '\n' ' '`" #see file DISTRO_PKGS_SPECS-ubuntu
  175. #...format ex: 'Packages-ubuntu-intrepid-main packages-ubuntu-intrepid-universe'
  176. ###TODO###
  177. MY_LANG='en,en_US,en_AU' #if this specified, then any locale info will be placed in _EXE pkgs.
  178. CURRDIR="`pwd`"
  179. [ ! -d packages-templates ] && exit 1
  180. [ ! -d packages-${BINARIES} ] && exit 1
  181. #some information about template-packages:
  182. #any directory in the template, the files in the target pkg will be cut down to the same selection.
  183. #(even if empty dir). Exception, file named 'PLUSEXTRAFILES' then target will have all files from deb.
  184. # 0-size file, means get file of same name from deb (even if in different dir) to target.
  185. # non-zero file, means copy this file from template to target.
  186. # template files with '-FULL' suffix, rename target file also (exs: in coreutils, util-linux).
  187. #Any dir in template with 'PKGVERSION' in name, substitute actual pkg version number in target dir.
  188. #Except for /etc, /dev, /var, all dirs in target are deleted to only those in template, except
  189. # if file 'PLUSEXTRADIRS' is found in template.
  190. #As a last resort, if target pkg is wrong, a file 'FIXUPHACK' is a script that can be at top dir
  191. # in template. It executes in target, with current-dir set to where FIXUPHACK is located. (ex: perl_tiny).
  192. # Ran into problem slackware post-install scripts messing things up. See near bottom of this script
  193. # how damage is limited. Also DISABLE_POST_INSTALL_SCRIPT=yes in FIXUPHACK to disable entirely.
  194. #If a dir in template has files in it then target is cut down (unless PLUSEXTRAFILES present),
  195. # however there are some exceptions (such as .so regular files). To not allow any exceptions,
  196. # place NOEXCEPTIONFILES in the template dir (ex: glibc usr/lib/gconv).
  197. # I needed to finetune this some more -- example packages-templates/gettext/usr/lib, have
  198. # NOEXCEPTIONFILES, but do want all of libasfprint.so.* whatever the version numbers are,
  199. # so can now create zero-size file 'libasfprint.so.STARCHAR' to achieve this.
  200. #PKGS_SPECS_TABLE table fomat:
  201. #will pkg be in woof.
  202. # Generic name for pkg. Note: PET packages, if exist, use this name + version#.
  203. # Comma-separated list of ubuntu/debian part-names for pkg(s). '-' prefix, exclude.
  204. # Empty field, then use PET pkg.
  205. # How the package will get split up in woof (optional redirection '>' operator).
  206. # Missing field, it goes into exe. Can also redirect >null, means dump it.
  207. #yes|abiword|iceword_|exe,dev,doc,nls
  208. #remove comments from PKGS_SPECS_TABLE... make sure '|' on end... get rid of old |+udev,+whatever on end...
  209. 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%||$%|%'`"
  210. echo
  211. echo "Checking syntax of PKGS_SPECS_TABLE..."
  212. CNT=1
  213. for ONECHK in $PKGS_SPECS_TABLE
  214. do
  215. BADFLAG='no'
  216. NUMDELS=`echo "$ONECHK" | sed -e 's/[^|]//g' | wc -c`
  217. [ $NUMDELS -lt 4 -o $NUMDELS -gt 6 ] && BADFLAG='yes'
  218. YESNO="`echo "$ONECHK" | cut -f 1 -d '|' | grep -E 'yes|no'`"
  219. [ "YESNO" = "" ] && BADFLAG='yes'
  220. GENPKG="`echo "$ONECHK" | cut -f 2 -d '|'`"
  221. [ "$GENPKG" = "" ] && BADFLAG='yes'
  222. if [ "$BADFLAG" = "yes" ];then
  223. echo "SYNTAX ERROR LINE ${CNT}: '$ONECHK'"
  224. echo "$PKGS_SPECS_TABLE" > /tmp/pst-dump
  225. exit 1
  226. fi
  227. CNT=$(($CNT + 1))
  228. done
  229. COMMANDLINE_CHOICE=""
  230. [ $1 ] && COMMANDLINE_CHOICE="$1"
  231. mkdir -p /tmp/2createpackages_tmp
  232. #091211 to save time rebuild only changed pkgs COMMANDLINE_CHOICE="CHANGED_ONLY"...
  233. mkdir -p status
  234. touch status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  235. #this file will keep growing, so reset it...
  236. [ "$COMMANDLINE_CHOICE" = "ALL_PACKAGES" ] && echo -n "" > status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  237. mkdir -p packages-${DISTRO_FILE_PREFIX}
  238. while [ 1 ];do
  239. if [ "$COMMANDLINE_CHOICE" = "CHANGED_ONLY" ];then #091211
  240. CHOICE_PKGS_SPECS_TABLE="$PKGS_SPECS_TABLE"
  241. break
  242. fi
  243. if [ "$COMMANDLINE_CHOICE" = "" ];then
  244. echo
  245. echo "Press ENTER only to build all pkgs,"
  246. echo -n " or type generic name of one pkg: "
  247. read USERINPUT
  248. else
  249. if [ "$COMMANDLINE_CHOICE" = "ALL_PACKAGES" ];then #see woof_gui_tabs.
  250. USERINPUT=""
  251. else
  252. USERINPUT="$COMMANDLINE_CHOICE"
  253. fi
  254. fi
  255. if [ "$USERINPUT" = "" ];then
  256. rm -rf packages-${DISTRO_FILE_PREFIX}
  257. mkdir packages-${DISTRO_FILE_PREFIX}
  258. CHOICE_PKGS_SPECS_TABLE="$PKGS_SPECS_TABLE"
  259. rm -rf sandbox2c 2>/dev/null
  260. else
  261. aPATTERN='^yes|'"$USERINPUT"'|'
  262. CHOICE_PKGS_SPECS_TABLE="`echo "$PKGS_SPECS_TABLE" | grep "$aPATTERN"`"
  263. if [ "$CHOICE_PKGS_SPECS_TABLE" = "" ];then
  264. echo "ERROR: Generic-name must be from 2nd field of variable PKGS_SPECS_TABLE"
  265. echo "in file ${DPSFILE}."
  266. echo "There must also be a 'yes' in the first field."
  267. continue
  268. fi
  269. rm -rf packages-${DISTRO_FILE_PREFIX}/$USERINPUT 2>/dev/null
  270. rm -rf packages-${DISTRO_FILE_PREFIX}/${USERINPUT}_DEV 2>/dev/null
  271. rm -rf packages-${DISTRO_FILE_PREFIX}/${USERINPUT}_DOC 2>/dev/null
  272. rm -rf packages-${DISTRO_FILE_PREFIX}/${USERINPUT}_NLS 2>/dev/null
  273. rm -rf sandbox2c/$USERINPUT 2>/dev/null
  274. fi
  275. break
  276. done
  277. #121120 further down, wants this in the host system...
  278. [ -f rootfs-skeleton/usr/local/petget/categories.dat ] && cp -f rootfs-skeleton/usr/local/petget/categories.dat /usr/local/petget/
  279. ############################################################################
  280. #find all packages that will be used in the Puppy build...
  281. #new script to find all pkgs for build...
  282. ./support/findpkgs
  283. #...returns file status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  284. # each line is full db entry for pkg, prefixed with :generic-name:, pet/compat and repo-filename.
  285. # 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||
  286. if [ $? -ne 0 ];then
  287. echo
  288. echo "ERROR: Script support/findpkgs aborted with an error, exiting."
  289. exit 1
  290. fi
  291. if [ ! -f status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} ];then
  292. echo
  293. echo "ERROR: Something went wrong with support/findpkgs, exiting."
  294. exit 1
  295. fi
  296. ############################################################################
  297. #read through PKGS_SPECS_TABLE, find matching pkg(s) in 'packages-${BINARIES}',
  298. #process and create raw woof packages in 'packages-${DISTRO_FILE_PREFIX}'...
  299. echo -n "" > /tmp/2createpackages-redo #091211
  300. rm -f ERROR-2CREATEPACKAGES 2>/dev/null
  301. for ONEPKGSPEC in $CHOICE_PKGS_SPECS_TABLE
  302. do
  303. [ "$ONEPKGSPEC" = "" ] && continue
  304. YESNO="`echo "$ONEPKGSPEC" | cut -f 1 -d '|'`"
  305. [ "$YESNO" = "no" ] && continue
  306. MISSPOSTPROC='no' #091211
  307. echo -n "$MISSPOSTPROC" > /tmp/2createpackages_tmp/MISSPOSTPROC #set inside do-done, separate process.
  308. GENERICNAME="`echo "$ONEPKGSPEC" | cut -f 2 -d '|'`"
  309. BINARYPARTNAMES="`echo "$ONEPKGSPEC" | cut -f 3 -d '|' | tr ',' ' '`"
  310. SPLITRULE="`echo "$ONEPKGSPEC" | cut -f 4 -d '|'`"
  311. echo "Processing $GENERICNAME"
  312. REMOVEDGENFLAG=0 #091211
  313. rm -f /tmp/2createpackages-hack-install.sh #slackware doinst.sh gets put here.
  314. rm -rf sandbox2b
  315. mkdir sandbox2b
  316. #processing pkgs that will be combined into $GENERICNAME...
  317. gennamePTN=":${GENERICNAME}:" #a pkg may be shared by multiple generic names, ex: :gcc_lib::gcc_dev:|compat|... (ex from Slacko).
  318. FNDIT="`grep "$gennamePTN" status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}`"
  319. if [ "$FNDIT" = "" ];then
  320. echo "
  321. ERROR: '${GENERICNAME}' package does not exist.
  322. You will need to find a matching package and place in packages-pet,
  323. or packages-${BINARIES} as appropriate.
  324. Do it, then rerun this script and choose to build $GENERICNAME." >> ERROR-2CREATEPACKAGES
  325. continue
  326. fi
  327. #no, inject $FNDIT at end of do-done, runs faster...
  328. # echo "${FNDIT}" |
  329. while read ONEDBENTRY
  330. do
  331. #120812 category now allows optional subcategory...
  332. #ONEDBENTRY=:GENERICNAME:|PETorCOMPAT|DBFILE|pkgname|nameonly|version|pkgrelease|category[;subcategory]|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  333. #...pkgname onwards is the full db entry for a package.
  334. PETorCOMPAT="`echo -n "$ONEDBENTRY" | cut -f 2 -d '|'`" #ex: compat
  335. if [ "$PETorCOMPAT" != "pet" -a "$PETorCOMPAT" != "compat" ];then
  336. echo "
  337. Syntax ERROR in status/findpkgs_FINAL_PKGS-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}:
  338. $ONEDBENTRY
  339. Ignoring this line." >> ERROR-2CREATEPACKAGES
  340. continue
  341. fi
  342. DBFILE="`echo -n "$ONEDBENTRY" | cut -f 3 -d '|'`" #ex: Packages-puppy-5-official
  343. DB_pkgname="`echo -n "$ONEDBENTRY" | cut -f 4 -d '|'`" #ex: abiword-2.3.4-w5
  344. DB_fullfilename="`echo -n "$ONEDBENTRY" | cut -f 11 -d '|'`" #ex: abiword-2.3.4-w5.pet
  345. petFLG="`echo -n "$DB_fullfilename" | grep -o 'pet$'`"
  346. echo -n "$petFLG" > /tmp/2createpackages_tmp/petFLG #cannot read petFLG outside do-done (separate process).
  347. #PKGS_SPECS_TABLE may specify redirections...
  348. EXE="_`echo "$SPLITRULE" | tr ',' '\n' | grep '^exe' | cut -f 2 -d '>' | tr '[a-z]' '[A-Z]'`"
  349. DEV="_`echo "$SPLITRULE" | tr ',' '\n' | grep '^dev' | cut -f 2 -d '>' | tr '[a-z]' '[A-Z]'`"
  350. DOC="_`echo "$SPLITRULE" | tr ',' '\n' | grep '^doc' | cut -f 2 -d '>' | tr '[a-z]' '[A-Z]'`"
  351. NLS="_`echo "$SPLITRULE" | tr ',' '\n' | grep '^nls' | cut -f 2 -d '>' | tr '[a-z]' '[A-Z]'`"
  352. [ "$EXE" = "_" ] && EXE="_EXE"
  353. [ "$DEV" = "_" ] && DEV="_EXE"
  354. [ "$DOC" = "_" ] && DOC="_EXE"
  355. [ "$NLS" = "_" ] && NLS="_EXE"
  356. #the "packagename_EXE" is just named "packagename"...
  357. [ "$EXE" = "_EXE" ] && EXE=""
  358. [ "$DEV" = "_EXE" ] && DEV=""
  359. [ "$DOC" = "_EXE" ] && DOC=""
  360. [ "$NLS" = "_EXE" ] && NLS=""
  361. if [ "$petFLG" = "pet" ];then #do not test PETorCOMPAT only.
  362. PETPKG="`basename $DB_fullfilename .pet`"
  363. PETSUB="pet" #110823
  364. [ "$PETorCOMPAT" = "compat" ] && PETSUB="$BINARIES" #110823
  365. cspPATTERN='|'"$PETPKG"'.pet$'
  366. if [ "$COMMANDLINE_CHOICE" = "CHANGED_ONLY" ];then
  367. if [ "`grep "$cspPATTERN" status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}`" != "" ];then
  368. echo " ...${PETPKG}.pet already processed"
  369. continue
  370. fi
  371. if [ $REMOVEDGENFLAG -eq 0 ];then
  372. rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME} 2>/dev/null
  373. rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV 2>/dev/null
  374. rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DOC 2>/dev/null
  375. rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_NLS 2>/dev/null
  376. rm -rf sandbox2c/${GENERICNAME} 2>/dev/null
  377. groPATTERN='^'"$GENERICNAME"'|' #get rid of old entries...
  378. grep -v "$groPATTERN" status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} > /tmp/2createpackages-hbdd
  379. mv -f /tmp/2createpackages-hbdd status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  380. REMOVEDGENFLAG=1
  381. fi
  382. fi
  383. echo "${GENERICNAME}|${PETPKG}.pet" >> status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  384. #now expand $PETPKG.pet in packages-${DISTRO_FILE_PREFIX}...
  385. echo " processing ${PETPKG}.pet"
  386. #PKGS_SPECS_TABLE may specify redirections...
  387. xPETTYPE="`echo -n "$DB_pkgname" | grep -o -E '_DEV|_DOC|_NLS'`" #_DEV, _DOC, _NLS, or empty for EXE.
  388. [ "$xPETTYPE" = "" ] && xxPETTYPE="$EXE"
  389. [ "$xPETTYPE" = "_DEV" ] && xxPETTYPE="$DEV"
  390. [ "$xPETTYPE" = "_DOC" ] && xxPETTYPE="$DOC"
  391. [ "$xPETTYPE" = "_NLS" ] && xxPETTYPE="$NLS"
  392. #110830 rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xxPETTYPE} 2> /dev/null
  393. rm -rf sandbox2e 2>/dev/null #110830
  394. mkdir sandbox2e #110830
  395. if [ -f packages-${PETSUB}/${PETPKG}.pet ];then #110823
  396. #cp -f packages-${PETSUB}/${PETPKG}.pet packages-${DISTRO_FILE_PREFIX}/ #110823
  397. #cd packages-${DISTRO_FILE_PREFIX}
  398. file -b "packages-${PETSUB}/${PETPKG}.pet" | grep -q "^xz" && ZEXT=xz || ZEXT=gz
  399. cp -f packages-${PETSUB}/${PETPKG}.pet sandbox2e/ #110830
  400. cd sandbox2e
  401. case $ZEXT in
  402. gz) opt=-z ;;
  403. xz) opt=-J ;;
  404. esac
  405. pet2tgz ${PETPKG}.pet
  406. tar ${opt} -x -f $PETPKG.tar.${ZEXT}
  407. #cp -a -f $PETPKG ${GENERICNAME}${xxPETTYPE}
  408. mkdir -p ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xxPETTYPE} #110830
  409. cp -a -f --remove-destination $PETPKG/* ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${xxPETTYPE}/ #110830
  410. sync
  411. rm ${PETPKG}.tar.${ZEXT}
  412. rm -rf $PETPKG
  413. cd ..
  414. else
  415. echo "
  416. ERROR: packages-${PETSUB}/${PETPKG}.pet does not exist.
  417. (Generic name: ${GENERICNAME})
  418. You will need to find this PET package and place in packages-${PETSUB}.
  419. Do it, then rerun this script and choose to build $GENERICNAME." >> ERROR-2CREATEPACKAGES
  420. fi
  421. rm -rf sandbox2e 2>/dev/null #110830
  422. continue
  423. fi
  424. #anything other than .pet pkgs...
  425. ONEBINARYPKG="./packages-${BINARIES}/${DB_fullfilename}"
  426. if [ ! -f $ONEBINARYPKG ];then
  427. echo "
  428. ERROR: ${ONEBINARYPKG} does not exist.
  429. Please find a package that matches, place it in packages-${BINARIES},
  430. then run this script again and choose to build ${GENERICNAME}." >> ERROR-2CREATEPACKAGES
  431. continue 2 #skip this pkg.
  432. fi
  433. zPKGNAME="$DB_fullfilename"
  434. #091211 CHANGED_ONLY commandline option...
  435. cspPATTERN='|'"$zPKGNAME"'$'
  436. if [ "$COMMANDLINE_CHOICE" = "CHANGED_ONLY" ];then
  437. if [ "`grep "$cspPATTERN" status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}`" != "" ];then
  438. echo " ...${zPKGNAME} already processed"
  439. MISSPOSTPROC='yes'
  440. echo -n "$MISSPOSTPROC" > /tmp/2createpackages_tmp/MISSPOSTPROC #set inside do-done, separate process.
  441. continue
  442. fi
  443. groPATTERN='^'"$GENERICNAME"'|' #get rid of old entries...
  444. grep -v "$groPATTERN" status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION} > /tmp/2createpackages-hbdd
  445. mv -f /tmp/2createpackages-hbdd status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  446. REMOVEDGENFLAG=1
  447. #there is a problem, actually need to redo the whole thing afterward...
  448. echo "$GENERICNAME" >> /tmp/2createpackages-redo
  449. continue 2 #process next GENERICNAME
  450. fi
  451. echo "${GENERICNAME}|${zPKGNAME}" >> status/2createpackages_history_builds-${DISTRO_BINARY_COMPAT}-${DISTRO_COMPAT_VERSION}
  452. echo " processing $zPKGNAME"
  453. case $DISTRO_BINARY_COMPAT in
  454. ubuntu|debian|raspbian)
  455. PKGNAME="`basename $ONEBINARYPKG .deb`" #ex: bash_3.2-4ububtu1_i386
  456. rm -rf sandbox2
  457. mkdir sandbox2
  458. dpkg-deb -x $ONEBINARYPKG sandbox2/
  459. if [ $? -ne 0 ];then
  460. echo "ERROR: failed to unpack $PKGNAME"
  461. continue
  462. fi
  463. ;;
  464. slackware)
  465. #100617 add support for .txz...
  466. SLACKEXT="`echo -n "$ONEBINARYPKG" | rev | cut -f 1 -d '.' | rev`" #exs: tgz, txz
  467. rm -rf sandbox2
  468. mkdir sandbox2
  469. cp -a $ONEBINARYPKG sandbox2/
  470. cd sandbox2
  471. if [ "$SLACKEXT" == "tgz" ];then
  472. PKGNAME="`basename ${ONEBINARYPKG} .tgz`" #ex: bash-3.2
  473. tar -izxf ${PKGNAME}.tgz
  474. RETVAL=$?
  475. rm -f ${PKGNAME}.tgz
  476. else
  477. PKGNAME="`basename ${ONEBINARYPKG} .txz`" #ex: bash-3.2
  478. tar -iJxf ${PKGNAME}.txz
  479. RETVAL=$?
  480. rm -f ${PKGNAME}.txz
  481. fi
  482. cd ..
  483. if [ $RETVAL -ne 0 ];then
  484. echo "ERROR: failed to unpack $PKGNAME"
  485. continue
  486. fi
  487. #complication, may have a post-install script...
  488. if [ -f sandbox2/install/doinst.sh ];then
  489. chmod +x sandbox2/install/doinst.sh
  490. #move it to here...
  491. #cat sandbox2/install/doinst.sh > sandbox2/hack-install.sh
  492. #accumulate post-install scripts here, run later...
  493. cat sandbox2/install/doinst.sh >> /tmp/2createpackages-hack-install.sh
  494. #...note, could have created FIXUPHACK which executes later in this script,
  495. # hack-install.sh also is executed near end of this script.
  496. rm -rf sandbox2/install
  497. fi
  498. ;;
  499. arch)
  500. FULLPKGNAME="`basename $ONEBINARYPKG`"
  501. PKGNAME="`basename $ONEBINARYPKG .pkg.tar.gz`" #ex: bash-3.2
  502. PKGNAME="`basename $PKGNAME .pkg.tar.xz`" #ex: bash-3.2
  503. PKGNAME="`echo -n "$PKGNAME" | sed 's%\-any$%%'`"
  504. PKGNAME="`echo -n "$PKGNAME" | sed 's%\-i686$%%'`"
  505. #PKGNAME="`echo -n "$PKGNAME" | sed 's%\-x86_64$%%'`" #for future
  506. rm -rf sandbox2
  507. mkdir sandbox2
  508. cp -a $ONEBINARYPKG sandbox2/
  509. cd sandbox2
  510. if [ "`basename $ONEBINARYPKG .tar.xz`" != "`basename $ONEBINARYPKG`" ]; then
  511. tar --force-local -Jxf $FULLPKGNAME #.tar.xz
  512. else
  513. tar --force-local -zxf $FULLPKGNAME #.tar.gz
  514. fi
  515. RETVAL=$?
  516. rm -f $FULLPKGNAME
  517. cd ..
  518. if [ $RETVAL -ne 0 ];then
  519. echo "ERROR: failed to unpack $PKGNAME"
  520. continue
  521. fi
  522. ;;
  523. t2|gentoo) #120515
  524. FULLPKGNAME="`basename $ONEBINARYPKG`"
  525. PKGNAME="`basename $ONEBINARYPKG .tar.bz2`" #ex: bash-3.2
  526. rm -rf sandbox2
  527. mkdir sandbox2
  528. cp -a $ONEBINARYPKG sandbox2/
  529. cd sandbox2
  530. tar -jxf $FULLPKGNAME
  531. RETVAL=$?
  532. rm -f $FULLPKGNAME
  533. cd ..
  534. if [ $RETVAL -ne 0 ];then
  535. echo "ERROR: failed to unpack $PKGNAME"
  536. continue
  537. fi
  538. ;;
  539. scientific) #110523 Iguleder.
  540. FULLPKGNAME="`basename $ONEBINARYPKG`"
  541. PKGNAME="`basename $ONEBINARYPKG .rpm`" #ex: bash-3.2
  542. rm -rf sandbox2
  543. mkdir sandbox2
  544. cp -a $ONEBINARYPKG sandbox2/
  545. cd sandbox2
  546. rpm2cpio $FULLPKGNAME | cpio -id > /dev/null 2>&1
  547. RETVAL=$?
  548. rm -f $FULLPKGNAME
  549. cd ..
  550. if [ $RETVAL -ne 0 ];then
  551. echo "ERROR: failed to unpack $PKGNAME"
  552. continue
  553. fi
  554. ;;
  555. mageia) #110615 support mageia
  556. FULLPKGNAME="`basename $ONEBINARYPKG`"
  557. PKGNAME="`basename $ONEBINARYPKG .rpm`" #ex: bash-3.2
  558. rm -rf sandbox2
  559. mkdir sandbox2
  560. cp -a $ONEBINARYPKG sandbox2/
  561. cd sandbox2
  562. #110618 busybox rpm2cpio does not work with mageia rpms...
  563. #rpm2cpio $FULLPKGNAME | cpio -id > /dev/null 2>&1
  564. #7z x -so $FULLPKGNAME | cpio -id > /dev/null 2>&1
  565. #7z works but big and slow. exploderpm works, fast, builtin to puppy...
  566. exploderpm -x $FULLPKGNAME > /dev/null 2>&1
  567. RETVAL=$?
  568. rm -f $FULLPKGNAME
  569. cd ..
  570. if [ $RETVAL -ne 0 ];then
  571. echo "ERROR: failed to unpack $PKGNAME"
  572. continue
  573. fi
  574. ;;
  575. esac
  576. #130111 moved below case-statement.
  577. #120316 hack for multiarch, move libs to standard locations...
  578. if [ "$ARCHDIR" ];then #130112 change test from ARCHDIR. 130114 revert DISTRO_ARCHDIR_SYMLINKS==yes.
  579. if [ -d sandbox2/lib/$ARCHDIR ];then
  580. #ARCHSUBDIR="$(find sandbox2/lib/${ARCHDIR} -mindepth 1 -maxdepth 1 -type d | head -n 1)" #121122 121123 revert.
  581. cp -a -f --remove-destination sandbox2/lib/${ARCHDIR}/* sandbox2/lib/
  582. sync
  583. rm -rf sandbox2/lib/${ARCHDIR}
  584. ln -s ./ sandbox2/lib/${ARCHDIR}
  585. #if [ "$ARCHSUBDIR" ]; then #121122 121123
  586. # BASESUBDIR="$(basename $ARCHSUBDIR)"
  587. # if [ ! -e sandbox2/lib/${BASESUBDIR}/${BASESUBDIR} ];then
  588. # ln -s ../${BASESUBDIR} sandbox2/lib/${BASESUBDIR}/${BASESUBDIR}
  589. # fi
  590. #fi
  591. fi
  592. if [ -d sandbox2/usr/lib/$ARCHDIR ];then
  593. #ARCHSUBDIR="$(find sandbox2/usr/lib/${ARCHDIR} -mindepth 1 -maxdepth 1 -type d | head -n 1)" #121122 121123 revert.
  594. cp -a -f --remove-destination sandbox2/usr/lib/${ARCHDIR}/* sandbox2/usr/lib/
  595. sync
  596. rm -rf sandbox2/usr/lib/${ARCHDIR}
  597. ln -s ./ sandbox2/usr/lib/${ARCHDIR}
  598. #if [ "$ARCHSUBDIR" ]; then #121122 121123
  599. # BASESUBDIR="$(basename $ARCHSUBDIR)"
  600. # if [ ! -e sandbox2/usr/lib/${BASESUBDIR}/${BASESUBDIR} ];then
  601. # ln -s ../${BASESUBDIR} sandbox2/usr/lib/${BASESUBDIR}/${BASESUBDIR}
  602. # fi
  603. #fi
  604. fi
  605. #120909 add /usr/bin...
  606. if [ -d sandbox2/usr/bin/$ARCHDIR ];then
  607. cp -a -f --remove-destination sandbox2/usr/bin/${ARCHDIR}/* sandbox2/usr/bin/
  608. sync
  609. rm -rf sandbox2/usr/bin/${ARCHDIR}
  610. ln -s ./ sandbox2/usr/bin/${ARCHDIR}
  611. fi
  612. fi
  613. #120818 overhauled. Pkg db now has category[;subcategory] (see 0setup), xdg enhanced (see /etc/xdg and /usr/share/desktop-directories), and generic icons for all subcategories (see /usr/local/lib/X11/mini-icons).
  614. #w019 fix .desktop files... 120628 improve...
  615. DEFICON='Executable.xpm'
  616. FULLPKGNAME="`basename $ONEBINARYPKG`"
  617. # fnPATTERN='|'"$FULLPKGNAME"'|'
  618. # #DB_ENTRY="`cat $PKGLISTS_COMPAT | grep "$fnPATTERN" | head -n 1`"
  619. DB_ENTRY="`echo -n "$ONEDBENTRY" | cut -f 4-19 -d '|'`" #take GENERICNAME|PETorCOMPAT|DBFILE| off start.
  620. #120818 find out if Categories entry in .desktop is valid, if not use 'category' field in pkg db...
  621. CATEGORY="`echo -n "$DB_ENTRY" | cut -f 5 -d '|'`" #exs: Document, Document;edit
  622. [ "$CATEGORY" = "" ] && CATEGORY='BuildingBlock' #paranoid precaution.
  623. #xCATEGORY and DEFICON will be the fallbacks if Categories entry in .desktop is invalid...
  624. xCATEGORY="`echo -n "$CATEGORY" | sed -e 's%^%X-%' -e 's%;%-%'`" #ex: X-Document-edit (refer /etc/xdg/menu/*.menu)
  625. DEFICON="`echo -n "$CATEGORY" | sed -e 's%^%mini-%' -e 's%;%-%'`" #ex: mini-Document-edit (refer /usr/local/lib/X11/mini-icons -- these are in jwm search path)
  626. case $CATEGORY in
  627. Calculate) CATEGORY='Business' ; xCATEGORY='X-Business' ; DEFICON='mini-Business.xpm' ;; #Calculate is old name, now Business.
  628. Develop) CATEGORY='Utility;development' ; xCATEGORY='X-Utility-development' ; DEFICON='mini-Utility-development.xpm' ;; #maybe an old pkg has this.
  629. Help) CATEGORY='Utility;help' ; xCATEGORY='X-Utility-help' ; DEFICON='mini-Help.xpm' ;; #maybe an old pkg has this.
  630. BuildingBlock) CATEGORY='Utility' ; xCATEGORY='X-Utility' ; DEFICON='mini-BuildingBlock.xpm' ;; #unlikely to have a .desktop file.
  631. esac
  632. #check validity of Categories= and Icon= entries in .desktop file...
  633. topCATEGORY="`echo -n "$CATEGORY" | cut -f 1 -d ';'`"
  634. tPATTERN="^${topCATEGORY} "
  635. cPATTERN="s%^Categories=.*%Categories=${xCATEGORY}%"
  636. iPATTERN="s%^Icon=.*%Icon=${DEFICON}%"
  637. FND_DESKTOP="`find sandbox2/usr/share/applications sandbox2/usr/local/share/applications sandbox2/usr/X11R7/applications -type f -name \*.desktop 2>/dev/null | tr '\n' ' '`"
  638. #121120 if only one .desktop file, first check if a match in /usr/local/petget/categories.dat (see also /usr/local/petget/installpkg.sh)...
  639. CATDONE='no'
  640. if [ -f /usr/local/petget/categories.dat ];then #precaution, but it will be there -- yes, have added code above makes sure it is.
  641. NUMDESKFILE="$(echo -n "$FND_DESKTOP" | wc -w)"
  642. if [ "$NUMDESKFILE" = "1" ];then
  643. #to lookup categories.dat, we need to know the generic name of the package, which may be different from pkg name...
  644. #db entry format: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  645. DBNAMEONLY="$(echo -n "$DB_ENTRY" | cut -f 2 -d '|')"
  646. DBPATH="$(echo -n "$DB_ENTRY" | cut -f 7 -d '|')"
  647. DBCOMPILEDDISTRO="$(echo -n "$DB_ENTRY" | cut -f 11 -d '|')"
  648. [ ! "$DBCOMPILEDDISTRO" ] && DBCOMPILEDDISTRO='puppy' #precaution. any name will do here.
  649. case $DBCOMPILEDDISTRO in
  650. debian|ubuntu|raspbian)
  651. if [ "$DBPATH" ];then #precaution
  652. xNAMEONLY="$(basename ${DBPATH})"
  653. else
  654. xNAMEONLY="$DBNAMEONLY"
  655. fi
  656. ;;
  657. *) xNAMEONLY="$DBNAMEONLY" ;;
  658. esac
  659. xnPTN=" ${xNAMEONLY} "
  660. #130219 categories.dat format changed slightly... ignore case...
  661. CATVARIABLE="$(grep -i "$xnPTN" /usr/local/petget/categories.dat | grep '^PKGCAT' | head -n 1 | cut -f 1 -d '=' | cut -f 2,3 -d '_' | tr '_' '-')" #ex: PKGCAT_Graphic_camera=" gphoto2 gtkam "
  662. if [ "$CATVARIABLE" ];then #ex: Graphic-camera
  663. xCATEGORY="X-${CATVARIABLE}"
  664. cPATTERN="s%^Categories=.*%Categories=${xCATEGORY}%"
  665. CATFOUND="yes"
  666. CATDONE='yes'
  667. fi
  668. fi
  669. fi
  670. for ONEDESKTOP in $FND_DESKTOP
  671. do
  672. CATFOUND="no"
  673. if [ "$CATDONE" = "no" ];then #121120
  674. for ONEORIGCAT in `cat $ONEDESKTOP | grep '^Categories=' | head -n 1 | cut -f 2 -d '=' | tr ';' ' ' | rev` #search in reverse order.
  675. do
  676. #find out if category already valid, if not fallback to xCATEGORY...
  677. ONEORIGCAT="`echo -n "$ONEORIGCAT" | rev`" #restore rev of one word.
  678. oocPATTERN=' '"$ONEORIGCAT"' '
  679. [ "`echo "$PUPHIERARCHY" | tr -s ' ' | grep "$tPATTERN" | cut -f 3 -d ' ' | tr ',' ' ' | sed -e 's%^% %' -e 's%$% %' | grep "$oocPATTERN"`" != "" ] && CATFOUND="yes"
  680. #got a problem with sylpheed, "Categories=GTK;Network;Email;News;" this displays in both Network and Internet menus...
  681. if [ "$CATFOUND" = "yes" ];then
  682. cPATTERN="s%^Categories=.*%Categories=${ONEORIGCAT}%"
  683. break
  684. fi
  685. done
  686. #121119 above may fail, as DB_category field may not match that in .desktop file, so leave out that $tPATTERN match in $PUPHIERARCHY...
  687. if [ "$CATFOUND" = "no" ];then
  688. for ONEORIGCAT in `cat $ONEDESKTOP | grep '^Categories=' | head -n 1 | cut -f 2 -d '=' | tr ';' ' ' | rev` #search in reverse order.
  689. do
  690. #find out if category already valid, if not fallback to xCATEGORY...
  691. ONEORIGCAT="`echo -n "$ONEORIGCAT" | rev`" #restore rev of one word.
  692. oocPATTERN=' '"$ONEORIGCAT"' '
  693. [ "`echo "$PUPHIERARCHY" | tr -s ' ' | cut -f 3 -d ' ' | tr ',' ' ' | sed -e 's%^% %' -e 's%$% %' | grep "$oocPATTERN"`" != "" ] && CATFOUND="yes"
  694. #got a problem with sylpheed, "Categories=GTK;Network;Email;News;" this displays in both Network and Internet menus...
  695. if [ "$CATFOUND" = "yes" ];then
  696. cPATTERN="s%^Categories=.*%Categories=${ONEORIGCAT}%"
  697. break
  698. fi
  699. done
  700. fi
  701. fi
  702. sed -i -e "$cPATTERN" $ONEDESKTOP #fix Category field.
  703. #does the icon exist?... fix .desktop... 110821 improve...
  704. ICON="`grep '^Icon=' $ONEDESKTOP | cut -f 2 -d '='`"
  705. if [ "$ICON" != "" ];then
  706. [ -e "sandbox2${ICON}" ] && continue #it may have a hardcoded path.
  707. [ -e "${ICON}" ] && continue #it may have a hardcoded path, look in running puppy.
  708. ICONBASE="`basename "$ICON"`"
  709. #first search where jwm looks for icons... 111207 check if paths exist...
  710. FNDICON=""
  711. [ -d sandbox2/usr/share/pixmaps ] && FNDICON="`find sandbox2/usr/share/pixmaps -maxdepth 1 -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  712. [ ! "$FNDICON" ] && [ -d sandbox2/usr/local/lib/X11/mini-icons ] && FNDICON="`find sandbox2/usr/local/lib/X11/mini-icons -maxdepth 1 -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  713. if [ "$FNDICON" ];then
  714. ICONNAMEONLY="`basename $FNDICON`"
  715. iPTN="s%^Icon=.*%Icon=${ICONNAMEONLY}%"
  716. sed -i -e "$iPTN" $ONEDESKTOP
  717. continue
  718. else
  719. #look elsewhere, including in running puppy... 111207 fix for parole /usr/share/parole/parole.png...
  720. FNDICON="`find sandbox2 /usr/share/icons /usr/local/share/pixmaps /usr/share/pixmaps -name $ICONBASE -o -name $ICONBASE.png -o -name $ICONBASE.xpm -o -name $ICONBASE.jpg -o -name $ICONBASE.jpeg -o -name $ICONBASE.gif -o -name $ICONBASE.svg | sed -e 's%sandbox2%%' | grep -i -E 'png$|xpm$|jpg$|jpeg$|gif$|svg$' | head -n 1`"
  721. if [ "$FNDICON" ];then
  722. ICONNAMEONLY="`basename "$FNDICON"`"
  723. mkdir -p sandbox2/usr/share/pixmaps #120514
  724. ln -snf "$FNDICON" sandbox2/usr/share/pixmaps/${ICONNAMEONLY} #111207 fix path.
  725. iPTN="s%^Icon=.*%Icon=${ICONNAMEONLY}%"
  726. sed -i -e "$iPTN" $ONEDESKTOP
  727. continue
  728. fi
  729. fi
  730. #substitute a default icon...
  731. sed -i -e "$iPATTERN" $ONEDESKTOP
  732. fi
  733. done
  734. #w019 T2 pkgs have /var/adm...
  735. [ -d sandbox2/var/adm ] && rm -rf sandbox2/var/adm
  736. #and these...
  737. [ -d sandbox2/etc/postinstall.d ] && rm -rf sandbox2/etc/postinstall.d
  738. [ -d sandbox2/etc/stone.d ] && rm -rf sandbox2/etc/stone.d
  739. #accumulate multiple binary pkgs into one place...
  740. cp -a --remove-destination sandbox2/* sandbox2b/ #accumulate all ubuntu|debian|t2|slackware pkgs.
  741. #if pkg has '-dev_' in name, copy all of it to $DEV... w018 add '_DEV'
  742. if [ "`echo "$PKGNAME" | grep -E '\-dev_|_DEV'`" != "" ];then
  743. mkdir -p packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}
  744. cp -a --remove-destination sandbox2/* packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/
  745. continue
  746. fi
  747. #if pkg has '-doc_' in name, copy all of it to $DOC... w018 add '_DOC'
  748. if [ "`echo "$PKGNAME" | grep -E '\-doc_|_DOC'`" != "" ];then
  749. mkdir -p packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DOC}
  750. cp -a --remove-destination sandbox2/* packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DOC}/
  751. continue
  752. fi
  753. #w018 '_NLS'
  754. if [ "`echo "$PKGNAME" | grep '_NLS'`" != "" ];then
  755. mkdir -p packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${NLS}
  756. cp -a --remove-destination sandbox2/* packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${NLS}/
  757. continue
  758. fi
  759. #now process sandbox2 and create split rootfs, devx, docs, nls...
  760. cd sandbox2
  761. #now to split pkg into exe,dev,doc,nls components...
  762. #this will find all files and symlinks to files...
  763. find -L ./ -noleaf -type f | sed -e 's/^\.\///' |
  764. while read ONEFILE
  765. do
  766. #problem, coming here with paths that have symlinks...
  767. UPONE="`dirname "$ONEFILE"`"
  768. while [ "$UPONE" != "." -a "$UPONE" != "/" ];do
  769. [ -h "$UPONE" ] && continue 2
  770. UPONE="`dirname "$UPONE"`"
  771. done
  772. ONEBASE="`basename "$ONEFILE"`"
  773. ONEPATH="`dirname "$ONEFILE"`"
  774. [ "$ONEPATH" = "." ] && ONEPATH=""
  775. #strip the file...
  776. #120502 but not if a cross-build (see file WOOFMERGEVARS), strip won't work...
  777. if [ "$WOOF_HOSTARCH" = "$WOOF_TARGETARCH" ];then
  778. if [ "`which strip`" != "" ];then #needs devx.
  779. if [ ! -h "$ONEFILE" ];then #make sure it isn't a symlink
  780. [ ! "`file "$ONEFILE" | grep 'ELF' | grep 'shared object'`" = "" ] && strip --strip-debug "$ONEFILE"
  781. [ ! "`file "$ONEFILE" | grep 'ELF' | grep 'executable'`" = "" ] && strip --strip-unneeded "$ONEFILE"
  782. fi
  783. fi
  784. fi
  785. sync
  786. ###NLS###
  787. #find out if this is an international language file...
  788. if [ ! "`echo -n "$ONEFILE" | grep --extended-regexp '/locale/|/nls/|/i18n/'`" = "" ];then
  789. if [ "`echo -n "$ONEFILE" | grep 'share/X11/locale/'`" = "" ];then #w020 T2, need Xorg locale files in main pkg.
  790. [ "$NLS" = "_NULL" ] && continue #just dump it.
  791. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${NLS}/${ONEPATH}"
  792. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${NLS}/${ONEPATH}/" 2>/dev/null
  793. continue
  794. fi
  795. fi
  796. ###DOC###
  797. #find out if this is a documentation file...
  798. if [ ! "`echo -n "$ONEFILE" | grep --extended-regexp '/man/|/doc/|/doc-base/|/docs/|/info/|/gtk-doc/|/faq/|/manual/|/examples/|/help/|/htdocs/'`" = "" ];then
  799. [ "$DOC" = "_NULL" ] && continue #just dump it.
  800. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DOC}/${ONEPATH}"
  801. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DOC}/${ONEPATH}/" 2>/dev/null
  802. continue
  803. fi
  804. ###DEV###
  805. #find out if this is development file... 091125: add 'config' dir (in xorg)...
  806. if [ ! "`echo -n "$ONEFILE" | grep --extended-regexp 'X11/config/|/include/|/pkgconfig/|/aclocal|/cvs/|/svn/'`" = "" ];then
  807. #note: if "$DEV" = "_NULL" then 'abiword_NULL' will get created, delete later.
  808. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}"
  809. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}/" 2>/dev/null
  810. continue
  811. fi
  812. #find *.so symlink files...
  813. if [ -h "$ONEFILE" ];then #-h tests for symlink
  814. if [ ! "`echo -n "$ONEFILE" | grep '\.so$'`" = "" ];then
  815. #note: if "$DEV" = "_NULL" then 'abiword_NULL' will get created, delete later.
  816. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}"
  817. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}/" 2>/dev/null
  818. continue
  819. fi
  820. fi
  821. #find various config files...
  822. if [ ! "`echo -n "$ONEBASE" | grep --extended-regexp '\-config$|config.sh$|Conf.sh$'`" = "" ];then
  823. #note: if "$DEV" = "_NULL" then 'abiword_NULL' will get created, delete later.
  824. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}"
  825. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}/" 2>/dev/null
  826. continue
  827. fi
  828. #all .a and .la files... and any stray .m4 files...
  829. if [ ! "`echo -n "$ONEBASE" | grep --extended-regexp '\.a$|\.la$|\.m4$'`" = "" ];then
  830. #note: if "$DEV" = "_NULL" then 'abiword_NULL' will get created, delete later.
  831. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}"
  832. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONEPATH}/" 2>/dev/null
  833. continue
  834. fi
  835. ###EXE###
  836. #anything left over goes into the main 'executable' package...
  837. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${ONEPATH}"
  838. cp -af "$ONEFILE" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${ONEPATH}/" 2>/dev/null
  839. done
  840. ###EXE###
  841. #fix for empty directories and links to dirs...
  842. find -L ./ -noleaf -type d | sed -e 's/^\.\///' |
  843. while read ANEWDIR
  844. do
  845. UPONE="`dirname "$ANEWDIR"`"
  846. [ "$UPONE" = "." ] && UPONE=""
  847. if [ -h "$ANEWDIR" ];then #link
  848. mkdir -p "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${UPONE}"
  849. cp -af "$ANEWDIR" "../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${UPONE}/"
  850. continue
  851. fi
  852. #copy a empty dir...
  853. [ "`ls -1 $ANEWDIR`" = "" ] && mkdir -p ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${ANEWDIR}
  854. done
  855. cd ..
  856. #end of splitting.
  857. done<<_END1
  858. $(echo "${FNDIT}")
  859. _END1
  860. #...get next pkg in same GENERICNAME
  861. [ "`cat /tmp/2createpackages_tmp/petFLG`" = "pet" ] && continue #do not do post-processing.
  862. [ "`cat /tmp/2createpackages_tmp/MISSPOSTPROC`" = "yes" ] && continue #091211
  863. ###POST-PROCESSING FOR NON-PET PKGS###
  864. ###EXE###
  865. #111204 do not execute post-install script if FIXUPHACK has DISABLE_POST_INSTALL_SCRIPT=yes...
  866. #if [ -f packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK ];then
  867. if [ -f packages-templates/$GENERICNAME/FIXUPHACK ];then #111210 01micko
  868. #DPISFLAG="`grep '^DISABLE_POST_INSTALL_SCRIPT' packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK | grep 'yes'`"
  869. DPISFLAG="`grep '^DISABLE_POST_INSTALL_SCRIPT' packages-templates/$GENERICNAME/FIXUPHACK | grep 'yes'`" #111210
  870. [ "$DPISFLAG" ] && [ -f /tmp/2createpackages-hack-install.sh ] && rm -f /tmp/2createpackages-hack-install.sh
  871. fi
  872. #slackware pkgs may have a post-install script.
  873. #for one genericname, have concatenated them in /tmp/2createpackages-hack-install.sh...
  874. #why not create a layered f.s. right now on top of sandbox2b and run hack-install.sh?...
  875. [ -f /tmp/2createpackages-hack-install.sh ] && mv -f /tmp/2createpackages-hack-install.sh sandbox2b/hack-install.sh
  876. if [ -f sandbox2b/hack-install.sh ];then
  877. echo " executing (Slackware) post-install script"
  878. #chmod +x sandbox2b/hack-install.sh
  879. #glibc pkg hack-install.sh tries to run /sbin/ldconfig which is bad, ditto chroot...
  880. [ -f /sbin/ldconfig ] && mv -f /sbin/ldconfig /sbin/ldconfig-2cp-hidden #this is in devx.
  881. [ -f /usr/sbin/chroot ] && mv -f /usr/sbin/chroot /usr/sbin/chroot-2cp-hidden
  882. [ -f sandbox2b/sbin/ldconfig ] && mv -f sandbox2b/sbin/ldconfig /tmp/ldconfig-hidden2
  883. mkdir -p sandbox2b/bin #hack, glibc post-install script needs this.
  884. mkdir layer_rw
  885. mkdir layer_top
  886. mount -t tmpfs tmpfs layer_rw
  887. LAYERFS="aufs"
  888. [ "`lsmod | grep '^unionfs'`" != "" ] && LAYERFS="unionfs"
  889. if [ "$LAYERFS" = "aufs" ];then
  890. mount -t aufs -o udba=reval,diropq=w,dirs=layer_rw=rw:sandbox2b=ro layerfs layer_top
  891. else
  892. mount -t unionfs -o dirs=layer_rw=rw:sandbox2b=ro layerfs layer_top
  893. fi
  894. cd layer_top
  895. /bin/sh ./hack-install.sh
  896. cd ..
  897. [ ! -d packages-${DISTRO_FILE_PREFIX}/${GENERICNAME} ] && mkdir -p packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}
  898. cp -a --remove-destination layer_rw/* packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}/ 2>/dev/null
  899. #aargh, problem if script deleted something. need to find whiteout files...
  900. find layer_rw -type f -name .wh.* | grep -v '\.wh\.\.wh' | sed -e 's%\.wh\.%%' | sed -e 's%layer_rw%%' |
  901. while read ONEFILE
  902. do
  903. rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${ONEFILE} 2>/dev/null
  904. [ -d packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV ] && rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV${ONEFILE} 2>/dev/null
  905. done
  906. sync
  907. umount layer_top
  908. umount layer_rw
  909. rmdir layer_top
  910. rmdir layer_rw
  911. [ -f /sbin/ldconfig-2cp-hidden ] && mv -f /sbin/ldconfig-2cp-hidden /sbin/ldconfig #restore.
  912. [ -f /usr/sbin/chroot-2cp-hidden ] && mv -f /usr/sbin/chroot-2cp-hidden /usr/sbin/chroot #restore.
  913. #echo " ...done"
  914. fi
  915. #now do some post-processing using "template" found in 'packages-templates'...
  916. if [ -d packages-templates/$GENERICNAME ];then
  917. echo " postprocessing with packages-templates/$GENERICNAME"
  918. mkdir -p packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}
  919. cp -a packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE} /tmp/${GENERICNAME}
  920. for TEMPLATEPATH in `find packages-templates/$GENERICNAME -type d`
  921. do
  922. TEMPLATEFILES="`find $TEMPLATEPATH -maxdepth 1 -type f`"
  923. TEMPLATELINKS="`find $TEMPLATEPATH -maxdepth 1 -type l`"
  924. #some dirs in template renamed with "PKGVERSION" in the name...
  925. #upPATTERN="s%PKGVERSION%${UPKGVERSION}%"
  926. ppPATTERN="s%packages-templates/%packages-${DISTRO_FILE_PREFIX}/%"
  927. #TARGETPATH="`echo -n "$TEMPLATEPATH" | sed -e "$ppPATTERN" | sed -e "$upPATTERN"`"
  928. TARGETPATH="`echo -n "$TEMPLATEPATH" | sed -e "$ppPATTERN"`"
  929. mkdir -p $TARGETPATH
  930. #TMPPATH="`echo -n "$TEMPLATEPATH" | sed -e 's%packages-templates/%/tmp/%' | sed -e "$upPATTERN"`"
  931. TMPPATH="`echo -n "$TEMPLATEPATH" | sed -e 's%packages-templates/%/tmp/%'`"
  932. #bit radical, but if dir in template has one or more files, truncate those in target...
  933. if [ ! -f $TEMPLATEPATH/PLUSEXTRAFILES ];then #marker-file, that all files in deb to be kept.
  934. tPATTERN="packages-${DISTRO_FILE_PREFIX}/"
  935. [ "`echo "$TARGETPATH" | grep "$tPATTERN"`" = "" ] && continue #paranoid precaution! (see next line)...
  936. #if [ "$TEMPLATEFILES" != "" ];then
  937. for ONEDEL in `find ${TARGETPATH} -maxdepth 1 -type f` #ignore symlinks.
  938. do
  939. #if file has any versioning info, do not delete...
  940. DELBASE="`basename $ONEDEL`"
  941. #if dir has NOEXCEPTIONFILES then do not allow these exceptions...
  942. [ ! -f $TEMPLATEPATH/NOEXCEPTIONFILES ] && [ "`echo "$DELBASE" | grep -E '\.[0-9]*\.|\.[0-9]*$|\-[0-9]*\.|[0-9]\.so$|\.so\.[0-9]'`" != "" ] && continue
  943. ##sometimes regular file but template has symlink of same name (ex: /usr/bin/gnumeric). do not delete...
  944. #[ -L ${TEMPLATEPATH}/${DELBASE} ] && continue
  945. rm $ONEDEL
  946. done
  947. #fi
  948. fi
  949. #if file exists in template, non-0 copy it from template to target, 0-size copy from deb pkg to target...
  950. for FINALFILE in $TEMPLATEFILES
  951. do
  952. ALTTARGETPATH="$TARGETPATH"
  953. ALTTMPPATH="$TMPPATH"
  954. TMPLNAMEONLY="`basename $FINALFILE -FULL`" #coreutils & util-linux have some file-FULL.
  955. if [ ! -f $TMPPATH/$TMPLNAMEONLY ];then
  956. if [ "/tmp/${GENERICNAME}" != "$TMPPATH" ];then #ignore top level.
  957. if [ "`echo -n "$TMPPATH" | grep -E "/root|/etc|/dev|/var/"`" = "" ];then #ignore if file in /root or /etc or /dev
  958. #if the target file is somewhere else, find it...
  959. ALTLOCATION="`find /tmp/${GENERICNAME} -type f -name $TMPLNAMEONLY | head -n 1`"
  960. if [ "$ALTLOCATION" != "" ];then
  961. #ALTTARGETPATH="`dirname $ALTLOCATION | sed -e 's%^/tmp/%packages-${DISTRO_FILE_PREFIX}/%'`"
  962. [ "`file "$ALTLOCATION" | grep ' text'`" = "" ] && ALTTMPPATH="`dirname $ALTLOCATION`" #ignore text file.
  963. else
  964. #a hack, util-linux has 'rename.ul', presume ubuntu have renamed it so as not to conflict
  965. #with some other 'rename'....
  966. ALTLOCATION="`find /tmp/${GENERICNAME} -type f -name ${TMPLNAMEONLY}.ul | head -n 1`"
  967. if [ "$ALTLOCATION" != "" ];then
  968. ALTTMPPATH="`dirname $ALTLOCATION`"
  969. TMPLNAMEONLY="$TMPLNAMEONLY"'.ul'
  970. #else
  971. # echo "WARNING: Not found in .deb: $FINALFILE"
  972. fi
  973. fi
  974. fi
  975. fi
  976. fi
  977. #130313 arch linux is relocating many files to /usr, providing symlinks, very annoying...
  978. #note, ALTTMPPATH is *not* the template, it is the actual package, copied to tmp.
  979. if [ ! -h $FINALFILE ];then
  980. if [ ! -s $FINALFILE ];then #want zero bytes, this is in template.
  981. if [ -h $ALTTMPPATH/$TMPLNAMEONLY ];then
  982. if [ "`echo -n "$FINALFILE" | grep '/usr/'`" = "" ];then #only catch files moved to /usr.
  983. LINKTNO="$(readlink $ALTTMPPATH/$TMPLNAMEONLY)"
  984. if [ "$(echo -n "$LINKTNO" | grep '\.\./usr/')" != "" ];then #only catch files moved to /usr.
  985. if [ -f $ALTTMPPATH/$LINKTNO ];then #hope it is relative link. -- i put the .. above to check that.
  986. rm -f $ALTTMPPATH/$TMPLNAMEONLY
  987. mv -f $ALTTMPPATH/$LINKTNO $ALTTMPPATH/ #put it back in correct place.
  988. NEWLINKTNO="$(echo -n "$LINKTNO" | sed -e 's%/usr/%/../%')"
  989. ln -s $NEWLINKTNO $ALTTMPPATH/$LINKTNO #concession, provide a symlink from "wrong" place.
  990. fi
  991. fi
  992. fi
  993. fi
  994. fi
  995. fi
  996. if [ -s $FINALFILE ];then
  997. #all non-0-size files must be copied from template to final pkg...
  998. cp -af $FINALFILE $ALTTARGETPATH/
  999. else
  1000. #zero-size file. copy from the backup made in /tmp/${GENERICNAME} to final pkg...
  1001. TARGETNAMEONLY="`basename $FINALFILE`"
  1002. if [ "`echo -n "$TARGETNAMEONLY" | grep "STARCHAR"`" != "" ];then
  1003. #if template file has text STARCHAR in it, replace with wildcard ...
  1004. globTARGETNAMEONLY="`echo -n "$TARGETNAMEONLY" | sed -e 's%STARCHAR%*%'`"
  1005. cp -a --remove-destination ${ALTTMPPATH}/${globTARGETNAMEONLY} ${ALTTARGETPATH}/ 2>/dev/null
  1006. else
  1007. cp -a --remove-destination ${ALTTMPPATH}/${TMPLNAMEONLY} ${ALTTARGETPATH}/${TARGETNAMEONLY} 2>/dev/null
  1008. fi
  1009. fi
  1010. done
  1011. #prune target dirs that are not in template (unless PLUSEXTRADIRS file exists in path)...
  1012. PLUSEXTRADIRS='no'
  1013. TESTPATH="$TEMPLATEPATH"
  1014. while [ "$TESTPATH" != "packages-templates" ];do
  1015. if [ -f $TESTPATH/PLUSEXTRADIRS ];then
  1016. PLUSEXTRADIRS='yes'
  1017. break
  1018. fi
  1019. TESTPATH="`dirname $TESTPATH`"
  1020. done
  1021. if [ "$PLUSEXTRADIRS" = "no" ];then
  1022. TEMPLATEDIRS="`find $TEMPLATEPATH -maxdepth 1 -type d | rev | cut -f 1 -d '/' | rev`"
  1023. # #w002 bug if 'PKGVERSION' is in template path...
  1024. #upPATTERN="s%PKGVERSION%${UPKGVERSION}%"
  1025. #xTEMPLATEDIRS="`echo "$TEMPLATEDIRS" | sed -e "$upPATTERN"`"
  1026. xTEMPLATEDIRS="$TEMPLATEDIRS"
  1027. for ONETARGETDIR in `find $TARGETPATH -mindepth 1 -maxdepth 1 -type d | rev | cut -f 1 -d '/' | rev` #120514 added -mindepth
  1028. do
  1029. #w002 precaution. dunno why, some pkgs in packages-woof are disappearing...
  1030. [ `echo -n "$TARGETPATH/$ONETARGETDIR" | sed -e 's%[^/]%%g' | wc -c` -le 1 ] && continue
  1031. tPATTERN='^'"$ONETARGETDIR"'$'
  1032. if [ "`echo "$xTEMPLATEDIRS" | grep "$tPATTERN"`" = "" ];then
  1033. tPATTERN="packages-${DISTRO_FILE_PREFIX}/"
  1034. [ "`echo "$TARGETPATH/$ONETARGETDIR" | grep "$tPATTERN"`" != "" ] && rm -rf $TARGETPATH/$ONETARGETDIR #test is paranoid precaution.
  1035. fi
  1036. done
  1037. fi
  1038. #if this dir in template has symlink(s), assume they are also required in target _EXE pkg...
  1039. gnPATTERN="s%raw/${GENERICNAME}/%raw/${GENERICNAME}_DEV/%"
  1040. DEVTARGETPATH="`echo -n "$TARGETPATH" | sed -e "$gnPATTERN"`"
  1041. if [ ! -d $DEVTARGETPATH ];then
  1042. gnPATTERN="s%raw/${GENERICNAME}/%raw/${GENERICNAME}_NULL/%"
  1043. DEVTARGETPATH="`echo -n "$TARGETPATH" | sed -e "$gnPATTERN"`"
  1044. fi
  1045. if [ "$TEMPLATELINKS" != "" -a -d $DEVTARGETPATH ];then
  1046. for ONEDEVLINK in `find $DEVTARGETPATH -maxdepth 1 -type l 2>/dev/null`
  1047. do
  1048. if [ "`readlink $ONEDEVLINK | grep '^/'`" != "" ];then #absolute link
  1049. READLINK="`readlink $ONEDEVLINK`"
  1050. [ ! -e packages-templates/${GENERICNAME}${READLINK} ] && continue
  1051. fi
  1052. TARGETLINK="`basename $ONEDEVLINK`"
  1053. [ ! -e $TARGETPATH/$TARGETLINK ] && [ ! -L $TARGETPATH/$TARGETLINK ] && cp -af ${ONEDEVLINK} ${TARGETPATH}/
  1054. done
  1055. fi
  1056. #um, above not quite enough, do this too...
  1057. if [ "$TEMPLATELINKS" != "" ];then
  1058. for ONETEMPLATELINK in $TEMPLATELINKS
  1059. do
  1060. TARGETLINKNAME="`basename $ONETEMPLATELINK`"
  1061. if [ ! -e $TARGETPATH/$TARGETLINKNAME ];then
  1062. mkdir -p $TARGETPATH
  1063. cp -a -f $TEMPLATEPATH/$TARGETLINKNAME $TARGETPATH/
  1064. fi
  1065. done
  1066. fi
  1067. #removed this, leave removal of invalid links to 3builddistro, as an individual
  1068. #pkg may have a link that is only valid in the final rootfs...
  1069. #for ONETARGETLINK in `find $TARGETPATH -maxdepth 1 -type l`
  1070. #do
  1071. # #NOTE: only works for relative links...
  1072. # TARGETLINKNAME="`basename $ONETARGETLINK`"
  1073. # [ "`readlink -e $ONETARGETLINK`" = "" ] && rm -f $TARGETPATH/$TARGETLINKNAME
  1074. #done
  1075. done
  1076. #a last resort fixup, if 'FIXUPHACK' exists, execute it... 111204 DISABLE_POST_INSTALL_SCRIPT code moved up.
  1077. #if [ -f packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK ];then
  1078. if [ -f packages-templates/$GENERICNAME/FIXUPHACK ];then #111210
  1079. cp -af packages-templates/$GENERICNAME/FIXUPHACK packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/ #111210
  1080. #DPIS="`grep 'DISABLE_POST_INSTALL_SCRIPT' packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK`"
  1081. #export UPKGVERSION
  1082. if [ "$EXE" = "_DEV" ];then #w091019
  1083. #only have _DEV dir so this is where must run FIXUPHACK...
  1084. mv -f packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV/
  1085. cd packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV/
  1086. else
  1087. cd packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/
  1088. fi
  1089. sh ./FIXUPHACK
  1090. cd ../..
  1091. #see examples templates coreutils and openssh_client (needed for slackware pkgs)...
  1092. #DISABLE_POST_INSTALL_SCRIPT=no
  1093. #[ "$DPIS" != "" ] && eval "$DPIS"
  1094. #[ "$DISABLE_POST_INSTALL_SCRIPT" = "yes" ] && rm -f /tmp/2createpackages-hack-install.sh 2>/dev/null #sandbox2b/hack-install.sh
  1095. #...note, slackware post-install script is executed near bottom of this script.
  1096. [ -f packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK ] && rm -f packages-${DISTRO_FILE_PREFIX}/$GENERICNAME/FIXUPHACK
  1097. [ -f packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV/FIXUPHACK ] && rm -f packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_DEV/FIXUPHACK #w091019
  1098. fi
  1099. fi
  1100. ###DEV,EXE###
  1101. #ubuntu splits up pkgs sometimes a symlink points to nothing until in the final build.
  1102. #put them into the _DEV pkg. ex: gcc_dev: usr/lib/gcc/i486-linux-gnu/4.3/libgcc_s.so.
  1103. #note, 3builddistro checks rootfs-complete for invalid symlinks, moves them to devx.
  1104. cd sandbox2b
  1105. find ./ -type l | sed -e 's/^\.\///' |
  1106. while read ONESYMLINK
  1107. do
  1108. UPONE="`dirname "$ONESYMLINK"`"
  1109. [ "$UPONE" = "." ] && UPONE=""
  1110. DESTFILE="`readlink $ONESYMLINK`"
  1111. if [ "`echo -n "$DESTFILE" | cut -c 1`" = "/" ];then
  1112. exePATHSPEC="../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}${DESTFILE}"
  1113. devPATHSPEC="../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}${DESTFILE}"
  1114. else
  1115. exePATHSPEC="../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${UPONE}/${DESTFILE}"
  1116. devPATHSPEC="../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${UPONE}/${DESTFILE}"
  1117. fi
  1118. if [ -e $exePATHSPEC ];then
  1119. if [ ! -e ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${ONESYMLINK} ];then
  1120. mkdir -p ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${UPONE}
  1121. cp -a "$ONESYMLINK" ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${EXE}/${UPONE}
  1122. fi
  1123. continue
  1124. fi
  1125. if [ -e $devPATHSPEC ];then
  1126. if [ ! -e ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${ONESYMLINK} ];then
  1127. mkdir -p ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${UPONE}
  1128. cp -a "$ONESYMLINK" ../packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}${DEV}/${UPONE}
  1129. fi
  1130. continue
  1131. fi
  1132. mkdir -p "../sandbox2c/${GENERICNAME}/${UPONE}"
  1133. cp -a --remove-destination "$ONESYMLINK" "../sandbox2c/${GENERICNAME}/${UPONE}"
  1134. done
  1135. cd ..
  1136. [ -d packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_NULL ] && rm -rf packages-${DISTRO_FILE_PREFIX}/${GENERICNAME}_NULL
  1137. [ -d /tmp/${GENERICNAME} ] && rm -rf /tmp/${GENERICNAME}
  1138. done #process next GENERICNAME.
  1139. if [ -s /tmp/2createpackages-redo ];then #091211
  1140. for ONEREDO in `cat /tmp/2createpackages-redo`
  1141. do
  1142. ./2createpackages $ONEREDO
  1143. done
  1144. fi
  1145. echo
  1146. echo "Script finished."
  1147. if [ -s ERROR-2CREATEPACKAGES ];then
  1148. echo "WARNING: Errors were logged to file ERROR-2CREATEPACKAGES"
  1149. fi
  1150. echo -n "Press ENTER key to exit: "
  1151. read yeahgetout
  1152. ###END###