createpets 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. #!/bin/sh
  2. #(c) copyright Barry Kauler June 2012
  3. #i wrote another script 'createpackages' that extracts all of the binary pkgs out of a Gentoo distro.
  4. #(i had a sd card image for the raspi).
  5. #'createpets' converts those binary pkgs into pet pkgs.
  6. . /etc/xdg/menus/hierarchy #has PUPHIERARCHY variable.
  7. CURRPATH="`pwd`"
  8. WOOF_HOSTARCH='x86'
  9. WOOF_TARGETARCH='arm'
  10. NLS='_NLS'
  11. EXE=''
  12. DEV='_DEV'
  13. DOC='_DOC'
  14. DB_compileddistro='puppy'
  15. DB_compiledrelease='ap6' #"Arm Puppy for armv6"
  16. DBFILE="Packages-${DB_compileddistro}-${DB_compiledrelease}-official"
  17. #paths ***SET THESE TO SUIT YOURSELF***
  18. BINDIR='0-armv6-gentoo-bin-pkgs' #location of the binary pkgs
  19. DESTDIR="${CURRPATH}/0-armv6-pets-from-bin-pkgs" #where the pet pkgs are to be created. Note: need absolute path.
  20. [ -d $DESTDIR ] && rm -rf ${CURRPATH}/0-armv6-pets-from-bin-pkgs/*
  21. TEMPLATES='packages-templates' #copy this dir out of woof, if running this script elsewhere.
  22. FIND_CAT='./find_cat' #copy this executable out of woof.
  23. [ ! -d $BINDIR ] && exit #sanity check.
  24. mkdir -p $DESTDIR
  25. [ -d sandbox2 ] && rm -rf sandbox2
  26. mkdir -p sandbox2
  27. echo -n "" > $DBFILE
  28. #db fields: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  29. for APKGNAME in `find ${BINDIR} -mindepth 1 -maxdepth 1 -type d | tr '\n' ' '`
  30. do
  31. baseAPKGNAME="`basename $APKGNAME`"
  32. echo "Processing $baseAPKGNAME"
  33. destAPKGNAME="`echo -n "$baseAPKGNAME" | tr '[A-Z]' '[a-z]'`" #ex: abiword-1.2.3-r1
  34. [ -d ${DESTDIR}/${destAPKGNAME}-${DB_compiledrelease} ] && destAPKGNAME="${destAPKGNAME}-SECOND" #precaution.
  35. [ -d ${DESTDIR}/${destAPKGNAME}-SECOND-${DB_compiledrelease} ] && destAPKGNAME="${destAPKGNAME}-THIRD" #precaution.
  36. #cp -a -f $APKGNAME ${DESTDIR}/${destAPKGNAME}
  37. rm -rf sandbox2/* 2>/dev/null
  38. cp -a -f ${APKGNAME}/* sandbox2/
  39. sync
  40. NAMEONLY="$(echo -n "$destAPKGNAME" | sed -e 's%\-[0-9][0-9.\-].*%%')"
  41. vPTN="s%${NAMEONLY}\-%%"
  42. PKGVERSION="$(echo -n "$destAPKGNAME" | sed -e "$vPTN")"
  43. if [ ! "$PKGVERSION" ];then #destAPKGNAME=abiword-1 does not get split properly.
  44. NAMEONLY="$(echo -n "$destAPKGNAME" | sed -e 's%\-[0-9].*%%')"
  45. vPTN="s%${NAMEONLY}\-%%"
  46. PKGVERSION="$(echo -n "$destAPKGNAME" | sed -e "$vPTN")"
  47. fi
  48. GENERICNAME="$NAMEONLY"
  49. UPKGVERSION="$(echo -n "$PKGVERSION" | sed -e 's%\-r[0-9].*%%')" #ex: 2.3-r1 becomes 2.3
  50. if [ -f ${APKGNAME}/DESCRIPTION ];then
  51. DB_description="$(cat ${APKGNAME}/DESCRIPTION)"
  52. else
  53. DB_description='no description'
  54. fi
  55. DB_category="`${FIND_CAT} $NAMEONLY "$DB_description"`"
  56. #fix icon and category in .desktop file...
  57. #code from 2createpackages...
  58. DEFICON='Executable.xpm'
  59. CATEGORY="$DB_category"
  60. case $CATEGORY in
  61. Desktop) CATEGORY='Desktop;X-Desktop' ; DEFICON='mini.window3d.xpm' ;;
  62. System) CATEGORY='System' ; DEFICON='mini-term.xpm' ;;
  63. Setup) CATEGORY='Setup;X-SetupEntry' ; DEFICON='so.xpm' ;;
  64. Utility) CATEGORY='Utility' ; DEFICON='mini-hammer.xpm' ;;
  65. Filesystem) CATEGORY='Filesystem;FileSystem' ; DEFICON='mini-filemgr.xpm' ;;
  66. Graphic) CATEGORY='Graphic;Presentation' ; DEFICON='image_2.xpm' ;;
  67. Document) CATEGORY='Document;X-Document' ; DEFICON='mini-doc1.xpm' ;;
  68. Business) CATEGORY='Business;X-Calculate' ; DEFICON='mini-calc.xpm' ;; #110821 Calculate is old name, now Business.
  69. Personal) CATEGORY='Personal;X-Personal' ; DEFICON='mini-book2.xpm' ;;
  70. Network) CATEGORY='Network' ; DEFICON='pc-2x.xpm' ;;
  71. Internet) CATEGORY='Internet;X-Internet' ; DEFICON='pc2www.xpm' ;;
  72. Multimedia) CATEGORY='Multimedia;AudioVideo' ; DEFICON='Animation.xpm' ;;
  73. Fun) CATEGORY='Fun;Game' ; DEFICON='mini-maze.xpm' ;;
  74. Develop) CATEGORY='Utility' ; DEFICON='mini-hex.xpm' ;;
  75. Help) CATEGORY='Utility' ; DEFICON='info16.xpm' ;;
  76. esac
  77. cPATTERN="s%^Categories=.*%Categories=${CATEGORY}%"
  78. iPATTERN="s%^Icon=.*%Icon=${DEFICON}%"
  79. for ONEDESKTOP in `find sandbox2/usr/share/applications sandbox2/usr/local/share/applications -type f -name '*.desktop' 2>/dev/null | tr '\n' ' '`
  80. do
  81. #find if category is already valid...
  82. CATFOUND="no"
  83. for ONEORIGCAT in `cat $ONEDESKTOP | grep '^Categories=' | head -n 1 | cut -f 2 -d '=' | tr ';' ' '`
  84. do
  85. oocPATTERN=' '"$ONEORIGCAT"' '
  86. [ "`echo "$PUPHIERARCHY" | tr -s ' ' | cut -f 3 -d ' ' | tr ',' ' ' | sed -e 's%^% %' -e 's%$% %' | grep "$oocPATTERN"`" != "" ] && CATFOUND="yes"
  87. done
  88. if [ "$CATFOUND" = "no" ];then
  89. sed -e "$cPATTERN" $ONEDESKTOP > /tmp/2createpackages-tmp
  90. mv -f /tmp/2createpackages-tmp $ONEDESKTOP
  91. fi
  92. #does the icon exist?... fix .desktop...
  93. ICON="`grep '^Icon=' $ONEDESKTOP | cut -f 2 -d '='`"
  94. if [ "$ICON" != "" ];then
  95. [ -e "sandbox2${ICON}" ] && continue #it may have a hardcoded path.
  96. [ -e "${ICON}" ] && continue #it may have a hardcoded path, look in running puppy.
  97. ICONBASE="`basename "$ICON"`"
  98. #first search where jwm looks for icons... check if paths exist...
  99. FNDICON=""
  100. [ -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`"
  101. [ ! "$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`"
  102. if [ "$FNDICON" ];then
  103. ICONNAMEONLY="`basename $FNDICON`"
  104. iPTN="s%^Icon=.*%Icon=${ICONNAMEONLY}%"
  105. sed -i -e "$iPTN" $ONEDESKTOP
  106. continue
  107. else
  108. #look elsewhere, including in running puppy... fix for parole /usr/share/parole/parole.png...
  109. 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`"
  110. if [ "$FNDICON" ];then
  111. ICONNAMEONLY="`basename "$FNDICON"`"
  112. mkdir -p sandbox2/usr/share/pixmaps
  113. ln -snf "$FNDICON" sandbox2/usr/share/pixmaps/${ICONNAMEONLY}
  114. iPTN="s%^Icon=.*%Icon=${ICONNAMEONLY}%"
  115. sed -i -e "$iPTN" $ONEDESKTOP
  116. continue
  117. fi
  118. fi
  119. #substitute a default icon...
  120. sed -i -e "$iPATTERN" $ONEDESKTOP
  121. fi
  122. done
  123. #now process sandbox2 and create split rootfs, devx, docs, nls...
  124. cd sandbox2
  125. #now to split pkg into exe,dev,doc,nls components...
  126. #this will find all files and symlinks to files...
  127. find -L ./ -noleaf -type f | sed -e 's/^\.\///' |
  128. while read ONEFILE
  129. do
  130. #problem, coming here with paths that have symlinks...
  131. UPONE="`dirname "$ONEFILE"`"
  132. while [ "$UPONE" != "." -a "$UPONE" != "/" ];do
  133. [ -h "$UPONE" ] && continue 2
  134. UPONE="`dirname "$UPONE"`"
  135. done
  136. ONEBASE="`basename "$ONEFILE"`"
  137. ONEPATH="`dirname "$ONEFILE"`"
  138. [ "$ONEPATH" = "." ] && ONEPATH=""
  139. #strip the file...
  140. #but not if a cross-build (see file WOOFMERGEVARS), strip won't work...
  141. if [ "$WOOF_HOSTARCH" = "$WOOF_TARGETARCH" ];then
  142. if [ "`which strip`" != "" ];then #needs devx.
  143. if [ ! -h "$ONEFILE" ];then #make sure it isn't a symlink
  144. [ ! "`file "$ONEFILE" | grep 'ELF' | grep 'shared object'`" = "" ] && strip --strip-debug "$ONEFILE"
  145. [ ! "`file "$ONEFILE" | grep 'ELF' | grep 'executable'`" = "" ] && strip --strip-unneeded "$ONEFILE"
  146. fi
  147. fi
  148. fi
  149. sync
  150. ###NLS###
  151. #find out if this is an international language file...
  152. if [ "`echo -n "$ONEFILE" | grep --extended-regexp '/locale/|/nls/|/i18n/'`" != "" ];then
  153. if [ "`echo -n "$ONEFILE" | grep 'share/X11/locale/'`" = "" ];then #T2, need Xorg locale files in main pkg.
  154. [ "$NLS" = "_NULL" ] && continue #just dump it.
  155. mkdir -p "${DESTDIR}/${NAMEONLY}${NLS}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  156. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${NLS}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  157. continue
  158. fi
  159. fi
  160. ###DOC###
  161. #find out if this is a documentation file...
  162. if [ ! "`echo -n "$ONEFILE" | grep --extended-regexp '/man/|/doc/|/doc-base/|/docs/|/info/|/gtk-doc/|/faq/|/manual/|/examples/|/help/|/htdocs/'`" = "" ];then
  163. [ "$DOC" = "_NULL" ] && continue #just dump it.
  164. mkdir -p "${DESTDIR}/${NAMEONLY}${DOC}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  165. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${DOC}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  166. continue
  167. fi
  168. ###DEV###
  169. #find out if this is development file...
  170. if [ ! "`echo -n "$ONEFILE" | grep --extended-regexp 'X11/config/|/include/|/pkgconfig/|/aclocal|/cvs/|/svn/'`" = "" ];then
  171. mkdir -p "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  172. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  173. continue
  174. fi
  175. #find *.so symlink files...
  176. if [ -h "$ONEFILE" ];then #-h tests for symlink
  177. if [ ! "`echo -n "$ONEFILE" | grep '\.so$'`" = "" ];then
  178. mkdir -p "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  179. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  180. continue
  181. fi
  182. fi
  183. #find various config files...
  184. if [ ! "`echo -n "$ONEBASE" | grep --extended-regexp '\-config$|config.sh$|Conf.sh$'`" = "" ];then
  185. mkdir -p "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  186. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  187. continue
  188. fi
  189. #all .a and .la files... and any stray .m4 files...
  190. if [ ! "`echo -n "$ONEBASE" | grep --extended-regexp '\.a$|\.la$|\.m4$'`" = "" ];then
  191. mkdir -p "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  192. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${DEV}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  193. continue
  194. fi
  195. ###EXE###
  196. #anything left over goes into the main 'executable' package...
  197. mkdir -p "${DESTDIR}/${NAMEONLY}${EXE}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}"
  198. cp -af "$ONEFILE" "${DESTDIR}/${NAMEONLY}${EXE}-${PKGVERSION}-${DB_compiledrelease}/${ONEPATH}" 2>/dev/null
  199. done
  200. cd ..
  201. #now do some post-processing using "template" found in 'packages-templates'...
  202. if [ -d ${TEMPLATES}/$GENERICNAME ];then
  203. echo " postprocessing with ${TEMPLATES}/$GENERICNAME"
  204. rm -rf /tmp/createpets-backup-pkg 2>/dev/null
  205. cp -a ${DESTDIR}/${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease} /tmp/createpets-backup-pkg
  206. for TEMPLATEPATH in `find ${TEMPLATES}/$GENERICNAME -type d`
  207. do
  208. TEMPLATEFILES="`find $TEMPLATEPATH -maxdepth 1 -type f`"
  209. TEMPLATELINKS="`find $TEMPLATEPATH -maxdepth 1 -type l`"
  210. #some dirs in template renamed with "PKGVERSION" in the name...
  211. upPATTERN="s%PKGVERSION%${UPKGVERSION}%"
  212. ppPATTERN="s%${TEMPLATES}/${GENERICNAME}%${DESTDIR}/${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease}%"
  213. TARGETPATH="`echo -n "$TEMPLATEPATH" | sed -e "$ppPATTERN" | sed -e "$upPATTERN"`"
  214. mkdir -p $TARGETPATH
  215. tPTN="s%${TEMPLATES}/${GENERICNAME}%/tmp/createpets-backup-pkg%"
  216. TMPPATH="`echo -n "$TEMPLATEPATH" | sed -e "$tPTN" | sed -e "$upPATTERN"`"
  217. #bit radical, but if dir in template has one or more files, truncate those in target...
  218. if [ ! -f $TEMPLATEPATH/PLUSEXTRAFILES ];then #marker-file, that all files in deb to be kept.
  219. tPATTERN="${DESTDIR}/"
  220. [ "$DESTDIR" = "" ] && exit #another paranoid precaution.
  221. [ "`echo "$TARGETPATH" | grep "$tPATTERN"`" = "" ] && continue #paranoid precaution! (see next line)...
  222. #if [ "$TEMPLATEFILES" != "" ];then
  223. for ONEDEL in `find ${TARGETPATH} -maxdepth 1 -type f` #ignore symlinks.
  224. do
  225. #if file has any versioning info, do not delete...
  226. DELBASE="`basename $ONEDEL`"
  227. #if dir has NOEXCEPTIONFILES then do not allow these exceptions...
  228. [ ! -f $TEMPLATEPATH/NOEXCEPTIONFILES ] && [ "`echo "$DELBASE" | grep -E '\.[0-9]*\.|\.[0-9]*$|\-[0-9]*\.|[0-9]\.so$|\.so\.[0-9]'`" != "" ] && continue
  229. ##sometimes regular file but template has symlink of same name (ex: /usr/bin/gnumeric). do not delete...
  230. #[ -L ${TEMPLATEPATH}/${DELBASE} ] && continue
  231. rm $ONEDEL
  232. done
  233. #fi
  234. fi
  235. #if file exists in template, non-0 copy it from template to target, 0-size copy from deb pkg to target...
  236. for FINALFILE in $TEMPLATEFILES
  237. do
  238. ALTTARGETPATH="$TARGETPATH"
  239. ALTTMPPATH="$TMPPATH"
  240. TMPLNAMEONLY="`basename $FINALFILE -FULL`" #coreutils & util-linux have some file-FULL.
  241. if [ ! -f $TMPPATH/$TMPLNAMEONLY ];then
  242. if [ "/tmp/createpets-backup-pkg" != "$TMPPATH" ];then #ignore top level.
  243. if [ "`echo -n "$TMPPATH" | grep -E "/root|/etc|/dev|/var/"`" = "" ];then #ignore if file in /root or /etc or /dev
  244. #if the target file is somewhere else, find it...
  245. ALTLOCATION="`find /tmp/createpets-backup-pkg -type f -name $TMPLNAMEONLY | head -n 1`"
  246. if [ "$ALTLOCATION" != "" ];then
  247. #ALTTARGETPATH="`dirname $ALTLOCATION | sed -e 's%^/tmp/%${DESTDIR}/%'`"
  248. [ "`file "$ALTLOCATION" | grep ' text'`" = "" ] && ALTTMPPATH="`dirname $ALTLOCATION`" #ignore text file.
  249. else
  250. #a hack, util-linux has 'rename.ul', presume ubuntu have renamed it so as not to conflict
  251. #with some other 'rename'....
  252. ALTLOCATION="`find /tmp/createpets-backup-pkg -type f -name ${TMPLNAMEONLY}.ul | head -n 1`"
  253. if [ "$ALTLOCATION" != "" ];then
  254. ALTTMPPATH="`dirname $ALTLOCATION`"
  255. TMPLNAMEONLY="$TMPLNAMEONLY"'.ul'
  256. #else
  257. # echo "WARNING: Not found in .deb: $FINALFILE"
  258. fi
  259. fi
  260. fi
  261. fi
  262. fi
  263. if [ -s $FINALFILE ];then
  264. #all non-0-size files must be copied from template to final pkg...
  265. cp -af $FINALFILE $ALTTARGETPATH/
  266. else
  267. #zero-size file. copy from the backup made in /tmp/createpets-backup-pkg to final pkg...
  268. TARGETNAMEONLY="`basename $FINALFILE`"
  269. if [ "`echo -n "$TARGETNAMEONLY" | grep "STARCHAR"`" != "" ];then
  270. #if template file has text STARCHAR in it, replace with wildcard ...
  271. globTARGETNAMEONLY="`echo -n "$TARGETNAMEONLY" | sed -e 's%STARCHAR%*%'`"
  272. cp -a --remove-destination ${ALTTMPPATH}/${globTARGETNAMEONLY} ${ALTTARGETPATH}/ 2>/dev/null
  273. else
  274. cp -a --remove-destination ${ALTTMPPATH}/${TMPLNAMEONLY} ${ALTTARGETPATH}/${TARGETNAMEONLY} 2>/dev/null
  275. fi
  276. fi
  277. done
  278. #prune target dirs that are not in template (unless PLUSEXTRADIRS file exists in path)...
  279. PLUSEXTRADIRS='no'
  280. TESTPATH="$TEMPLATEPATH"
  281. while [ "$TESTPATH" != "${TEMPLATES}" ];do
  282. if [ -f $TESTPATH/PLUSEXTRADIRS ];then
  283. PLUSEXTRADIRS='yes'
  284. break
  285. fi
  286. TESTPATH="`dirname $TESTPATH`"
  287. done
  288. if [ "$PLUSEXTRADIRS" = "no" ];then
  289. TEMPLATEDIRS="`find $TEMPLATEPATH -maxdepth 1 -type d | rev | cut -f 1 -d '/' | rev`"
  290. #bug if 'PKGVERSION' is in template path...
  291. upPATTERN="s%PKGVERSION%${UPKGVERSION}%"
  292. xTEMPLATEDIRS="`echo "$TEMPLATEDIRS" | sed -e "$upPATTERN"`"
  293. for ONETARGETDIR in `find $TARGETPATH -mindepth 1 -maxdepth 1 -type d | rev | cut -f 1 -d '/' | rev`
  294. do
  295. #precaution. dunno why, some pkgs in packages-woof are disappearing...
  296. [ `echo -n "$TARGETPATH/$ONETARGETDIR" | sed -e 's%[^/]%%g' | wc -c` -le 1 ] && continue
  297. tPATTERN='^'"$ONETARGETDIR"'$'
  298. if [ "`echo "$xTEMPLATEDIRS" | grep "$tPATTERN"`" = "" ];then
  299. tPATTERN="${DESTDIR}/"
  300. [ "`echo "$TARGETPATH/$ONETARGETDIR" | grep "$tPATTERN"`" != "" ] && rm -rf $TARGETPATH/$ONETARGETDIR #test is paranoid precaution.
  301. fi
  302. done
  303. fi
  304. #if this dir in template has symlink(s), assume they are also required in target _EXE pkg...
  305. gnPATTERN="s%raw/${GENERICNAME}/%raw/${GENERICNAME}_DEV/%"
  306. DEVTARGETPATH="`echo -n "$TARGETPATH" | sed -e "$gnPATTERN"`"
  307. if [ ! -d $DEVTARGETPATH ];then
  308. gnPATTERN="s%raw/${GENERICNAME}/%raw/${GENERICNAME}_NULL/%"
  309. DEVTARGETPATH="`echo -n "$TARGETPATH" | sed -e "$gnPATTERN"`"
  310. fi
  311. if [ "$TEMPLATELINKS" != "" -a -d $DEVTARGETPATH ];then
  312. for ONEDEVLINK in `find $DEVTARGETPATH -maxdepth 1 -type l 2>/dev/null`
  313. do
  314. if [ "`readlink $ONEDEVLINK | grep '^/'`" != "" ];then #absolute link
  315. READLINK="`readlink $ONEDEVLINK`"
  316. [ ! -e ${TEMPLATES}/${GENERICNAME}${READLINK} ] && continue
  317. fi
  318. TARGETLINK="`basename $ONEDEVLINK`"
  319. [ ! -e $TARGETPATH/$TARGETLINK ] && [ ! -L $TARGETPATH/$TARGETLINK ] && cp -af ${ONEDEVLINK} ${TARGETPATH}/
  320. done
  321. fi
  322. #um, above not quite enough, do this too...
  323. if [ "$TEMPLATELINKS" != "" ];then
  324. for ONETEMPLATELINK in $TEMPLATELINKS
  325. do
  326. TARGETLINKNAME="`basename $ONETEMPLATELINK`"
  327. if [ ! -e $TARGETPATH/$TARGETLINKNAME ];then
  328. mkdir -p $TARGETPATH
  329. cp -a -f $TEMPLATEPATH/$TARGETLINKNAME $TARGETPATH/
  330. fi
  331. done
  332. fi
  333. done
  334. #a last resort fixup, if 'FIXUPHACK' exists, execute it... DISABLE_POST_INSTALL_SCRIPT code moved up.
  335. #if [ -f ${DESTDIR}/$GENERICNAME/FIXUPHACK ];then
  336. if [ -f ${TEMPLATES}/$GENERICNAME/FIXUPHACK ];then #111210
  337. cp -af ${TEMPLATES}/$GENERICNAME/FIXUPHACK ${DESTDIR}/${NAMEONLY}${EXE}-${PKGVERSION}-${DB_compiledrelease}/
  338. #DPIS="`grep 'DISABLE_POST_INSTALL_SCRIPT' ${DESTDIR}/$GENERICNAME/FIXUPHACK`"
  339. export UPKGVERSION
  340. if [ "$EXE" = "_DEV" ];then
  341. #only have _DEV dir so this is where must run FIXUPHACK...
  342. mv -f ${DESTDIR}/$GENERICNAME/FIXUPHACK ${DESTDIR}/${NAMEONLY}_DEV-${PKGVERSION}-${DB_compiledrelease}/
  343. cd ${DESTDIR}/${NAMEONLY}_DEV-${PKGVERSION}-${DB_compiledrelease}/
  344. else
  345. cd ${DESTDIR}/${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease}/
  346. fi
  347. sh ./FIXUPHACK
  348. cd $CURRPATH
  349. [ -f ${DESTDIR}/${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease}/FIXUPHACK ] && rm -f ${DESTDIR}/${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease}/FIXUPHACK
  350. [ -f ${DESTDIR}/${NAMEONLY}_DEV-${PKGVERSION}-${DB_compiledrelease}/FIXUPHACK ] && rm -f ${DESTDIR}/${NAMEONLY}_DEV-${PKGVERSION}-${DB_compiledrelease}/FIXUPHACK
  351. fi
  352. fi
  353. #for each created dir, create 'pet.specs' file, create pet pkgs...
  354. if [ -f ${APKGNAME}/DEPEND ];then
  355. DB_dependencies="$(cat ${APKGNAME}/DEPEND | tr ' ' '\n' | rev | cut -f 1 -d '/' | rev | cut -f 1 -d ':' | cut -f 1 -d '[' | sed -e 's%\-[0-9][0-9.\-].*%%' -e 's%\-[0-9]$%%' -e 's%^%+%' | sed -e 's%$%,%' | sort -u | tr '\n' ' ' | tr -d ' ' | sed -e 's%,$%%' | tr '[A-Z]' '[a-z]')"
  356. else
  357. DB_dependencies=''
  358. fi
  359. #db fields: pkgname|nameonly|version|pkgrelease|category|size|path|fullfilename|dependencies|description|compileddistro|compiledrelease|repo|
  360. if [ -d ${DESTDIR}/${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease} ];then
  361. DB_pkgname="${NAMEONLY}-${PKGVERSION}-${DB_compiledrelease}"
  362. DB_nameonly="${NAMEONLY}"
  363. DB_version="${PKGVERSION}-${DB_compiledrelease}"
  364. DB_size="`du -k -s ${DESTDIR}/${DB_pkgname} | cut -f 1`"
  365. DB_fullfilename="${DB_pkgname}.pet"
  366. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" > ${DESTDIR}/${DB_pkgname}/pet.specs
  367. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" >> $DBFILE
  368. DB_dependencies="+${NAMEONLY}"
  369. [ -f ${DESTDIR}/${DB_pkgname}/CATEGORY ] && rm -f ${DESTDIR}/${DB_pkgname}/CATEGORY
  370. [ -f ${DESTDIR}/${DB_pkgname}/DEPEND ] && rm -f ${DESTDIR}/${DB_pkgname}/DEPEND
  371. [ -f ${DESTDIR}/${DB_pkgname}/DESCRIPTION ] && rm -f ${DESTDIR}/${DB_pkgname}/DESCRIPTION
  372. [ -f ${DESTDIR}/${DB_pkgname}/RDEPEND ] && rm -f ${DESTDIR}/${DB_pkgname}/RDEPEND
  373. [ -f ${DESTDIR}/${DB_pkgname}/SIZE ] && rm -f ${DESTDIR}/${DB_pkgname}/SIZE
  374. #create pet pkg...
  375. cd $DESTDIR
  376. dir2tgz ${DB_pkgname}
  377. tgz2pet ${DB_pkgname}.tar.gz
  378. cd $CURRPATH
  379. fi
  380. if [ -d ${DESTDIR}/${NAMEONLY}_DEV-${PKGVERSION}-${DB_compiledrelease} ];then
  381. DB_pkgname="${NAMEONLY}_DEV-${PKGVERSION}-${DB_compiledrelease}"
  382. DB_nameonly="${NAMEONLY}_DEV"
  383. DB_version="${PKGVERSION}-${DB_compiledrelease}"
  384. DB_size="`du -k -s ${DESTDIR}/${DB_pkgname} | cut -f 1`"
  385. DB_fullfilename="${DB_pkgname}.pet"
  386. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" > ${DESTDIR}/${DB_pkgname}/pet.specs
  387. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" >> $DBFILE
  388. DB_dependencies="+${NAMEONLY}"
  389. [ -f ${DESTDIR}/${DB_pkgname}/CATEGORY ] && rm -f ${DESTDIR}/${DB_pkgname}/CATEGORY
  390. [ -f ${DESTDIR}/${DB_pkgname}/DEPEND ] && rm -f ${DESTDIR}/${DB_pkgname}/DEPEND
  391. [ -f ${DESTDIR}/${DB_pkgname}/DESCRIPTION ] && rm -f ${DESTDIR}/${DB_pkgname}/DESCRIPTION
  392. [ -f ${DESTDIR}/${DB_pkgname}/RDEPEND ] && rm -f ${DESTDIR}/${DB_pkgname}/RDEPEND
  393. [ -f ${DESTDIR}/${DB_pkgname}/SIZE ] && rm -f ${DESTDIR}/${DB_pkgname}/SIZE
  394. #create pet pkg...
  395. cd $DESTDIR
  396. dir2tgz ${DB_pkgname}
  397. tgz2pet ${DB_pkgname}.tar.gz
  398. cd $CURRPATH
  399. fi
  400. if [ -d ${DESTDIR}/${NAMEONLY}_NLS-${PKGVERSION}-${DB_compiledrelease} ];then
  401. DB_pkgname="${NAMEONLY}_NLS-${PKGVERSION}-${DB_compiledrelease}"
  402. DB_nameonly="${NAMEONLY}_NLS"
  403. DB_version="${PKGVERSION}-${DB_compiledrelease}"
  404. DB_size="`du -k -s ${DESTDIR}/${DB_pkgname} | cut -f 1`"
  405. DB_fullfilename="${DB_pkgname}.pet"
  406. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" > ${DESTDIR}/${DB_pkgname}/pet.specs
  407. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" >> $DBFILE
  408. DB_dependencies=""
  409. #create pet pkg...
  410. cd $DESTDIR
  411. dir2tgz ${DB_pkgname}
  412. tgz2pet ${DB_pkgname}.tar.gz
  413. cd $CURRPATH
  414. fi
  415. if [ -d ${DESTDIR}/${NAMEONLY}_DOC-${PKGVERSION}-${DB_compiledrelease} ];then
  416. DB_pkgname="${NAMEONLY}_DOC-${PKGVERSION}-${DB_compiledrelease}"
  417. DB_nameonly="${NAMEONLY}_DOC"
  418. DB_version="${PKGVERSION}-${DB_compiledrelease}"
  419. DB_size="`du -k -s ${DESTDIR}/${DB_pkgname} | cut -f 1`"
  420. DB_fullfilename="${DB_pkgname}.pet"
  421. DB_dependencies=""
  422. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" > ${DESTDIR}/${DB_pkgname}/pet.specs
  423. echo "${DB_pkgname}|${DB_nameonly}|${DB_version}||${DB_category}|${DB_size}K||${DB_fullfilename}|${DB_dependencies}|${DB_description}|${DB_compileddistro}|${DB_compiledrelease}||" >> $DBFILE
  424. #create pet pkg...
  425. cd $DESTDIR
  426. dir2tgz ${DB_pkgname}
  427. tgz2pet ${DB_pkgname}.tar.gz
  428. cd $CURRPATH
  429. fi
  430. sync
  431. done
  432. sort $DBFILE > /tmp/$DBFILE
  433. mv -f /tmp/$DBFILE $DBFILE
  434. sync
  435. ###END###