2createpackages 58 KB

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