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.

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