mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1292 lines
39 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Build-Pkg
  11. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. exec 2>&1
  25. buildstart="`date "+%m/%d/%Y from %T"`"
  26. options=''
  27. config=default
  28. clear_src=1
  29. norebuild=0
  30. nopostinst=0
  31. update=0
  32. make_tar=''
  33. prefix="usr"
  34. prefix_auto=1
  35. pkgdir=""
  36. download=0
  37. verbose=0
  38. xtrace=0
  39. debug=0
  40. chroot=0
  41. root=""
  42. id=''
  43. desktopfiles=''
  44. desktopauto=1
  45. stagelevel=9
  46. this_is_the_2nd_run=0
  47. #
  48. # ---- Functions
  49. #
  50. help_msg() {
  51. spacer=" "
  52. echo
  53. echo "Usage: ./scripts/Build-Pkg" \
  54. "[ -0 | -1 | -2 ... | -8 | -9 ] \\"
  55. echo "$spacer [ -v ] [ -xtrace ] [ -chroot ] \\"
  56. echo "$spacer [ -root { <rootdir> | auto } ] [ -update ] \\"
  57. echo "$spacer [ -cfg <config> ] [ -nopostinst ] \\"
  58. echo "$spacer [ -prefix <prefix-dir> ] [ -norebuild ] \\"
  59. echo "$spacer [ -noclearsrc ] [ -pkgdir <pkgdir> ] \\"
  60. echo "$spacer [ -id <id> ] [ -debug ] pkg-name(s)"
  61. echo
  62. echo " Build a single package. Warning: Re-building a package might overwrite or"
  63. echo " remove configuration files; with the -update option modified files are backed"
  64. echo " up and restored after the package build. In most cases the other options are"
  65. echo " only needed by ./scripts/Build-Target when building the entire distribution."
  66. echo
  67. echo " -0, -1, ..., -9 set build stage to 0, 1, ..., 9, respectively"
  68. echo " -v be verbose"
  69. echo " -xtrace print additional xtrace (debug-)output to the"
  70. echo " build log file"
  71. echo " -chroot create and use a chroot environment"
  72. echo " -root { <rootdir> | auto } the root build directory to use;"
  73. echo " defaults to automatic setting"
  74. echo " -update backup/restore modified package files"
  75. echo " -cfg <config> the build configuration to use"
  76. echo " -nopostinst do not create postinstall files"
  77. echo " -prefix <prefix-dir> the installation prefix for packages;"
  78. echo " defaults to automatic setting"
  79. echo " -norebuild don't rebuild a previously successfully built package;"
  80. echo " if the \"retry broken\" Config option is set, don't"
  81. echo " rebuild unsuccessfully built packages, too"
  82. echo " -noclearsrc don't delete the package build directory (src.*)"
  83. echo " -pkgdir <pkgdir> path to package build config (package/..),"
  84. echo " either absolute or relative to ROCK Linux"
  85. echo " sources directory"
  86. echo " -id <id> use the given build id"
  87. echo " -debug enable debug mode: setup everything and exit before"
  88. echo " the actual build"
  89. echo " -download download missing source files"
  90. echo
  91. echo "Type './scripts/Help Build-Pkg' for details."
  92. echo
  93. }
  94. #
  95. # ---- Parse options + config and make Build-Pkg sub-calls
  96. #
  97. while [ "$1" ] ; do
  98. case "$1" in
  99. -this_is_the_2nd_run) this_is_the_2nd_run=1 ;;
  100. -[0-9]) options="$options $1" ; stagelevel=${1#-} ;;
  101. -v) options="$options $1" ; verbose=1 ;;
  102. -xtrace) options="$options $1" ; xtrace=1 ;;
  103. -debug) options="$options $1" ; debug=1 ; clear_src=0 ;;
  104. -update) options="$options $1" ; update=1 ;;
  105. -chroot) options="$options $1" ; chroot=1 ;;
  106. -chr-sub) options="$options $1" ; chroot=0 ;;
  107. -cfg) options="$options $1 $2" ; config="$2" ; shift ;;
  108. -root) options="$options $1 $2" ; root="$2" ; shift ;;
  109. -prefix) options="$options $1 $2" ;
  110. prefix_auto=0 ; prefix="$2" ; shift ;;
  111. -id) options="$options $1 $2" ; id="$2" ; shift ;;
  112. -pkgdir) options="$options $1 $2" ; pkgdir="$2" ; shift ;;
  113. -noclearsrc) options="$options $1" ; clear_src=0 ;;
  114. -norebuild) options="$options $1" ; norebuild=1 ;;
  115. -nopostinst) options="$options $1" ; nopostinst=1 ;;
  116. -download) options="$options $1" ; download=1 ;;
  117. -*) help_msg ; exit 1 ;;
  118. *) break ;;
  119. esac
  120. shift
  121. done
  122. # check if arguments are left as package names
  123. if [ $# = 0 ] ; then
  124. help_msg ; exit 1
  125. fi
  126. ./scripts/Check-System || exit 1
  127. export ROCK_CHECK_SYSTEM_OK=1
  128. . ./scripts/functions
  129. . ./scripts/parse-config
  130. if [ -z "$root" -a $stagelevel -le 1 ] || \
  131. [ -z "$root" -a $chroot -eq 1 ] || \
  132. [ "$root" = auto ]; then
  133. if [ $stagelevel -gt 0 ]; then root="build/$ROCKCFG_ID"
  134. else root="build/$ROCKCFG_ID/ROCK/$toolsdir"; fi
  135. fi
  136. [ "$pkgdir" -a "${pkgdir#/}" = "$pkgdir" ] && pkgdir="$base/$pkgdir"
  137. [ "$root" -a "${root#/}" = "$root" ] && root="$base/$root"
  138. prefix=${prefix%/} ; prefix=${prefix#/} ; root=${root%/}
  139. xroot="$root" ; [ $stagelevel -gt 1 ] && root=""
  140. if [ -z "$id" ] ; then
  141. id=`get_unique`
  142. options="$options -id $id"
  143. fi
  144. ./scripts/Build-Tools -$stagelevel -cfg $config || exit 1
  145. # more than one package are passed
  146. if [ $# -gt 1 ] ; then
  147. for x ; do
  148. if ! ./scripts/Build-Pkg $options $x && \
  149. [ "$ROCKCFG_ABORT_ON_ERROR" = 1 ] ; then
  150. exit 1
  151. fi
  152. done
  153. exit 0
  154. fi
  155. # parameter 1 has $pkg=$xpkg
  156. pkg="${1%=*}"; xpkg="${1#*=}"
  157. builddir="$base/src.$xpkg.$id"
  158. # get real pkg name for mapped packages
  159. . build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkgmapper
  160. # set desktop file name
  161. desktopfiles="$( echo ${base}/package/*/${pkg} )/*.desktop"
  162. export ROCK_PKG=$pkg
  163. export ROCK_XPKG=$xpkg
  164. mkdir -p "$builddir"; chmod 700 "$builddir"
  165. if [ "$chroot" = 1 ] ; then
  166. cd "$xroot" || exit 1
  167. x_mknod() {
  168. if [ ! -e "$1" ]; then
  169. mknod "$@"
  170. fi
  171. }
  172. mkdir -p dev/loop
  173. x_mknod dev/null c 1 3
  174. x_mknod dev/zero c 1 5
  175. x_mknod dev/random c 1 8
  176. x_mknod dev/urandom c 1 9
  177. x_mknod dev/loop/0 b 7 0
  178. x_mknod dev/loop/1 b 7 1
  179. x_mknod dev/loop/2 b 7 2
  180. x_mknod dev/loop/3 b 7 3
  181. x_mknod dev/tty c 5 0
  182. x_mknod dev/ptmx c 5 2
  183. if [ ! -L dev/fd ]; then
  184. ln -s /proc/self/fd dev/fd
  185. fi
  186. if [ "$ROCKCFG_PSEUDONATIVE" = 1 -a ! -f pseudonative_handler ]
  187. then
  188. echo_header "Preparing chroot dir for pseudonative build:"
  189. echo_status "Building pseudonative_handler."
  190. cc -static -o pseudonative_handler \
  191. $base/misc/tools-source/pseudonative_handler.c
  192. if [ ! -f /proc/sys/fs/binfmt_misc/register ] ; then
  193. echo_status "Mounting /proc/sys/fs/binfmt_misc."
  194. mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
  195. fi
  196. echo_status "Registering pseudonative_handler."
  197. sign="$( hexdump bin/bash | head -n2 | cut -f2- -d' ' | tr -d ' \n' | \
  198. cut -c 1-40 | sed -e 's,\(..\)\(..\),\\x\2\\x\1,g' )"
  199. echo ":${arch_machine}_rock_bin:M::$sign::/pseudonative_handler:" > /proc/sys/fs/binfmt_misc/register
  200. sign="$( hexdump lib/libc.so.[0-9] | head -n2 | cut -f2- -d' ' | tr -d ' \n' | \
  201. cut -c 1-40 | sed -e 's,\(..\)\(..\),\\x\2\\x\1,g' )"
  202. echo ":${arch_machine}_rock_lib:M::$sign::/pseudonative_handler:" > /proc/sys/fs/binfmt_misc/register
  203. echo_status "Creating pseudonative bindir."
  204. rm -rf ROCK/tools.cross/pseudonative.bin
  205. mkdir -p ROCK/tools.cross/pseudonative.bin
  206. cd ROCK/tools.cross
  207. while read f
  208. do
  209. b=$(basename $f)
  210. a=${b#$arch_target-}
  211. ln -sf ../$f pseudonative.bin/$b
  212. if [ "$a" != "$b" ]; then
  213. ln -sf ../$f pseudonative.bin/$a
  214. fi
  215. done < <(
  216. find crosscc lib libexec $arch_target wrapper -xtype f -perm +111 | \
  217. xargs file -L | grep ELF.*executable | cut -f1 -d:
  218. )
  219. echo_status "Applying some bin hotfixes."
  220. ln -s ../bin/true pseudonative.bin/umount
  221. ln -s ../bin/true pseudonative.bin/mount
  222. rm -f bin/uname pseudonative.bin/uname
  223. echo_status "Creating pseudonative libdir."
  224. rm -rf pseudonative.lib; mkdir -p pseudonative.lib
  225. cp /lib/ld-linux.so.* /lib/libc.so.* pseudonative.lib/
  226. cp /lib/libnss_compat.so.* pseudonative.lib/
  227. cp /lib/libnss_files.so.* pseudonative.lib/
  228. cd ../..
  229. echo_status "Creating fake rootdir-symlink."
  230. mkdir -p $( dirname ${xroot#/} )
  231. rm -f ${xroot#/}; ln -s / ${xroot#/}
  232. fi
  233. realconf=$(cd $base/config; pwd -P)
  234. realdown=$(cd $base/download; pwd -P)
  235. realbase=$(dirname $(cd $base/scripts; pwd -P))
  236. if [ ! -e ROCK/loop/scripts ]; then
  237. mkdir -p ROCK/{loop,config,download}
  238. mount --bind $realbase $PWD/ROCK/loop
  239. mount --bind $realconf $PWD/ROCK/config
  240. mount --bind $realdown $PWD/ROCK/download
  241. fi
  242. if [ ! -f proc/mounts ]; then
  243. mount -t proc proc $PWD/proc
  244. fi
  245. for x in Documentation architecture misc package scripts target; do
  246. if [ ! -e ROCK/$x ]; then ln -s "loop/$x" "ROCK/$x"; fi
  247. done
  248. if [ ! -e "ROCK/build/$ROCKCFG_ID" ]; then
  249. mkdir -p "ROCK/build"
  250. ln -snf ../.. "ROCK/build/$ROCKCFG_ID"
  251. fi
  252. # If build is a symlink to somewhere else (NFS share for clusterbuild
  253. # usually) we do _not_ want to extract our stuff there.
  254. # Network latency!
  255. ln -s loop/src.$xpkg.$id ROCK/src.$xpkg.$id
  256. cat > "$builddir/chroot.sh" <<- EOT
  257. #!/bin/bash
  258. export ROCK_THIS_IS_CHROOT=1; cd /ROCK
  259. ./scripts/Build-Pkg $options -chr-sub -root "/" "$1"
  260. EOT
  261. cat > "$builddir/debug.sh" <<- EOT
  262. #!/bin/bash
  263. export ROCK_THIS_IS_CHROOT=1
  264. if [ ! -e $PWD/ROCK/loop/scripts ]; then
  265. mount --bind $realbase $PWD/ROCK/loop
  266. mount --bind $realconf $PWD/ROCK/config
  267. mount --bind $realdown $PWD/ROCK/download
  268. fi
  269. if [ ! -e $PWD/ROCK/src.$xpkg.$id ]; then
  270. ln -s loop/src.$xpkg.$id $PWD/ROCK/src.$xpkg.$id
  271. fi
  272. chroot "$xroot" /bin/bash /ROCK/src.$xpkg.$id/debug_x.sh
  273. rm -f $PWD/ROCK/src.$xpkg.$id
  274. EOT
  275. chmod +x "$builddir/debug.sh"
  276. if [ "$TZ" ] ; then
  277. if [ "${TZ#/}" != "$TZ" ] ; then
  278. cp $TZ ROCK/localtime
  279. else
  280. cp /usr/share/zoneinfo/$TZ ROCK/localtime
  281. fi
  282. else
  283. if [ -f /etc/localtime ] ; then
  284. cp /etc/localtime ROCK/localtime
  285. else
  286. ln -s /usr/share/zoneinfo/Factory ROCK/localtime
  287. fi
  288. fi
  289. TZ="/ROCK/localtime" chroot . bin/bash ROCK/src.$xpkg.$id/chroot.sh
  290. returncode=$?
  291. umount $PWD/ROCK/loop
  292. umount $PWD/ROCK/config
  293. umount $PWD/ROCK/download
  294. umount $PWD/proc
  295. # Only remove $builddir if it is empty.
  296. rmdir --ignore-fail-on-non-empty "$realbase/src.$xpkg.$id"
  297. exit $returncode
  298. fi
  299. if [ "$ROCKCFG_FLIST" = "flwrapper" -a -z "$FLWRAPPER" ] ; then
  300. export FLWRAPPER_WLOG="$builddir/fl_wrapper.wlog"
  301. export FLWRAPPER_RLOG="$builddir/fl_wrapper.rlog"
  302. export FLWRAPPER_BASEPID=$$
  303. [ "$LD_PRELOAD" ] && LD_PRELOAD="${LD_PRELOAD}:"
  304. export FLWRAPPER="$base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/fl_wrapper.so"
  305. export LD_PRELOAD="${LD_PRELOAD}$FLWRAPPER"
  306. fi
  307. export INSTALL_WRAPPER_LOGFILE="$builddir/install_wrapper.log"
  308. export CMD_WRAPPER_LOGFILE="$builddir/cmd_wrapper.log"
  309. if [ $norebuild = 1 -a -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then
  310. echo_pkg_deny $stagelevel $pkg "already built"
  311. exit 0
  312. fi
  313. if [ "$ROCKCFG_RETRY_BROKEN" = 0 -a $norebuild = 1 -a \
  314. -f $root/var/adm/logs/$stagelevel-$xpkg.err ] ; then
  315. echo_pkg_deny $stagelevel $pkg "already failed"
  316. exit 1
  317. fi
  318. confdir=""
  319. archdir="$builddir/archdir"
  320. if [ -z "$pkgdir" ] ; then
  321. for x in package/*/$pkg/$pkg.desc ; do
  322. if [ -f "$x" ] ; then
  323. if [ "$confdir" ] ; then
  324. echo_pkg_deny $stagelevel $pkg "in multiple trees"
  325. echo "Package in multiple trees: $pkg !" \
  326. > $root/var/adm/logs/$stagelevel-$xpkg.err
  327. exit 1
  328. fi
  329. x=${x#package/}; x=${x%%/*}
  330. confdir="$base/package/$x/$pkg"
  331. repository=$x
  332. fi
  333. done
  334. else
  335. if [ -f "$pkgdir/$pkg.desc" ] ; then
  336. confdir="$pkgdir"
  337. repository=extern
  338. fi
  339. fi
  340. if [ -z "$confdir" ] ; then
  341. echo_pkg_deny $stagelevel $pkg "does not exist" ; exit 1
  342. fi
  343. mkdir -p $root/var/adm/{logs,flists,cksums,md5sums,packages,dependencies}
  344. mkdir -p $root/var/adm/{dep-debug,parse-config,cache,descs,rock-debug}
  345. [ "$root" ] && chmod 700 $root
  346. rm -f $root/var/adm/logs/$stagelevel-$xpkg.{out,log,err}
  347. if [ $this_is_the_2nd_run = 0 ] ; then
  348. [ $stagelevel -gt 1 ] && . /etc/profile
  349. options="-this_is_the_2nd_run $options $pkg=$xpkg"
  350. if [ "$ROCKCFG_CREATE_CACHE" = 1 -a $stagelevel -gt 1 ] ; then
  351. mkdir -p $root/var/adm/cache
  352. touch $root/var/adm/cache/$xpkg
  353. rm -f $root/var/adm/cache/$xpkg.tm
  354. /usr/bin/time -o "$root/var/adm/cache/$xpkg.tm" \
  355. -f 'buildtime=$(qcalc %U + %S)' $0 $options
  356. returncode=$?
  357. [ ! -e "$root/var/adm/cache/$xpkg.tm" ] && exit $returncode
  358. qcalc() { gawk "BEGIN { printf(\"%d\n\", ($*)*100); }"; }
  359. eval "`grep -v '^Command ' < $root/var/adm/cache/$xpkg.tm`"
  360. rm -f $root/var/adm/cache/$xpkg.tm
  361. {
  362. errortag=""
  363. if [ -f "$root/var/adm/logs/$stagelevel-$xpkg.err" ] ; then
  364. errortag=" ERROR"
  365. fi
  366. if [ -f $confdir/$pkg.desc ] ; then
  367. grep '^\[COPY\] ' $confdir/$pkg.desc | \
  368. sed "s,/$pkg.desc\$,/$pkg.cache,"
  369. fi
  370. echo
  371. grep '^\[TIMESTAMP\]' $root/var/adm/cache/$xpkg
  372. date "+[TIMESTAMP] %s %c ($stagelevel)$errortag"
  373. echo
  374. echo "[CONFIG-ID] ${ROCKCFG_ID#*-}"
  375. echo -e "[ROCKVER] $rockver\n"
  376. echo "[LOGS]" $( cd $root/var/adm/logs ; \
  377. ls ?-$xpkg.* 2> /dev/null )
  378. echo
  379. grep '^\[BUILDTIME\]' $root/var/adm/cache/$xpkg
  380. echo "[BUILDTIME] $buildtime ($stagelevel)$errortag"
  381. x="$root/var/adm/packages/$xpkg"
  382. if [ -f $x ]; then
  383. echo "[SIZE] `grep "^Package Size: " \
  384. $x | cut -f3- -d' '`"
  385. fi
  386. echo
  387. x="$root/var/adm/dependencies/$xpkg"
  388. if [ "$pkg" != "rock-debug" -a -f $x ]; then
  389. cut -f2- -d' ' "$x" | \
  390. fmt -70 | sed 's,^,[DEP] ,'
  391. echo
  392. fi
  393. cat $root/var/adm/flists/$xpkg{,:*} 2> /dev/null | \
  394. sed -r '\,(bin/[^/]+|lib/.+\.(so|a))$, { s,.*/,,; p; };d' | \
  395. sort -u | fmt -w65 | sed 's,^,[PROVIDES] ,'
  396. echo
  397. for stagelevel in 0 1 2 3 4 5 6 7 8 9 ; do
  398. x="$root/var/adm/logs/$stagelevel-$xpkg.err"
  399. if [ -f "$x" ] ; then
  400. tail -n 50 "$x" | \
  401. sed "s,^,[$stagelevel-ERROR] ,"
  402. echo
  403. fi
  404. done
  405. } > $root/var/adm/cache/$xpkg.new
  406. mv $root/var/adm/cache/$xpkg.new $root/var/adm/cache/$xpkg
  407. exit $returncode
  408. else
  409. exec $0 $options
  410. fi
  411. fi
  412. #
  413. # ---- Setting Build Variables
  414. #
  415. flistroot="bin boot etc lib sbin usr var opt"
  416. flistrfilter="ldconfig\..*: .*|.*: /var/adm/.*"
  417. flistdel="var/adm/.*|var/tmp/.*|var/lock/.*|var/run/.*|etc/ld.so.cache|usr/tmp/.*|.*\\.old"
  418. pkgsplits=""
  419. if [ "$ROCKCFG_SPLIT_DEV" != 0 ]; then
  420. # this doesn't affect files in /lib, just /.../lib
  421. # so there needn't be an exception for linux kernel modules
  422. splitreg 40 dev '(/lib/.*\.(la|a|o)$|/include/|/man[23]/)'
  423. splitdesc_dev() { desc_I="$desc_I (development files)"; }
  424. fi
  425. if [ "$ROCKCFG_SPLIT_DOC" != 0 ]; then
  426. # only move doc/ to :doc, not man and info pages
  427. splitreg 60 doc '/share/doc/'
  428. splitdesc_doc() { desc_I="$desc_I (documentation)"; }
  429. fi
  430. if [ $stagelevel -le 1 ]
  431. then
  432. makeopt='CC="$CC" CXX="$CXX" CC_FOR_BUILD="$BUILDCC"'
  433. makeopt="$makeopt"' BUILDCC="$BUILDCC" BUILD_CC="$BUILD_CC"'
  434. makeopt="$makeopt"' HOSTCC="$HOSTCC" HOST_CC="$HOST_CC"'
  435. makeopt="$makeopt"' STRIP="$STRIP" AR="$AR" LD="$LD"'
  436. makeopt="$makeopt"' RANLIB="$RANLIB" NM="$NM"'
  437. makeinstopt="$makeopt"' prefix=$root/$prefix install'
  438. for x in prefix bindir sbindir libdir datadir \
  439. infodir mandir sysconfdir localstatedir \
  440. includedir
  441. do
  442. makeopt="$makeopt $x=\${$x/${root//\//\\/}/}"
  443. done
  444. else
  445. makeopt='prefix=/$prefix CC="$CC" CXX="$CXX"'
  446. makeinstopt='prefix=/$prefix CC="$CC" CXX="$CXX" install'
  447. flistdel="$flistdel|`echo $base | sed s,^/,,`/.*"
  448. fi
  449. prepare="" ; hook_add prepare 5 'eval "$prepare"'
  450. prepatch="" ; hook_add prepatch 5 'eval "$prepatch"'
  451. postpatch="" ; hook_add postpatch 5 'eval "$postpatch"'
  452. postdoc="" ; hook_add postdoc 5 'eval "$postdoc"'
  453. preconf="" ; hook_add preconf 5 'eval "$preconf"'
  454. premake="" ; hook_add premake 5 'eval "$premake"'
  455. inmake="" ; hook_add inmake 5 'eval "$inmake"'
  456. postmake="" ; hook_add postmake 5 'eval "$postmake"'
  457. postinstall="" ; hook_add postinstall 5 'eval "$postinstall"'
  458. postflist="" ; hook_add postflist 5 'eval "$postflist"'
  459. finish="" ; hook_add finish 5 'eval "$finish"'
  460. [ "$ROCKCFG_DO_CHECK" = 1 ] && hook_add inmake 6 'run_check'
  461. hook_add postflist 3 'postflist_libs'
  462. configprefix="" ; autogen=0 ; automakever=""
  463. configscript="./configure" ; extraconfopt=""
  464. configexec="bash"
  465. srcdir=auto ; srctar=auto
  466. taropt="--use-compress-program=bzip2 -xf"
  467. mainfunction="build_this_package"
  468. runconf=1 ; runxmkmf=1 ; runmkpl=1 ; runpysetup=1 ; autopatch=1
  469. autoextract=1 ; chownsrcdir=1 ; nocvsinsrcdir=1; patchopt="-bfp1 -z .orig"
  470. createprefix=1 ; createdocs="" ; rmemptydir="" ; autoso2a=0 ; forcefpic=""
  471. check_shared=1
  472. check_usrlocal=1
  473. check_badfiles=1
  474. badfiles="" badfiles_nr=0
  475. declare -a badfiles_desc
  476. #
  477. # ---- Read various config files
  478. #
  479. parse_desc $confdir/$pkg.desc
  480. ver="`echo "$desc_V" | tail -n 1 | cut -f1 -d' '`"
  481. extraver="`echo "$desc_V" | tail -n 1 | cut -s -f2- -d' '`"
  482. [ -z "$extraver" ] && extraver="0"
  483. if [ "$pkg" = "$xpkg" ]; then
  484. echo_pkg_start $stagelevel $repository $xpkg $ver $extraver
  485. else
  486. echo_pkg_start $stagelevel $repository $pkg=$xpkg $ver $extraver
  487. fi
  488. if [ "$ROCKCFG_PARANOIA_CHECK" = 1 -a -z "$pkgdir" ] ; then
  489. x="`./scripts/Check-PkgFormat $pkg`"
  490. [ "$x" ] && abort "$x\nDisable the 'Paranoia Check' config `
  491. `option to ignore such errors."
  492. fi
  493. targetdir="$base/target/$target"
  494. patchfiles="`ls $confdir/*.patch $confdir/*.patch.$arch \
  495. $confdir/*.patch_$xpkg $confdir/*.patch_$xpkg.$arch \
  496. $targetdir/pkg_$pkg.patch $targetdir/pkg_$pkg.patch.$arch \
  497. $targetdir/xpkg_$xpkg.patch $targetdir/xpkg_$xpkg.patch.$arch \
  498. 2>/dev/null | tr '\n' ' '`"
  499. if [ $stagelevel -le 1 ]; then
  500. patchfiles="`ls $patchfiles $confdir/*.patch.cross \
  501. $confdir/*.patch.cross.$arch 2>/dev/null | tr '\n' ' '`"
  502. fi
  503. if [ $stagelevel -eq 0 ]; then
  504. flistroot="$flistroot include share doc info man"
  505. flistroot="$flistroot crosscc wrapper $arch_target"
  506. createdocs=0
  507. fi
  508. if [ -f $confdir/$pkg.cache ]; then
  509. if ! egrep -q '^\[PROVIDES].*\.(so|a)( |$)' $confdir/$pkg.cache; then
  510. forcefpic="0"
  511. fi
  512. fi
  513. if [ $stagelevel -gt 1 ]; then
  514. for pc_file in $xroot/var/adm/parse-config/* ; do
  515. if [ -s "$pc_file" -a "${pc_file##*/}" != "$xpkg" ]
  516. then . "$pc_file" ; fi
  517. done
  518. unset pc_file
  519. fi
  520. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config
  521. set_confopt
  522. if [ $stagelevel -eq 0 -a "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  523. echo_status "Building this package statically for pseudo native build."
  524. var_insert extraconfopt " " "--enable-static --disable-shared"
  525. for x in BUILDCC_WRAPPER_INSERT LDFLAGS LD CFLAGS CC; do
  526. var_append $x " " "-static"
  527. done
  528. fi
  529. eval "$desc_O"
  530. # include package pre config - if any
  531. if [ -f $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_pre.conf ] ; then
  532. echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_pre.conf"
  533. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_pre.conf
  534. fi
  535. if [ -f $targetdir/pkg_$pkg.conf ] ; then
  536. echo_status "Reading package configuration from target directory."
  537. . $targetdir/pkg_$pkg.conf
  538. elif [ -f $confdir/$pkg.conf ] ; then
  539. echo_status "Reading package configuration from package directory."
  540. . $confdir/$pkg.conf
  541. fi
  542. # include package post config - if any
  543. if [ -f $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_post.conf ] ; then
  544. echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_post.conf"
  545. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_post.conf
  546. fi
  547. if [ -f $base/architecture/$arch/pkg-header ] ; then
  548. echo_status "Reading overwrites from architecture/$arch/pkg-header."
  549. . $base/architecture/$arch/pkg-header
  550. fi
  551. if [ -f $base/target/$target/pkg-header ] ; then
  552. echo_status "Reading overwrites from target/$target/pkg-header."
  553. . $base/target/$target/pkg-header
  554. fi
  555. #
  556. # ---- Variable updates based on the configuration files read
  557. #
  558. if [ -z "$prefix" -o "${prefix#usr}" != "$prefix" ] ; then
  559. flistdel="$flistdel|usr/share/info/(dir|standards.info)"
  560. if [ "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  561. flistdel="$flistdel|usr/share/locale/..[/_].*"
  562. flistdel="$flistdel|usr/share/man/..[/_].*"
  563. fi
  564. if [ $stagelevel = 0 ] ; then
  565. flistdel="${flistdel//usr\//}|${flistdel//usr\/share\//}"
  566. fi
  567. else
  568. flistdel="$flistdel|$prefix/info/(dir|standards.info)"
  569. if [ "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  570. flistdel="$flistdel|$prefix/share/locale/..[/_].*"
  571. flistdel="$flistdel|$prefix/man/..[/_].*"
  572. fi
  573. fi
  574. #
  575. # ---- Build Package
  576. #
  577. echo_status "Preparing build in src.$xpkg.$id"
  578. if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then
  579. echo_status "Mounting tmpfs on src.$xpkg.$id"
  580. mount -t tmpfs -o $ROCKCFG_SRC_TMPFS_OPT tmpfs "$builddir"
  581. fi
  582. if [ "$xroot" != "$root" ] ; then
  583. for x in $flistroot ; do
  584. [ -d $xroot/$x ] || mkdir -p $xroot/$x
  585. [ -d $root/$x ] || ln -sf $xroot/$x $root/
  586. done
  587. fi
  588. if [ $update = 1 ] ; then
  589. echo_status "Creating backup of old package data (running in update mode)."
  590. (
  591. cd $xroot/
  592. grep -v "^X" var/adm/md5sums/$xpkg var/adm/md5sums/$xpkg:* 2> /dev/null |
  593. md5sum --check - 2>&1 | grep ': FAILED$' | cut -f1 -d:
  594. ) > "$builddir/backup_files.txt"
  595. if [ -s "$builddir/backup_files.txt" ] ; then
  596. mkdir -p "$xroot/var/adm/backup"
  597. chmod 700 "$xroot/var/adm/backup"
  598. backup_tar="$xroot/var/adm/backup/$(
  599. date '+%Y%m%d%H%M%S')_$xpkg.tar.bz2"
  600. ( cd $xroot/; tar --no-recursion --force-local -cf - -T "$builddir/`
  601. `backup_files.txt" || true; ) | bzip2 > $backup_tar
  602. else
  603. update=0
  604. fi
  605. fi
  606. if [ "$ROCKCFG_FLIST" = "flwrapper" ] ; then
  607. rm -f "$builddir/"fl_wrapper.{r,w}log
  608. touch "$builddir/"fl_wrapper.{r,w}log
  609. elif [ "$ROCKCFG_FLIST" = "find" ] ; then
  610. touch "$builddir/temp.time_stamp"
  611. sleep 2
  612. fi
  613. if [ $stagelevel -gt 1 -a "$autoso2a" = 1 ]; then
  614. export AUTOSO2A_DIR="$builddir/autoso2a"
  615. export AUTOSO2A_AR="$AR" AUTOSO2A_RANLIB="$RANLIB"
  616. var_insert CC_WRAPPER_OTHERS ":" "so2a_wrapper"
  617. var_insert CXX_WRAPPER_OTHERS ":" "so2a_wrapper"
  618. fi
  619. i=0
  620. mkdir -p "$builddir/wrappers"
  621. for x in "${wrapper_data[@]}"; do
  622. echo "$x" | (
  623. read n; o="$n"
  624. if [ -f "$builddir/wrappers/$n" ]; then
  625. mv "$builddir/wrappers/$n" "$builddir/wrappers/$n.$i"
  626. o="$n.$i"; (( i++ ))
  627. fi
  628. {
  629. echo '#!/bin/bash'
  630. echo 'echo "$PWD: $0 $*" >> "'"$builddir/wrappers.log"'"'
  631. echo 'PATH="$PATH_WRBACKUP"'
  632. echo "orig='$o'"
  633. cat
  634. } > "$builddir/wrappers/$n"
  635. chmod +x "$builddir/wrappers/$n"
  636. )
  637. done
  638. export PATH_WRBACKUP="$PATH"
  639. PATH="$builddir/wrappers:$PATH"
  640. unset i
  641. # make sure we don't create an flist with just an
  642. # empty docdir in it if the package build fails..
  643. flistdel="$flistdel|${docdir#$root/}"
  644. # define new abort function for errors while building
  645. #
  646. abort() {
  647. [ "$*" ] && echo "$*"; echo "--- BUILD ERROR ---"
  648. rm -vf $root/var/adm/logs/$stagelevel-$xpkg.log
  649. false
  650. }
  651. # FD 202 can be used to write output to console instead of build log
  652. exec 202>&1
  653. {
  654. (
  655. set -e
  656. if [ $xtrace -eq 1 -o $ROCKCFG_XTRACE -eq 1 ] ; then
  657. PS4=$'=[$FUNCNAME:$LINENO (last \\\$?=$?)> '
  658. set -o xtrace
  659. fi
  660. trap 'echo "Got SIGINT (Crtl-C). Aborting build." ; exit 1' INT
  661. exec < /dev/null
  662. hook_eval prepare
  663. mkdir -p "$builddir/archdir"
  664. # Download archives files and link to them in $archdir.
  665. while read l_cksum l_srctar l_url l_flags ; do
  666. [ -z "$l_cksum" ] && continue
  667. x=`source_file l_cksum $l_srctar l_url $l_flags`
  668. if [ ! -f $x ]; then
  669. if [ $download = 1 ] ; then
  670. echo_status "Running ./scripts/Download for this package..."
  671. echo_status "----- DOWNLOAD LOG -----"
  672. echo; ./scripts/Download $xpkg; echo
  673. echo_status "------------------------"
  674. download=0
  675. fi >&202 2>&1
  676. if [ ! -f $x ]; then
  677. echo "File not found: ${x#$base/}"
  678. abort "Did you run ./scripts/Download for this package?"
  679. fi
  680. fi
  681. ln -vs $x "$builddir/archdir/"
  682. done < <( echo "$desc_D" | column_clean )
  683. echo_status "Building. Writing output to" \
  684. "\$root/var/adm/logs/$stagelevel-$xpkg.out" >&202
  685. # Makes debugging build problems easier
  686. #
  687. hook_dump > "$builddir/debug.hooks"
  688. #
  689. {
  690. dump_env
  691. cat <<- EOT
  692. PS1='\\[\\e[00m\\e[01;31m\\]debug-`
  693. `$xpkg\\[\\e[00m\\]:[\\W]\\\$ '
  694. alias cp="cp -i" ; alias mv="mv -i"
  695. alias rm="rm -i" ; alias ls="ls --color=auto -a"
  696. alias ..="cd .." ; alias ...="cd ../.."
  697. alias xdiff="sh $base/misc/archive/xdiff.sh"
  698. alias bked="sh $base/misc/archive/bked.sh"
  699. fixfile () {
  700. # we use .vanilla to not rediff backup .orig from patch
  701. [ -f \$1.vanilla ] || cp \$1 \$1.vanilla
  702. \$EDITOR \$1
  703. }
  704. fixfilediff() {
  705. find -name '*.vanilla' | while read x ; do
  706. diff -u \$x \${x/.vanilla/}
  707. done
  708. }
  709. EOT
  710. } > "$builddir/debug.buildenv"
  711. #
  712. cat > "$builddir/debug_x.sh" <<- EOT
  713. #!/bin/bash
  714. export PROMPT_COMMAND='. debug.buildenv; cd .; unset PROMPT_COMMAND'
  715. cd "$builddir"; exec bash 200>> build.pid
  716. EOT
  717. #
  718. if [ "$ROCK_THIS_IS_CHROOT" != 1 ]; then
  719. mv "$builddir/debug_x.sh" "$builddir/debug.sh"
  720. chmod +x "$builddir/debug.sh"
  721. fi
  722. # Create PID file
  723. #
  724. # The builtin-variable '$$' is not this pid because this proc
  725. # is just a sub-proc of $$. That's why the $builddir/strace.tmp
  726. # hack is required to get the right pid to trace.
  727. #
  728. # We also conntect filedescriptor 3 with the pid file. So the command
  729. # 'fuser' can be used to create a list of all processes which are part
  730. # of this build process.
  731. #
  732. sh -c 'echo $PPID' > "$builddir/build.pid"
  733. exec 200>> "$builddir/build.pid"
  734. echo "Command Wrapper Debug: running '${CC} --version' .."
  735. type ${CC%% *}; CMD_WRAPPER_DEBUG=1 ${CC} --version
  736. echo "[ writing debug log to $builddir/cmd_wrapper.log ]"
  737. if [ "$debug" = 1 ] ; then
  738. echo "Everything is set up." \
  739. "We are in debug mode - so exit now."
  740. exit
  741. fi
  742. if [ "$ROCKCFG_FLIST" = "strace" ] ; then
  743. if [ "$(uname -m)" = "ppc" ]; then
  744. SYSEXIT="exit"
  745. else
  746. SYSEXIT="_exit"
  747. fi
  748. strace -o "$builddir/strace.out" -F -f -q -e open,creat,mkdir,`
  749. `mknod,link,symlink,rename,utime,chdir,execve,`
  750. `fork,clone,vfork,`
  751. `$SYSEXIT,exit_group -p `cat "$builddir/build.pid"` &
  752. strace_pid=$! ; sleep 1 ; cd $base
  753. fi
  754. echo "Running main build function '$mainfunction' ..."
  755. cd "$builddir" ; eval "$mainfunction"
  756. hook_eval postinstall
  757. echo "Creating file list and doing final adaptions ... "
  758. #
  759. cd $xroot/
  760. #
  761. if [ "$ROCKCFG_FLIST" = "strace" ] ; then
  762. sleep 1 ; kill -INT $strace_pid ; sleep 1
  763. fl_stparse -w "$builddir/fl_wrapper.wlog" \
  764. -r "$builddir/fl_wrapper.rlog" < "$builddir/strace.out"
  765. fi
  766. if [ "$ROCKCFG_FLIST" = "flwrapper" -o \
  767. "$ROCKCFG_FLIST" = "strace" ] ; then
  768. if [ "$stagelevel" -le 1 ]
  769. then
  770. xbase="$( cd $xroot/ 2> /dev/null ; pwd -P )"
  771. if egrep -qv "[ ]($base|$xbase|$builddir|/tmp|/usr/tmp|/var/tmp|/var/backups|/proc|/dev)(/|$)" \
  772. $builddir/fl_wrapper.wlog
  773. then
  774. x="Created file outside basedir: "
  775. egrep -v "[ ]($base|$xbase|$builddir|/tmp|/usr/tmp|/var/tmp|/proc|/dev)(/|$)" \
  776. $builddir/fl_wrapper.wlog | \
  777. cut -f2- | sort -u | sed "s,^,$x,"
  778. echo "base #1: $base"
  779. echo "base #2: $xbase"
  780. abort
  781. fi
  782. fi
  783. if fl_wrparse -D -s -r "$xroot/" < $builddir/fl_wrapper.wlog | \
  784. egrep "^(${flistroot// /|})(/|$)" >> \
  785. $builddir/flist.txt
  786. then : ; fi
  787. elif [ "$ROCKCFG_FLIST" = "find" ] ; then
  788. if find $flistroot \
  789. \( -not -type d -or -type d -empty \) \
  790. -and \( -newer $builddir/temp.time_stamp -or \
  791. -cnewer $builddir/temp.time_stamp \) -printf "%p\n" >> \
  792. $builddir/flist.txt
  793. then : ; fi
  794. fi
  795. # evaluate flistdel (1/2)
  796. egrep -v "^($flistdel)\$" $builddir/flist.txt | sort -u > $builddir/flist.txt.new
  797. mv $builddir/flist.txt.new $builddir/flist.txt
  798. # copy over missing *.a files
  799. if [ "$autoso2a" = 1 ]; then
  800. echo "Checking for missing .a files ..."
  801. while read d s; do
  802. grep -q "/${s%.so}.a$" $builddir/flist.txt && continue
  803. [ "$d" = "lib" ] && d="usr/lib"
  804. if [ -f "$AUTOSO2A_DIR/${s%.so}.a" ]; then
  805. echo "Installing automatically created $d/${s%.so}.a."
  806. cp "$AUTOSO2A_DIR/${s%.so}.a" "$root/$d/${s%.so}.a"
  807. add_flist "$root/$d/${s%.so}.a"
  808. else
  809. echo "Not found: $AUTOSO2A_DIR/${s%.so}.a"
  810. fi
  811. done < <( egrep '(^|/)lib/[^/]*\.so$' "$builddir/flist.txt" | sed 's,\(.*\)/,\1 ,' )
  812. fi
  813. # merge flist of previous build
  814. for x in var/adm/flists/$xpkg var/adm/flists/$xpkg:*; do
  815. [ -f $x ] && cut -f2- -d' ' $x >> "$builddir/flist.txt"
  816. done
  817. # evaluate flistdel (2/2)
  818. egrep -v "^($flistdel)\$" "$builddir/flist.txt" | sort -u > "$builddir/flist.txt.new"
  819. mv "$builddir/flist.txt.new" "$builddir/flist.txt"
  820. hook_eval postflist
  821. fl_wrparse -D -p "$xpkg" -r "$xroot/" < "$builddir/flist.txt" | sort -u > "$builddir/flist.split"
  822. echo Found `wc -l < "$builddir/flist.split"` "files for this package."
  823. splitapply $xpkg "$builddir/flist.split"
  824. if [ "$ROCKCFG_FLIST" = "flwrapper" -o \
  825. "$ROCKCFG_FLIST" = "strace" ] && [ $stagelevel -gt 1 ] ; then
  826. echo "Calculating package dependencies ..."
  827. ! egrep -v "^($flistrfilter)\$" "$builddir"/fl_wrapper.[rw]log |
  828. sort -u | fl_wrparse -D -s -r "$xroot/" -p '' | \
  829. grep -v ' var/adm/' | awk '
  830. ARGIND < ARGC-1 {
  831. if ( index($1, "'$xpkg':") != 1 )
  832. f[$2] = $1 " " f[$2];
  833. }
  834. ARGIND == ARGC-1 {
  835. file = $2;
  836. while ( file != "" ) {
  837. if ( f[file] ) {
  838. split(f[file], a);
  839. for (i in a)
  840. if (! d[a[i] " " file]) {
  841. d[a[i] " " file] = 1;
  842. print a[i] " " file;
  843. }
  844. }
  845. sub("/?[^/]*$", "", file)
  846. }
  847. }
  848. ' var/adm/flists/* - > "$builddir/dependencies.debug"
  849. awk 'BEGIN { FS=": "; } { print "'$xpkg': " $1; }' \
  850. < "$builddir/dependencies.debug" > "$builddir/dependencies.txt"
  851. if [ -f var/adm/dep-debug/$xpkg ] ; then
  852. cat var/adm/dep-debug/$xpkg >> "$builddir/dependencies.debug"
  853. fi
  854. sort -u "$builddir/dependencies.debug" > var/adm/dep-debug/$xpkg
  855. # add debug info for known false dependencies
  856. if egrep -q "^[^#].* $xpkg( |$)" $base/scripts/dep_fixes.txt; then
  857. echo "--- $xpkg [$stagelevel] ---" >> $root/var/adm/rock-debug/falsedeps.txt
  858. fi
  859. while read x; do
  860. grep "^$x: " "$builddir/dependencies.debug" | sort -u | \
  861. sed "s,:, -> $xpkg [$stagelevel]:," >> $root/var/adm/rock-debug/falsedeps.txt
  862. done < <( egrep "^$xpkg +del +" $base/scripts/dep_fixes.txt | \
  863. tr ' ' '\t' | tr -s '\t' | cut -f3- | tr '\t' '\n' )
  864. # merge the dependencies defined by the package
  865. for x in `echo "$desc_E" | egrep '^add ' | sed 's/^add //' ` ; do
  866. echo "Adding dependency: $x ..."
  867. echo "$xpkg: $x" >> "$builddir/dependencies.txt"
  868. done
  869. # remove dependencies as requested by the package
  870. # TODO: groups are not used yet (and it is not easy here)
  871. del_pattern=""
  872. for x in `echo "$desc_E" | egrep '^del ' | sed 's/^del //' ` ; do
  873. del_pattern="$del_pattern -e \".*: $x(:.*|)\$\""
  874. done
  875. if [ -n "$del_pattern" ] ; then
  876. echo "Deleting dependencies, pattern: $del_pattern ..."
  877. eval "egrep -v $del_pattern \"$builddir/dependencies.txt\"" > "$builddir/dependencies.txt.new"
  878. mv "$builddir/dependencies.txt.new" "$builddir/dependencies.txt"
  879. fi
  880. if [ -f var/adm/dependencies/$xpkg ] ; then
  881. cat var/adm/dependencies/$xpkg >> "$builddir/dependencies.txt"
  882. fi
  883. sort -u "$builddir/dependencies.txt" > "$builddir/dependencies.txt.new"
  884. mv "$builddir/dependencies.txt.new" "$builddir/dependencies.txt"
  885. fi
  886. for spkg in $( sed 's,: .*,,' < "$builddir/flist.split" | sort -u )
  887. do
  888. (
  889. if [ -z "${spkg##*:*}" ]; then
  890. splitdesc_${spkg#*:}
  891. fi
  892. echo "<$spkg> Creating flist file ..."
  893. {
  894. grep "^$spkg: " "$builddir/flist.split"
  895. [ -s "var/adm/parse-config/$spkg" ] && \
  896. echo "$spkg: var/adm/parse-config/$spkg"
  897. for x in var/adm/flists/$spkg var/adm/md5sums/$spkg \
  898. var/adm/cksums/$spkg var/adm/packages/$spkg \
  899. var/adm/descs/$spkg var/adm/dependencies/$spkg ; do
  900. touch $x ; echo "$spkg: $x"
  901. done
  902. } | sort -u > var/adm/flists/$spkg
  903. if [ -f "$builddir/dependencies.txt" ] ; then
  904. echo "<$spkg> Creating package dependencies file ..."
  905. sed "s,^[^ ]*,$spkg:," < "$builddir/dependencies.txt" > var/adm/dependencies/$spkg
  906. fi
  907. echo "<$spkg> Creating package description ..."
  908. #
  909. rocksrcck=$(cd $base; md5sum package/*/$pkg/* 2> /dev/null | \
  910. grep -v '\.cache$' | md5sum | cut -f1 -d' ')
  911. buildlist="$( grep "^Build \[.\] at " var/adm/packages/$spkg || true
  912. echo "Build [$stagelevel] at $buildstart to `date "+%T %Z"`")"
  913. #
  914. cat > var/adm/packages/$spkg << EOT
  915. Package Name and Version: $spkg $ver $extraver
  916. Package Size: `getdu $root/ < var/adm/flists/$spkg`, `
  917. wc -l < var/adm/flists/$spkg | tr -d ' '` files
  918. ROCK Linux Package Source Checksum: $rocksrcck
  919. ROCK Linux Version and Architecture: $rockver $arch
  920. Build on `uname -m -n -r -s -p`
  921. $buildlist
  922. Status: ${desc_S:-ALPHA}, License: ${desc_L:-Unknown}
  923. ${desc_I:-$spkg}
  924. $( echo "${desc_T:-No description available.}" | sed 's,^, ,' )
  925. URL(s):
  926. $( echo "${desc_U:-http://www.rocklinux.net/packages/$pkg.html}" | sed 's,^, ,' )
  927. Original Author(s):
  928. $( echo "${desc_A:-Unknown}" | sed 's,^, ,' )
  929. ROCK Package Maintainer(s):
  930. $( echo "${desc_M:-Unknown}" | sed 's,^, ,' )
  931. Download URL(s):
  932. $( echo "${desc_D:-None}" | awk '{ print " " $3 $2; }' )
  933. EOT
  934. {
  935. echo "[CONFIG] ${ROCKCFG_ID#*-}"
  936. while read x; do
  937. if [ "${x#\[}" != "$x" ]; then # "]}"
  938. x="`echo ${x// /|} | tr -d '[]'`"
  939. y="${x%%|*}" ; x="(${x%|(*)})"
  940. case "$y" in
  941. V) echo "[V] $ver $extraver" ;;
  942. *) echo "$descfile" | egrep "^\[$x\]" | expand | sed "s,^[^ ]*,[$y]," ;;
  943. esac
  944. fi
  945. done < $base/Documentation/Developers/PKG-DESC-FORMAT
  946. } > var/adm/descs/$spkg
  947. # Create them last so checksums of other var/adm files are correct.
  948. echo "<$spkg> Creating md5sum and cksum files ..."
  949. echo -n > var/adm/cksums/$spkg
  950. echo -n > var/adm/md5sums/$spkg
  951. # getfiles only returns non-directories, suitable for checksum creation.
  952. getfiles < var/adm/flists/$spkg > "$builddir/files.lst"
  953. if [ -s "$builddir/files.lst" ] ; then
  954. while read file ; do
  955. [ -z "${file//[ ]/}" ] && continue
  956. # Checksums on these files are volatile.
  957. if [ "$file" = "var/adm/cksums/$spkg" -o \
  958. "$file" = "var/adm/md5sums/$spkg" -o \
  959. -b "$file" -o -c "$file" -o -p "$file" -o \
  960. -L "$file" -o -S "$file" ] ; then
  961. echo "X ${file}" >> var/adm/md5sums/$spkg
  962. echo "X $( stat -c %s ${file} ) ${file}" \
  963. >> var/adm/cksums/$spkg
  964. elif [ ${ROCKCFG_CREATE_CKSUM} -eq 1 ] ; then
  965. md5sum "${file}" >> var/adm/md5sums/$spkg
  966. cksum "${file}" >> var/adm/cksums/$spkg
  967. else
  968. echo "0 ${file}" >> var/adm/md5sums/$spkg
  969. echo "0 $( stat -c %s ${file} ) ${file}" \
  970. >> var/adm/cksums/$spkg
  971. fi
  972. done < "$builddir/files.lst"
  973. fi
  974. if [ $stagelevel -ge 2 -a $nopostinst = 0 -a -d /var/adm/postinstall ]; then
  975. cp var/adm/flists/$spkg "$(mktemp var/adm/postinstall/${spkg}-install.XXXXXX)"
  976. fi
  977. )
  978. done
  979. echo "Making post-install adaptions."
  980. if [ $stagelevel -ge 2 -a -f /sbin/ldconfig ] ; then ldconfig ; fi
  981. if [ "$ROCKCFG_PARANOIA_CHECK" = 1 ] ; then
  982. found_errors=0
  983. found_dups=0
  984. # check for files which are 'shared' with other packages
  985. if [ "$check_shared" != "0" ]; then
  986. while read dummy file; do
  987. if [ $found_dups = 0 ] ; then
  988. echo "Found shared files with other packages:"
  989. found_errors=1; found_dups=1
  990. fi
  991. echo "$file:" $( cd $root/var/adm/flists
  992. grep -l " $file\$" * )
  993. done < <( cat $root/var/adm/flists/* | sed "s,^$xpkg:[^ ]*,.," | \
  994. sort -k2 | uniq -d -f1 | grep '^\. ' )
  995. fi
  996. found_local=0
  997. # check for files in /usr/local
  998. if [ "$check_usrlocal" != "0" ]; then
  999. while read file ; do
  1000. if [ $found_local = 0 ] ; then
  1001. echo "Found files in /usr/local:"
  1002. found_errors=1; found_local=1
  1003. fi
  1004. echo $file
  1005. done < <( sed "s,^$xpkg: ,/," $root/var/adm/flists/$xpkg \
  1006. $root/var/adm/flists/$xpkg:* 2> /dev/null | egrep "^/usr/local" )
  1007. fi
  1008. found_bad=0
  1009. # check for registered 'bad files'
  1010. if [ "$check_badfiles" != "0" -a -n "$badfiles" ]; then
  1011. echo "$badfiles" > "$builddir/badfiles.txt"
  1012. while read x file; do
  1013. if [ $found_bad = 0 ]; then
  1014. echo "Found registered 'bad files' in package:"
  1015. found_errors=1; found_bad=1
  1016. fi
  1017. desc="No description found!"
  1018. for ((x=0; x<badfiles_nr; x++)); do
  1019. if echo " $file" | grep -q "${badfiles_desc[x]%%$'\n'*}"
  1020. then desc="${badfiles_desc[x]#*$'\n'}"; fi
  1021. done
  1022. echo "$file: $desc"
  1023. done < <( grep -f "$builddir/badfiles.txt" $root/var/adm/flists/$xpkg \
  1024. $root/var/adm/flists/$xpkg:* 2> /dev/null )
  1025. fi
  1026. [ $found_errors != 0 ] && abort
  1027. fi
  1028. touch $root/var/adm/logs/$stagelevel-$xpkg.log
  1029. echo "Finished building $pkg=$xpkg."
  1030. hook_eval finish
  1031. )
  1032. if [ ! -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then
  1033. abort
  1034. fi
  1035. } 2>&1 | {
  1036. trap '' INT
  1037. if [ "$ROCKCFG_VERBOSE" = 1 -o "$verbose" = 1 ] ; then
  1038. tee $root/var/adm/logs/$stagelevel-$xpkg.out
  1039. else
  1040. cat > $root/var/adm/logs/$stagelevel-$xpkg.out
  1041. fi
  1042. }
  1043. if [ $update = 1 ] ; then
  1044. echo_status "Restoring backup of old package data."
  1045. while read fn ; do
  1046. [ -f $xroot/$fn ] && mv $xroot/$fn $xroot/$fn.new
  1047. done < "$builddir/backup_files.txt"
  1048. tar --force-local --use-compress-program=bzip2 -C $xroot/ -xpf $backup_tar
  1049. while read fn ; do
  1050. cmp -s $fn $fn.new && rm -f $fn.new
  1051. done < "$builddir/backup_files.txt"
  1052. fi
  1053. cd $base
  1054. umount -r -d -f "$builddir"/* 2> /dev/null
  1055. umount -r -d -f -l "$builddir"/* 2> /dev/null
  1056. if [ "$ROCKCFG_SRC_TMPFS_LOG" = 1 -a -n "$( type -p df )" ]; then
  1057. if [ ! -f $root/var/adm/rock-debug/tmpfslog.txt ] ; then
  1058. echo -e "# Config\tPackage\tInodes\tKB" | \
  1059. expand -t20 > $root/var/adm/rock-debug/tmpfslog.txt
  1060. fi
  1061. echo -e "$config\t$stagelevel-$xpkg\t$(
  1062. df 2> /dev/null -Pi "$builddir" | tail -n 1 | tr -s ' ' | cut -f3 -d' '
  1063. )\t$(
  1064. df 2> /dev/null -Pk "$builddir" | tail -n 1 | tr -s ' ' | cut -f3 -d' ')" | \
  1065. expand -t20 >> $root/var/adm/rock-debug/tmpfslog.txt
  1066. fi
  1067. if [ "$ROCKCFG_PSEUDONATIVE" = 1 -a $stagelevel -eq 0 ]; then
  1068. rm -f $base/build/$ROCKCFG_ID/pseudonative_handler
  1069. fi
  1070. if [ "$ROCKCFG_FLIST" = "flwrapper" ] ; then
  1071. export LD_PRELOAD="${LD_PRELOAD//${FLWRAPPER}/}"
  1072. export LD_PRELOAD="${LD_PRELOAD//::/:}"
  1073. fi
  1074. if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then
  1075. umount -l "$builddir"
  1076. fi
  1077. if [ -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then
  1078. if [ $clear_src = 1 ] ; then
  1079. rm -rf "$builddir"/* "$builddir"
  1080. else
  1081. cp $root/var/adm/logs/$stagelevel-$xpkg.out "$builddir/BUILD-LOG"
  1082. fi
  1083. echo_status "\$root/var/adm/logs/$stagelevel-$xpkg.out" \
  1084. "-> $stagelevel-$xpkg.log"
  1085. mv $root/var/adm/logs/$stagelevel-$xpkg.out \
  1086. $root/var/adm/logs/$stagelevel-$xpkg.log
  1087. echo_pkg_finish $stagelevel $repository $xpkg
  1088. exit 0
  1089. else
  1090. if [ $clear_src = 1 -a "$ROCKCFG_ALWAYS_CLEAN" = 1 ] ; then
  1091. rm -rf "$builddir"/* "$builddir"
  1092. else
  1093. cp $root/var/adm/logs/$stagelevel-$xpkg.out "$builddir/ERROR-LOG"
  1094. fi
  1095. if [ "$ROCKCFG_VERBOSE" != 1 -a "$verbose" != 1 ] ; then
  1096. echo_errorquote "$( grep -B7 -- '--- BUILD ERROR ---' \
  1097. $root/var/adm/logs/$stagelevel-$xpkg.out | \
  1098. sed '$ s,--- BUILD ERROR ---,,' | \
  1099. grep . | grep -vx -- -- )"
  1100. fi
  1101. echo_status "\$root/var/adm/logs/$stagelevel-$xpkg.out" \
  1102. "-> $stagelevel-$xpkg.err"
  1103. mv $root/var/adm/logs/$stagelevel-$xpkg.out \
  1104. $root/var/adm/logs/$stagelevel-$xpkg.err
  1105. echo_pkg_abort $stagelevel $repository $xpkg
  1106. exit 1
  1107. fi
  1108. # ---- EOF