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.

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