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.

1194 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 - 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/.*"
  392. flistdel="etc/ld.so.cache|var/tmp/.*|usr/tmp/.*|var/adm/logs/.*|.*\\.old"
  393. pkgsplits=""
  394. if [ "$ROCKCFG_SPLIT_DEV" != 0 ]; then
  395. # this doesn't affect files in /lib, just /.../lib
  396. # so there mustn't be an exception for linux kernel modules
  397. splitreg 40 dev '(/lib/.*\.(la|a|o)$|/include/)'
  398. splitdesc_dev() { desc_I="$desc_I (development files)"; }
  399. fi
  400. if [ "$ROCKCFG_SPLIT_DOC" != 0 ]; then
  401. # only move doc/ to :doc, not man and info pages
  402. splitreg 60 doc '/share/doc/'
  403. splitdesc_doc() { desc_I="$desc_I (documentation)"; }
  404. fi
  405. if [ "$pkg" != rock-debug ]; then
  406. flistdel="$flistdel|var/adm/rock-debug/.*"
  407. fi
  408. if [ $stagelevel -le 1 ]
  409. then
  410. makeopt='CC="$CC" CXX="$CXX" CC_FOR_BUILD="$BUILDCC"'
  411. makeopt="$makeopt"' BUILDCC="$BUILDCC" BUILD_CC="$BUILD_CC"'
  412. makeopt="$makeopt"' HOSTCC="$HOSTCC" HOST_CC="$HOST_CC"'
  413. makeopt="$makeopt"' STRIP="$STRIP" AR="$AR" LD="$LD"'
  414. makeopt="$makeopt"' RANLIB="$RANLIB" NM="$NM"'
  415. makeinstopt="$makeopt"' prefix=$root/$prefix install'
  416. for x in prefix bindir sbindir libdir datadir \
  417. infodir mandir sysconfdir localstatedir \
  418. includedir
  419. do
  420. makeopt="$makeopt $x=\${$x/${root//\//\\/}/}"
  421. done
  422. else
  423. makeopt='prefix=/$prefix CC="$CC" CXX="$CXX"'
  424. makeinstopt='prefix=/$prefix CC="$CC" CXX="$CXX" install'
  425. flistdel="$flistdel|`echo $base | sed s,^/,,`/.*"
  426. fi
  427. prepare="" ; hook_add prepare 5 'eval "$prepare"'
  428. prepatch="" ; hook_add prepatch 5 'eval "$prepatch"'
  429. postpatch="" ; hook_add postpatch 5 'eval "$postpatch"'
  430. postdoc="" ; hook_add postdoc 5 'eval "$postdoc"'
  431. preconf="" ; hook_add preconf 5 'eval "$preconf"'
  432. premake="" ; hook_add premake 5 'eval "$premake"'
  433. inmake="" ; hook_add inmake 5 'eval "$inmake"'
  434. postmake="" ; hook_add postmake 5 'eval "$postmake"'
  435. postinstall="" ; hook_add postinstall 5 'eval "$postinstall"'
  436. postflist="" ; hook_add postflist 5 'eval "$postflist"'
  437. finish="" ; hook_add finish 5 'eval "$finish"'
  438. [ "$ROCKCFG_DO_CHECK" = 1 ] && hook_add inmake 6 'run_check'
  439. hook_add postflist 3 'postflist_static_lib'
  440. configprefix="" ; autogen=0 ; automakever=""
  441. configscript="./configure" ; extraconfopt=""
  442. configexec="bash"
  443. srcdir=auto ; srctar=auto
  444. taropt="--use-compress-program=bzip2 -xf"
  445. mainfunction="build_this_package"
  446. runconf=1 ; runxmkmf=1 ; runmkpl=1 ; runpysetup=1 ; autopatch=1
  447. autoextract=1 ; chownsrcdir=1 ; nocvsinsrcdir=1; patchopt="-bfp1 -z .orig"
  448. createprefix=1 ; createdocs="" ; rmemptydir="" ; autoso2a=0
  449. check_shared=1
  450. check_usrlocal=1
  451. check_badfiles=1
  452. badfiles="" badfiles_nr=0
  453. declare -a badfiles_desc
  454. #
  455. # ---- Read various config files
  456. #
  457. parse_desc $confdir/$pkg.desc
  458. ver="`echo "$desc_V" | tail -n 1 | cut -f1 -d' '`"
  459. extraver="`echo "$desc_V" | tail -n 1 | cut -s -f2- -d' '`"
  460. [ -z "$extraver" ] && extraver="${rockver//DEV-*/DEV}"
  461. if [ "$pkg" = "$xpkg" ]; then
  462. echo_pkg_start $stagelevel $repository $xpkg $ver $extraver
  463. else
  464. echo_pkg_start $stagelevel $repository $pkg=$xpkg $ver $extraver
  465. fi
  466. if [ "$ROCKCFG_PARANOIA_CHECK" = 1 -a -z "$pkgdir" ] ; then
  467. x="`./scripts/Check-PkgFormat $pkg`"
  468. [ "$x" ] && abort "$x\nDisable the 'Paranoia Check' config `
  469. `option to ignore such errors."
  470. fi
  471. targetdir="$base/target/$target"
  472. patchfiles="`ls $confdir/*.patch $confdir/*.patch.$arch \
  473. $confdir/*.patch_$xpkg $confdir/*.patch_$xpkg.$arch \
  474. $targetdir/pkg_$pkg.patch $targetdir/pkg_$pkg.patch.$arch \
  475. $targetdir/xpkg_$xpkg.patch $targetdir/xpkg_$xpkg.patch.$arch \
  476. 2>/dev/null | tr '\n' ' '`"
  477. if [ $stagelevel -le 1 ]; then
  478. patchfiles="`ls $patchfiles $confdir/*.patch.cross \
  479. $confdir/*.patch.cross.$arch 2>/dev/null | tr '\n' ' '`"
  480. fi
  481. if [ $stagelevel -eq 0 ]; then
  482. flistroot="$flistroot include share doc info man"
  483. flistroot="$flistroot crosscc wrapper $arch_target"
  484. createdocs=0
  485. fi
  486. if [ $stagelevel -gt 1 ]; then
  487. for pc_file in $xroot/var/adm/parse-config/* ; do
  488. if [ -s "$pc_file" -a "${pc_file##*/}" != "$xpkg" ]
  489. then . "$pc_file" ; fi
  490. done
  491. unset pc_file
  492. fi
  493. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config
  494. set_confopt
  495. if [ $stagelevel -eq 0 -a "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  496. echo_status "Building this package statically for pseudo native build."
  497. var_insert extraconfopt " " "--enable-static --disable-shared"
  498. for x in BUILDCC_WRAPPER_INSERT LDFLAGS LD CFLAGS CC; do
  499. var_append $x " " "-static"
  500. done
  501. fi
  502. eval "$desc_O"
  503. # include package pre config - if any
  504. if [ -f $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_pre.conf ] ; then
  505. echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_pre.conf"
  506. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_pre.conf
  507. fi
  508. if [ -f $targetdir/pkg_$pkg.conf ] ; then
  509. echo_status "Reading package configuration from target directory."
  510. . $targetdir/pkg_$pkg.conf
  511. elif [ -f $confdir/$pkg.conf ] ; then
  512. echo_status "Reading package configuration from package directory."
  513. . $confdir/$pkg.conf
  514. fi
  515. # include package post config - if any
  516. if [ -f $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_post.conf ] ; then
  517. echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_post.conf"
  518. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_post.conf
  519. fi
  520. if [ -f $base/architecture/$arch/pkg-header ] ; then
  521. echo_status "Reading overwrites from architecture/$arch/pkg-header."
  522. . $base/architecture/$arch/pkg-header
  523. fi
  524. if [ -f $base/target/$target/pkg-header ] ; then
  525. echo_status "Reading overwrites from target/$target/pkg-header."
  526. . $base/target/$target/pkg-header
  527. fi
  528. #
  529. # ---- Variable updates based on the configuration files read
  530. #
  531. if [ -z "$prefix" -o "${prefix#usr}" != "$prefix" ] ; then
  532. flistdel="$flistdel|usr/share/info/(dir|standards.info)"
  533. if [ "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  534. flistdel="$flistdel|usr/share/locale/..[/_].*"
  535. flistdel="$flistdel|usr/share/man/..[/_].*"
  536. fi
  537. if [ $stagelevel = 0 ] ; then
  538. flistdel="${flistdel//usr\//}|${flistdel//usr\/share\//}"
  539. fi
  540. else
  541. flistdel="$flistdel|$prefix/info/(dir|standards.info)"
  542. if [ "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  543. flistdel="$flistdel|$prefix/share/locale/..[/_].*"
  544. flistdel="$flistdel|$prefix/man/..[/_].*"
  545. fi
  546. fi
  547. #
  548. # ---- Build Package
  549. #
  550. echo_status "Preparing build in src.$xpkg.$id"
  551. mkdir -p $builddir; chmod 700 $builddir
  552. if [ $clear_src = 1 ] ; then
  553. if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then
  554. mount -t tmpfs -o $ROCKCFG_SRC_TMPFS_OPT none $builddir
  555. fi
  556. fi
  557. if [ "$xroot" != "$root" ] ; then
  558. for x in $flistroot ; do
  559. [ -d $xroot/$x ] || mkdir -p $xroot/$x
  560. [ -d $root/$x ] || ln -sf $xroot/$x $root/
  561. done
  562. fi
  563. if [ $update = 1 ] ; then
  564. echo_status "Creating backup of old package data (running in update mode)."
  565. (
  566. cd $xroot/
  567. cat var/adm/md5sums/$xpkg var/adm/md5sums/$xpkg:* 2> /dev/null |
  568. md5sum --check - 2>&1 | grep ': FAILED$' | cut -f1 -d:
  569. ) > $builddir/backup_files.txt
  570. if [ -s $builddir/backup_files.txt ] ; then
  571. mkdir -p "$xroot/var/adm/backup"
  572. chmod 700 "$xroot/var/adm/backup"
  573. backup_tar="$xroot/var/adm/backup/$(
  574. date '+%Y%m%d%H%M%S')_$xpkg.tar.bz2"
  575. ( cd $xroot/; tar --no-recursion --force-local -cf - -T $builddir/`
  576. `backup_files.txt || true; ) | bzip2 > $backup_tar
  577. else
  578. update=0
  579. fi
  580. fi
  581. if [ "$ROCKCFG_FLIST" = "flwrapper" ] ; then
  582. rm -f $builddir/fl_wrapper.wlog $builddir/fl_wrapper.rlog
  583. touch $builddir/fl_wrapper.wlog $builddir/fl_wrapper.rlog
  584. elif [ "$ROCKCFG_FLIST" = "find" ] ; then
  585. touch $builddir/temp.time_stamp
  586. sleep 2
  587. fi
  588. if [ $stagelevel -gt 1 -a "$autoso2a" = 1 ]; then
  589. export AUTOSO2A_DIR="$builddir/autoso2a"
  590. export AUTOSO2A_AR="$AR" AUTOSO2A_RANLIB="$RANLIB"
  591. var_insert CC_WRAPPER_OTHERS ":" "so2a_wrapper"
  592. var_insert CXX_WRAPPER_OTHERS ":" "so2a_wrapper"
  593. fi
  594. hook_eval prepare
  595. # define new abort function for errors while building
  596. #
  597. abort() {
  598. [ "$*" ] && echo "$*"; echo "--- BUILD ERROR ---"
  599. rm -vf $root/var/adm/logs/$stagelevel-$xpkg.log
  600. false
  601. }
  602. {
  603. trap 'echo "Got SIGINT (Crtl-C). Aborting build." ; exit 1' INT
  604. exec < /dev/null
  605. # Makes debugging build problems easier
  606. #
  607. hook_dump > $builddir/debug.hooks
  608. #
  609. {
  610. dump_env
  611. cat <<- EOT
  612. PS1='\\[\\e[00m\\e[01;31m\\]debug-`
  613. `$xpkg\\[\\e[00m\\]:[\\W]\\\$ '
  614. alias cp="cp -i" ; alias mv="mv -i"
  615. alias rm="rm -i" ; alias ls="ls --color=auto -a"
  616. alias ..="cd .." ; alias ...="cd ../.."
  617. alias xdiff="sh $base/misc/archive/xdiff.sh"
  618. alias bked="sh $base/misc/archive/bked.sh"
  619. fixfile () {
  620. # we use .vanilla to not rediff backup .orig from patch
  621. [ -f \$1.vanilla ] || cp \$1 \$1.vanilla
  622. \$EDITOR \$1
  623. }
  624. fixfilediff() {
  625. find -name '*.vanilla' | while read x ; do
  626. diff -u \$x \${x/.vanilla/}
  627. done
  628. }
  629. EOT
  630. } > $builddir/debug.buildenv
  631. #
  632. cat > $builddir/debug_x.sh <<- EOT
  633. #!/bin/bash
  634. export PROMPT_COMMAND='. debug.buildenv; cd .; unset PROMPT_COMMAND'
  635. cd $builddir; exec bash 200>> build.pid
  636. EOT
  637. #
  638. if [ "$ROCK_THIS_IS_CHROOT" != 1 ]; then
  639. mv $builddir/debug_x.sh $builddir/debug.sh
  640. chmod +x $builddir/debug.sh
  641. fi
  642. # Create PID file
  643. #
  644. # The builtin-variable '$$' is not this pid because this proc
  645. # is just a sub-proc of $$. That's why the $builddir/strace.tmp
  646. # hack is required to get the right pid to trace.
  647. #
  648. # We also conntect filedescriptor 3 with the pid file. So the command
  649. # 'fuser' can be used to create a list of all processes which are part
  650. # of this build process.
  651. #
  652. sh -c 'echo $PPID' > $builddir/build.pid
  653. exec 200>> $builddir/build.pid
  654. echo "Command Wrapper Debug: running '${CC} --version' .."
  655. type ${CC%% *}; CMD_WRAPPER_DEBUG=1 ${CC} --version
  656. echo "[ writing debug log to $builddir/cmd_wrapper.log ]"
  657. if [ "$debug" = 1 ] ; then
  658. echo "Everything is set up." \
  659. "We are in debug mode - so exit now."
  660. exit
  661. fi
  662. if [ "$ROCKCFG_FLIST" = "strace" ] ; then
  663. if [ "$(uname -m)" = "ppc" ]; then
  664. SYSEXIT="exit"
  665. else
  666. SYSEXIT="_exit"
  667. fi
  668. strace -o $builddir/strace.out -F -f -q -e open,creat,mkdir,`
  669. `mknod,link,symlink,rename,utime,chdir,execve,fork,`
  670. `vfork,$SYSEXIT,exit_group -p `cat $builddir/build.pid` &
  671. strace_pid=$! ; sleep 1 ; cd $base
  672. fi
  673. (
  674. set -e
  675. mkdir -p "$builddir/archdir"
  676. while read l_cksum l_srctar l_url l_flags ; do
  677. [ -z "$l_cksum" ] && continue
  678. x=`source_file l_cksum $l_srctar l_url $l_flags`
  679. if [ ! -f $x ]; then
  680. echo "File not found: ${x#$base/}"
  681. echo "Did you run ./scripts/Download for this package?"
  682. false
  683. fi
  684. ln -vs $x $builddir/archdir/
  685. done < <( echo "$desc_D" | column_clean )
  686. echo "Running main build function '$mainfunction' ..."
  687. if [ $xtrace -eq 1 -o $ROCKCFG_XTRACE -eq 1 ] ; then
  688. PS4=$'=[$FUNCNAME:$LINENO (last \\\$?=$?)> ' ; set -o xtrace
  689. cd $builddir ; eval "$mainfunction"
  690. set +o xtrace
  691. else
  692. cd $builddir ; eval "$mainfunction"
  693. fi
  694. touch $root/var/adm/logs/$stagelevel-$xpkg.log
  695. )
  696. [ ! -f $root/var/adm/logs/$stagelevel-$xpkg.log ] && abort
  697. hook_eval postinstall
  698. echo "Creating file list and doing final adaptions ... "
  699. #
  700. cd $xroot/
  701. #
  702. if [ "$ROCKCFG_FLIST" = "strace" ] ; then
  703. sleep 1 ; kill -INT $strace_pid ; sleep 1
  704. fl_stparse -w $builddir/fl_wrapper.wlog \
  705. -r $builddir/fl_wrapper.rlog < $builddir/strace.out
  706. fi
  707. if [ "$ROCKCFG_FLIST" = "flwrapper" -o \
  708. "$ROCKCFG_FLIST" = "strace" ] ; then
  709. if [ "$stagelevel" -le 1 ]
  710. then
  711. xbase="$( cd $xroot/ 2> /dev/null ; pwd -P )"
  712. if egrep -qv "[ ]($base|$xbase|/tmp|/usr/tmp|/var/tmp|/proc|/dev)(/|$)" \
  713. $builddir/fl_wrapper.wlog
  714. then
  715. x="Created file outside basedir: "
  716. egrep -v "[ ]($base|$xbase|/tmp|/usr/tmp|/var/tmp|/proc|/dev)(/|$)" \
  717. $builddir/fl_wrapper.wlog | \
  718. cut -f2- | sort -u | sed "s,^,$x,"
  719. echo "base #1: $base"
  720. echo "base #2: $xbase"
  721. abort
  722. fi
  723. fi
  724. if fl_wrparse -D -s -r "$xroot/" < $builddir/fl_wrapper.wlog | \
  725. egrep "^(${flistroot// /|})(/|$)" >> \
  726. $builddir/flist.txt
  727. then : ; fi
  728. elif [ "$ROCKCFG_FLIST" = "find" ] ; then
  729. if find $flistroot \
  730. \( -not -type d -or -type d -empty \) \
  731. -and \( -newer $builddir/temp.time_stamp -or \
  732. -cnewer $builddir/temp.time_stamp \) -printf "%p\n" >> \
  733. $builddir/flist.txt
  734. then : ; fi
  735. fi
  736. # evaluate flistdel (1/2)
  737. egrep -v "^($flistdel|var/adm/.*)\$" $builddir/flist.txt | sort -u > $builddir/flist.txt.new
  738. mv $builddir/flist.txt.new $builddir/flist.txt
  739. # copy over missing *.a files
  740. if [ "$autoso2a" = 1 ]; then
  741. echo "Checking for missing .a files ..."
  742. while read d s; do
  743. grep -q "/${s%.so}.a$" $builddir/flist.txt && continue
  744. [ "$d" = "lib" ] && d="usr/lib"
  745. if [ -f "$AUTOSO2A_DIR/${s%.so}.a" ]; then
  746. echo "Installing automatically created $d/${s%.so}.a."
  747. cp "$AUTOSO2A_DIR/${s%.so}.a" "$root/$d/${s%.so}.a"
  748. add_flist "$root/$d/${s%.so}.a"
  749. else
  750. echo "Not found: $AUTOSO2A_DIR/${s%.so}.a"
  751. fi
  752. done < <( egrep '(^|/)lib/[^/]*\.so$' $builddir/flist.txt | sed 's,\(.*\)/,\1 ,' )
  753. fi
  754. # merge flist of previous build
  755. for x in var/adm/flists/$xpkg var/adm/flists/$xpkg:*; do
  756. [ -f $x ] && cut -f2- -d' ' $x >> $builddir/flist.txt
  757. done
  758. # evaluate flistdel (2/2)
  759. egrep -v "^($flistdel|var/adm/.*)\$" $builddir/flist.txt | sort -u > $builddir/flist.txt.new
  760. mv $builddir/flist.txt.new $builddir/flist.txt
  761. hook_eval postflist
  762. fl_wrparse -D -p "$xpkg" -r "$xroot/" < $builddir/flist.txt | sort -u > $builddir/flist.split
  763. echo Found `wc -l < $builddir/flist.split` "files for this package."
  764. splitapply $xpkg $builddir/flist.split
  765. if [ "$ROCKCFG_FLIST" = "flwrapper" -o \
  766. "$ROCKCFG_FLIST" = "strace" ] && [ $stagelevel -gt 1 ] ; then
  767. echo "Calculating package dependencies ..."
  768. ! egrep -v "^($flistrfilter)\$" $builddir/fl_wrapper.[rw]log |
  769. sort -u | fl_wrparse -D -s -r "$xroot/" -p '' | \
  770. grep -v ' var/adm/' | awk '
  771. ARGIND < ARGC-1 {
  772. if ( index($1, "'$xpkg':") != 1 )
  773. f[$2] = $1 " " f[$2];
  774. }
  775. ARGIND == ARGC-1 {
  776. file = $2;
  777. while ( file != "" ) {
  778. if ( f[file] ) {
  779. split(f[file], a);
  780. for (i in a)
  781. if (! d[a[i] " " file]) {
  782. d[a[i] " " file] = 1;
  783. print a[i] " " file;
  784. }
  785. }
  786. sub("/?[^/]*$", "", file)
  787. }
  788. }
  789. ' var/adm/flists/* - > $builddir/dependencies.debug
  790. awk 'BEGIN { FS=": "; } { print "'$xpkg': " $1; }' \
  791. < $builddir/dependencies.debug > $builddir/dependencies.txt
  792. if [ -f var/adm/dep-debug/$xpkg ] ; then
  793. cat var/adm/dep-debug/$xpkg >> $builddir/dependencies.debug
  794. fi
  795. sort -u $builddir/dependencies.debug > var/adm/dep-debug/$xpkg
  796. # add debug info for known false positives
  797. if egrep -q "^[^#].*[ ]$spkg([ ]|$)" $base/scripts/dep_fixes.txt; then
  798. echo "--- $spkg [$stagelevel] ---" >> $root/var/adm/rock-debug/falsedeps.txt
  799. fi
  800. while read x; do
  801. grep "^$x: " $builddir/dependencies.debug | sort -u | \
  802. sed "s,:, -> $spkg [$stagelevel]:," >> $root/var/adm/rock-debug/falsedeps.txt
  803. done < <( egrep "^$spkg[ ]+del[ ]+" $base/scripts/dep_fixes.txt | \
  804. tr ' ' '\t' | tr -s '\t' | cut -f3- | tr '\t' '\n' )
  805. # merge the dependencies defined by the package
  806. for x in `echo "$desc_E" | egrep '^add ' | sed 's/^add //' ` ; do
  807. echo "Adding dependency: $x ..."
  808. echo "$xpkg: $x" >> $builddir/dependencies.txt
  809. done
  810. # remove dependencies as requested by the package
  811. # TODO: goups are not used yet (and it is not easy here)
  812. del_pattern=""
  813. for x in `echo "$desc_E" | egrep '^del ' | sed 's/^del //' ` ; do
  814. del_pattern="$del_pattern -e \".*: $x(:.*|)\$\""
  815. done
  816. if [ -n "$del_pattern" ] ; then
  817. echo "Deleting dependencies, pattern: $del_pattern ..."
  818. eval "egrep -v $del_pattern $builddir/dependencies.txt" > $builddir/dependencies.txt.new
  819. mv $builddir/dependencies.txt.new $builddir/dependencies.txt
  820. fi
  821. if [ -f var/adm/dependencies/$xpkg ] ; then
  822. cat var/adm/dependencies/$xpkg >> $builddir/dependencies.txt
  823. fi
  824. sort -u $builddir/dependencies.txt > $builddir/dependencies.txt.new
  825. mv $builddir/dependencies.txt.new $builddir/dependencies.txt
  826. fi
  827. for spkg in $( sed 's,: .*,,' < $builddir/flist.split | sort -u )
  828. do
  829. (
  830. if [ -z "${spkg##*:*}" ]; then
  831. splitdesc_${spkg#*:}
  832. fi
  833. echo "<$spkg> Creating flist file ..."
  834. {
  835. grep "^$spkg: " $builddir/flist.split
  836. [ -s "var/adm/parse-config/$spkg" ] && \
  837. echo "$spkg: var/adm/parse-config/$spkg"
  838. for x in var/adm/flists/$spkg var/adm/md5sums/$spkg \
  839. var/adm/cksums/$spkg var/adm/packages/$spkg \
  840. var/adm/descs/$spkg var/adm/dependencies/$spkg ; do
  841. touch $x ; echo "$spkg: $x"
  842. done
  843. } | sort -u > var/adm/flists/$spkg
  844. echo "<$spkg> Creating package dependencies file ..."
  845. sed "s,^[^ ]*,$spkg:," < $builddir/dependencies.txt > var/adm/dependencies/$spkg
  846. echo "<$spkg> Creating md5sum and cksum files ..."
  847. getfiles < var/adm/flists/$spkg > $builddir/files.lst
  848. if [ -s $builddir/files.lst ] ; then
  849. cat $builddir/files.lst | \
  850. grep -v '^var/adm/' | sed -e 's/ /\\ /g' | \
  851. xargs -r md5sum > var/adm/md5sums/$spkg
  852. cat $builddir/files.lst | \
  853. grep -v '^var/adm/' | sed -e 's/ /\\ /g' | \
  854. xargs -r cksum > var/adm/cksums/$spkg
  855. else
  856. cat /dev/null > var/adm/md5sums/$spkg
  857. cat /dev/null > var/adm/cksums/$spkg
  858. fi
  859. echo "<$spkg> Creating package description ..."
  860. #
  861. rocksrcck=$(cd $base; md5sum package/*/$pkg/* 2> /dev/null | \
  862. grep -v '\.cache$' | md5sum | cut -f1 -d' ')
  863. buildlist="$( grep "^Build \[.\] at " var/adm/packages/$spkg || true
  864. echo "Build [$stagelevel] at $buildstart to `date "+%T %Z"`")"
  865. #
  866. cat > var/adm/packages/$spkg << EOT
  867. Package Name and Version: $spkg $ver $extraver
  868. Package Size: `getdu $root/ < var/adm/flists/$spkg`, `
  869. wc -l < var/adm/flists/$spkg | tr -d ' '` files
  870. ROCK Linux Package Source Checksum: $rocksrcck
  871. ROCK Linux Version and Architecture: $rockver $arch
  872. Build on `uname -m -n -r -s -p`
  873. $buildlist
  874. Status: ${desc_S:-ALPHA}, License: ${desc_L:-Unknown}
  875. ${desc_I:-$spkg}
  876. $( echo "${desc_T:-No description available.}" | sed 's,^, ,' )
  877. URL(s):
  878. $( echo "${desc_U:-http://www.rocklinux.net/packages/$pkg.html}" | sed 's,^, ,' )
  879. Original Author(s):
  880. $( echo "${desc_A:-Unknown}" | sed 's,^, ,' )
  881. ROCK Package Maintainer(s):
  882. $( echo "${desc_M:-Unknown}" | sed 's,^, ,' )
  883. Download URL(s):
  884. $( echo "${desc_D:-None}" | awk '{ print " " $3 $2; }' )
  885. EOT
  886. {
  887. echo "[CONFIG] ${ROCKCFG_ID#*-}"
  888. while read x; do
  889. if [ "${x#\[}" != "$x" ]; then
  890. x="`echo ${x// /|} | tr -d '[]'`"
  891. y="${x%%|*}" ; x="(${x%|(*)})"
  892. case "$y" in
  893. V) echo "[V] $ver $extraver" ;;
  894. *) echo "$descfile" | egrep "^\[$x\]" | expand | sed "s,^[^ ]*,[$y]," ;;
  895. esac
  896. fi
  897. done < $base/Documentation/Developers/PKG-DESC-FORMAT
  898. } > var/adm/descs/$spkg
  899. )
  900. done
  901. echo "Making post-install adaptions."
  902. if [ $stagelevel -ge 2 -a -f /sbin/ldconfig ] ; then ldconfig ; fi
  903. if [ "$ROCKCFG_PARANOIA_CHECK" = 1 ] ; then
  904. found_errors=0
  905. found_dups=0
  906. # check for files which are 'shared' with other packages
  907. if [ "$check_shared" != "0" ]; then
  908. while read dummy file; do
  909. if [ $found_dups = 0 ] ; then
  910. echo "Found shared files with other packages:"
  911. found_errors=1; found_dups=1
  912. fi
  913. echo "$file:" $( cd $root/var/adm/flists
  914. grep -l " $file\$" * )
  915. done < <( cat $root/var/adm/flists/* | sed "s,^$xpkg:[^ ]*,.," | \
  916. sort -k2 | uniq -d -f1 | grep '^\. ' )
  917. fi
  918. found_local=0
  919. # check for files in /usr/local
  920. if [ "$check_usrlocal" != "0" ]; then
  921. while read file ; do
  922. if [ $found_local = 0 ] ; then
  923. echo "Found files in /usr/local:"
  924. found_errors=1; found_local=1
  925. fi
  926. echo $file
  927. done < <( sed "s,^$xpkg: ,/," $root/var/adm/flists/$xpkg \
  928. $root/var/adm/flists/$xpkg:* 2> /dev/null | egrep "^/usr/local" )
  929. fi
  930. found_bad=0
  931. # check for registered 'bad files'
  932. if [ "$check_badfiles" != "0" -a -n "$badfiles" ]; then
  933. echo "$badfiles" > $builddir/badfiles.txt
  934. while read x file; do
  935. if [ $found_bad = 0 ]; then
  936. echo "Found registered 'bad files' in package:"
  937. found_errors=1; found_bad=1
  938. fi
  939. desc="No description found!"
  940. for ((x=0; x<badfiles_nr; x++)); do
  941. if echo " $file" | grep -q "${badfiles_desc[x]%%$'\n'*}"
  942. then desc="${badfiles_desc[x]#*$'\n'}"; fi
  943. done
  944. echo "$file: $desc"
  945. done < <( grep -f $builddir/badfiles.txt $root/var/adm/flists/$xpkg \
  946. $root/var/adm/flists/$xpkg:* 2> /dev/null )
  947. fi
  948. [ $found_errors != 0 ] && abort
  949. fi
  950. echo "Finished building $pkg=$xpkg."
  951. } 2>&1 | {
  952. trap '' INT
  953. echo_status "Building. Writing output to" \
  954. "\$root/var/adm/logs/$stagelevel-$xpkg.out"
  955. if [ "$ROCKCFG_VERBOSE" = 1 -o "$verbose" = 1 ] ; then
  956. tee $root/var/adm/logs/$stagelevel-$xpkg.out
  957. else
  958. cat > $root/var/adm/logs/$stagelevel-$xpkg.out
  959. fi
  960. }
  961. hook_eval finish
  962. if [ $update = 1 ] ; then
  963. echo_status "Restoring backup of old package data."
  964. while read fn ; do
  965. [ -f $xroot/$fn ] && mv $xroot/$fn $xroot/$fn.new
  966. done < $builddir/backup_files.txt
  967. tar --force-local --use-compress-program=bzip2 -C $xroot/ -xpf $backup_tar
  968. while read fn ; do
  969. cmp -s $fn $fn.new && rm -f $fn.new
  970. done < $builddir/backup_files.txt
  971. fi
  972. cd $base
  973. umount -r -d -f $builddir/* 2> /dev/null
  974. umount -r -d -f -l $builddir/* 2> /dev/null
  975. if [ "$ROCKCFG_SRC_TMPFS_LOG" = 1 -a -n "$( type -p df )" ]; then
  976. if [ ! -f $root/var/adm/rock-debug/tmpfslog.txt ] ; then
  977. echo -e "# Config\tPackage\tInodes\tKB" | \
  978. expand -t20 > $root/var/adm/rock-debug/tmpfslog.txt
  979. fi
  980. echo -e "$config\t$stagelevel-$xpkg\t$(
  981. df 2> /dev/null -Pi $builddir | tail -n 1 | tr -s ' ' | cut -f3 -d' '
  982. )\t$(
  983. df 2> /dev/null -Pk $builddir | tail -n 1 | tr -s ' ' | cut -f3 -d' ')" | \
  984. expand -t20 >> $root/var/adm/rock-debug/tmpfslog.txt
  985. fi
  986. umount -r -d -f $builddir 2> /dev/null
  987. umount -r -d -f -l $builddir 2> /dev/null
  988. if [ "$ROCKCFG_PSEUDONATIVE" = 1 -a $stagelevel -eq 0 ]; then
  989. rm -f $base/build/$ROCKCFG_ID/pseudonative_handler
  990. fi
  991. if [ -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then
  992. if [ $clear_src = 1 ] ; then
  993. rm -rf $builddir/* $builddir
  994. else
  995. cp $root/var/adm/logs/$stagelevel-$xpkg.out $builddir/BUILD-LOG
  996. fi
  997. echo_status "\$root/var/adm/logs/$stagelevel-$xpkg.out" \
  998. "-> $stagelevel-$xpkg.log"
  999. mv $root/var/adm/logs/$stagelevel-$xpkg.out \
  1000. $root/var/adm/logs/$stagelevel-$xpkg.log
  1001. echo_pkg_finish $stagelevel $repository $xpkg
  1002. exit 0
  1003. else
  1004. if [ $clear_src = 1 -a "$ROCKCFG_ALWAYS_CLEAN" = 1 ] ; then
  1005. rm -rf $builddir/* $builddir
  1006. else
  1007. cp $root/var/adm/logs/$stagelevel-$xpkg.out $builddir/ERROR-LOG
  1008. fi
  1009. if [ "$ROCKCFG_VERBOSE" != 1 -a "$verbose" != 1 ] ; then
  1010. echo_errorquote "$( grep -B7 -- '--- BUILD ERROR ---' \
  1011. $root/var/adm/logs/$stagelevel-$xpkg.out | \
  1012. sed '$ s,--- BUILD ERROR ---,,' | \
  1013. grep . | grep -vx -- -- )"
  1014. fi
  1015. echo_status "\$root/var/adm/logs/$stagelevel-$xpkg.out" \
  1016. "-> $stagelevel-$xpkg.err"
  1017. mv $root/var/adm/logs/$stagelevel-$xpkg.out \
  1018. $root/var/adm/logs/$stagelevel-$xpkg.err
  1019. echo_pkg_abort $stagelevel $repository $xpkg
  1020. exit 1
  1021. fi
  1022. # ---- EOF