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.

1185 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. srcdir=auto ; srctar=auto
  443. taropt="--use-compress-program=bzip2 -xf"
  444. mainfunction="build_this_package"
  445. runconf=1 ; runxmkmf=1 ; runmkpl=1 ; runpysetup=1 ; autopatch=1
  446. autoextract=1 ; chownsrcdir=1 ; nocvsinsrcdir=1; patchopt="-bfp1 -z .orig"
  447. createprefix=1 ; createdocs="" ; rmemptydir="" ; autoso2a=0
  448. check_shared=1
  449. check_usrlocal=1
  450. check_badfiles=1
  451. badfiles="" badfiles_nr=0
  452. declare -a badfiles_desc
  453. #
  454. # ---- Read various config files
  455. #
  456. parse_desc $confdir/$pkg.desc
  457. ver="`echo "$desc_V" | tail -n 1 | cut -f1 -d' '`"
  458. extraver="`echo "$desc_V" | tail -n 1 | cut -s -f2- -d' '`"
  459. [ -z "$extraver" ] && extraver="${rockver//DEV-*/DEV}"
  460. if [ "$pkg" = "$xpkg" ]; then
  461. echo_pkg_start $stagelevel $repository $xpkg $ver $extraver
  462. else
  463. echo_pkg_start $stagelevel $repository $pkg=$xpkg $ver $extraver
  464. fi
  465. if [ "$ROCKCFG_PARANOIA_CHECK" = 1 -a -z "$pkgdir" ] ; then
  466. x="`./scripts/Check-PkgFormat $pkg`"
  467. [ "$x" ] && abort "$x\nDisable the 'Paranoia Check' config `
  468. `option to ignore such errors."
  469. fi
  470. targetdir="$base/target/$target"
  471. patchfiles="`ls $confdir/*.patch $confdir/*.patch.$arch \
  472. $confdir/*.patch_$xpkg $confdir/*.patch_$xpkg.$arch \
  473. $targetdir/pkg_$pkg.patch $targetdir/pkg_$pkg.patch.$arch \
  474. $targetdir/xpkg_$xpkg.patch $targetdir/xpkg_$xpkg.patch.$arch \
  475. 2>/dev/null | tr '\n' ' '`"
  476. if [ $stagelevel -le 1 ]; then
  477. patchfiles="`ls $patchfiles $confdir/*.patch.cross \
  478. $confdir/*.patch.cross.$arch 2>/dev/null | tr '\n' ' '`"
  479. fi
  480. if [ $stagelevel -eq 0 ]; then
  481. flistroot="$flistroot include share doc info man"
  482. flistroot="$flistroot crosscc wrapper $arch_target"
  483. createdocs=0
  484. fi
  485. if [ $stagelevel -gt 1 ]; then
  486. for pc_file in $xroot/var/adm/parse-config/* ; do
  487. if [ -s "$pc_file" -a "${pc_file##*/}" != "$xpkg" ]
  488. then . "$pc_file" ; fi
  489. done
  490. unset pc_file
  491. fi
  492. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config
  493. set_confopt
  494. if [ $stagelevel -eq 0 -a "$ROCKCFG_PSEUDONATIVE" = 1 ]; then
  495. echo_status "Building this package statically for pseudo native build."
  496. var_insert extraconfopt " " "--enable-static --disable-shared"
  497. for x in BUILDCC_WRAPPER_INSERT LDFLAGS LD CFLAGS CC; do
  498. var_append $x " " "-static"
  499. done
  500. fi
  501. eval "$desc_O"
  502. # include package pre config - if any
  503. if [ -f $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_pre.conf ] ; then
  504. echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_pre.conf"
  505. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_pre.conf
  506. fi
  507. if [ -f $targetdir/pkg_$pkg.conf ] ; then
  508. echo_status "Reading package configuration from target directory."
  509. . $targetdir/pkg_$pkg.conf
  510. elif [ -f $confdir/$pkg.conf ] ; then
  511. echo_status "Reading package configuration from package directory."
  512. . $confdir/$pkg.conf
  513. fi
  514. # include package post config - if any
  515. if [ -f $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_post.conf ] ; then
  516. echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_post.conf"
  517. . $base/build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_${pkg}_post.conf
  518. fi
  519. if [ -f $base/architecture/$arch/pkg-header ] ; then
  520. echo_status "Reading overwrites from architecture/$arch/pkg-header."
  521. . $base/architecture/$arch/pkg-header
  522. fi
  523. if [ -f $base/target/$target/pkg-header ] ; then
  524. echo_status "Reading overwrites from target/$target/pkg-header."
  525. . $base/target/$target/pkg-header
  526. fi
  527. #
  528. # ---- Variable updates based on the configuration files read
  529. #
  530. if [ -z "$prefix" -o "${prefix#usr}" != "$prefix" ] ; then
  531. flistdel="$flistdel|usr/share/info/(dir|standards.info)"
  532. if [ "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  533. flistdel="$flistdel|usr/share/locale/..[/_].*"
  534. flistdel="$flistdel|usr/share/man/..[/_].*"
  535. fi
  536. if [ $stagelevel = 0 ] ; then
  537. flistdel="${flistdel//usr\//}|${flistdel//usr\/share\//}"
  538. fi
  539. else
  540. flistdel="$flistdel|$prefix/info/(dir|standards.info)"
  541. if [ "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  542. flistdel="$flistdel|$prefix/share/locale/..[/_].*"
  543. flistdel="$flistdel|$prefix/man/..[/_].*"
  544. fi
  545. fi
  546. #
  547. # ---- Build Package
  548. #
  549. echo_status "Preparing build in src.$xpkg.$id"
  550. mkdir -p $builddir; chmod 700 $builddir
  551. if [ $clear_src = 1 ] ; then
  552. if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then
  553. mount -t tmpfs -o $ROCKCFG_SRC_TMPFS_OPT none $builddir
  554. fi
  555. fi
  556. if [ "$xroot" != "$root" ] ; then
  557. for x in $flistroot ; do
  558. [ -d $xroot/$x ] || mkdir -p $xroot/$x
  559. [ -d $root/$x ] || ln -sf $xroot/$x $root/
  560. done
  561. fi
  562. if [ $update = 1 ] ; then
  563. echo_status "Creating backup of old package data (running in update mode)."
  564. (
  565. cd $xroot/
  566. cat var/adm/md5sums/$xpkg var/adm/md5sums/$xpkg:* 2> /dev/null |
  567. md5sum --check - 2>&1 | grep ': FAILED$' | cut -f1 -d:
  568. ) > $builddir/backup_files.txt
  569. if [ -s $builddir/backup_files.txt ] ; then
  570. mkdir -p "$xroot/var/adm/backup"
  571. chmod 700 "$xroot/var/adm/backup"
  572. backup_tar="$xroot/var/adm/backup/$(
  573. date '+%Y%m%d%H%M%S')_$xpkg.tar.bz2"
  574. ( cd $xroot/; tar --no-recursion -cf - -T $builddir/`
  575. `backup_files.txt || true; ) | bzip2 > $backup_tar
  576. else
  577. update=0
  578. fi
  579. fi
  580. if [ "$ROCKCFG_FLIST" = "flwrapper" ] ; then
  581. rm -f $builddir/fl_wrapper.wlog $builddir/fl_wrapper.rlog
  582. touch $builddir/fl_wrapper.wlog $builddir/fl_wrapper.rlog
  583. elif [ "$ROCKCFG_FLIST" = "find" ] ; then
  584. touch $builddir/temp.time_stamp
  585. sleep 2
  586. fi
  587. if [ $stagelevel -gt 1 -a "$autoso2a" = 1 ]; then
  588. export AUTOSO2A_DIR="$builddir/autoso2a"
  589. export AUTOSO2A_AR="$AR" AUTOSO2A_RANLIB="$RANLIB"
  590. var_insert CC_WRAPPER_OTHERS ":" "so2a_wrapper"
  591. var_insert CXX_WRAPPER_OTHERS ":" "so2a_wrapper"
  592. fi
  593. hook_eval prepare
  594. # define new abort function for errors while building
  595. #
  596. abort() {
  597. [ "$*" ] && echo "$*"; echo "--- BUILD ERROR ---"
  598. rm -vf $root/var/adm/logs/$stagelevel-$xpkg.log
  599. false
  600. }
  601. {
  602. trap 'echo "Got SIGINT (Crtl-C). Aborting build." ; exit 1' INT
  603. exec < /dev/null
  604. # Makes debugging build problems easier
  605. #
  606. hook_dump > $builddir/debug.hooks
  607. #
  608. {
  609. dump_env
  610. cat <<- EOT
  611. PS1='\\[\\e[00m\\e[01;31m\\]debug-`
  612. `$xpkg\\[\\e[00m\\]:[\\W]\\\$ '
  613. alias cp="cp -i" ; alias mv="mv -i"
  614. alias rm="rm -i" ; alias ls="ls --color=auto -a"
  615. alias ..="cd .." ; alias ...="cd ../.."
  616. alias xdiff="sh $base/misc/archive/xdiff.sh"
  617. alias bked="sh $base/misc/archive/bked.sh"
  618. fixfile () {
  619. # we use .vanilla to not rediff backup .orig from patch
  620. [ -f \$1.vanilla ] || cp \$1 \$1.vanilla
  621. \$EDITOR \$1
  622. }
  623. fixfilediff() {
  624. find -name '*.vanilla' | while read x ; do
  625. diff -u \$x \${x/.vanilla/}
  626. done
  627. }
  628. EOT
  629. } > $builddir/debug.buildenv
  630. #
  631. cat > $builddir/debug_x.sh <<- EOT
  632. #!/bin/bash
  633. export PROMPT_COMMAND='. debug.buildenv; cd .; unset PROMPT_COMMAND'
  634. cd $builddir; exec bash 200>> build.pid
  635. EOT
  636. #
  637. if [ "$ROCK_THIS_IS_CHROOT" != 1 ]; then
  638. mv $builddir/debug_x.sh $builddir/debug.sh
  639. chmod +x $builddir/debug.sh
  640. fi
  641. # Create PID file
  642. #
  643. # The builtin-variable '$$' is not this pid because this proc
  644. # is just a sub-proc of $$. That's why the $builddir/strace.tmp
  645. # hack is required to get the right pid to trace.
  646. #
  647. # We also conntect filedescriptor 3 with the pid file. So the command
  648. # 'fuser' can be used to create a list of all processes which are part
  649. # of this build process.
  650. #
  651. sh -c 'echo $PPID' > $builddir/build.pid
  652. exec 200>> $builddir/build.pid
  653. echo "Command Wrapper Debug: running '${CC} --version' .."
  654. type ${CC%% *}; CMD_WRAPPER_DEBUG=1 ${CC} --version
  655. echo "[ writing debug log to $builddir/cmd_wrapper.log ]"
  656. if [ "$debug" = 1 ] ; then
  657. echo "Everything is set up." \
  658. "We are in debug mode - so exit now."
  659. exit
  660. fi
  661. if [ "$ROCKCFG_FLIST" = "strace" ] ; then
  662. strace -o $builddir/strace.out -F -f -q -e open,creat,mkdir,`
  663. `mknod,link,symlink,rename,utime,chdir,execve,fork,`
  664. `vfork,_exit,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. echo "$descfile" | egrep "^\[$x\]" | expand | sed "s,^[^ ]*,[$y],"
  887. fi
  888. done < $base/Documentation/Developers/PKG-DESC-FORMAT
  889. } > var/adm/descs/$spkg
  890. )
  891. done
  892. echo "Making post-install adaptions."
  893. if [ $stagelevel -ge 2 -a -f /sbin/ldconfig ] ; then ldconfig ; fi
  894. if [ "$ROCKCFG_PARANOIA_CHECK" = 1 ] ; then
  895. found_errors=0
  896. found_dups=0
  897. # check for files which are 'shared' with other packages
  898. if [ "$check_shared" != "0" ]; then
  899. while read dummy file; do
  900. if [ $found_dups = 0 ] ; then
  901. echo "Found shared files with other packages:"
  902. found_errors=1; found_dups=1
  903. fi
  904. echo "$file:" $( cd $root/var/adm/flists
  905. grep -l " $file\$" * )
  906. done < <( cat $root/var/adm/flists/* | sed "s,^$xpkg:[^ ]*,.," | \
  907. sort -k2 | uniq -d -f1 | grep '^\. ' )
  908. fi
  909. found_local=0
  910. # check for files in /usr/local
  911. if [ "$check_usrlocal" != "0" ]; then
  912. while read file ; do
  913. if [ $found_local = 0 ] ; then
  914. echo "Found files in /usr/local:"
  915. found_errors=1; found_local=1
  916. fi
  917. echo $file
  918. done < <( sed "s,^$xpkg: ,/," $root/var/adm/flists/$xpkg \
  919. $root/var/adm/flists/$xpkg:* 2> /dev/null | egrep "^/usr/local" )
  920. fi
  921. found_bad=0
  922. # check for registered 'bad files'
  923. if [ "$check_badfiles" != "0" -a -n "$badfiles" ]; then
  924. echo "$badfiles" > $builddir/badfiles.txt
  925. while read x file; do
  926. if [ $found_bad = 0 ]; then
  927. echo "Found registered 'bad files' in package:"
  928. found_errors=1; found_bad=1
  929. fi
  930. desc="No description found!"
  931. for ((x=0; x<badfiles_nr; x++)); do
  932. if echo " $file" | grep -q "${badfiles_desc[x]%%$'\n'*}"
  933. then desc="${badfiles_desc[x]#*$'\n'}"; fi
  934. done
  935. echo "$file: $desc"
  936. done < <( grep -f $builddir/badfiles.txt $root/var/adm/flists/$xpkg \
  937. $root/var/adm/flists/$xpkg:* 2> /dev/null )
  938. fi
  939. [ $found_errors != 0 ] && abort
  940. fi
  941. echo "Finished building $pkg=$xpkg."
  942. } 2>&1 | {
  943. trap '' INT
  944. echo_status "Building. Writing output to" \
  945. "\$root/var/adm/logs/$stagelevel-$xpkg.out"
  946. if [ "$ROCKCFG_VERBOSE" = 1 -o "$verbose" = 1 ] ; then
  947. tee $root/var/adm/logs/$stagelevel-$xpkg.out
  948. else
  949. cat > $root/var/adm/logs/$stagelevel-$xpkg.out
  950. fi
  951. }
  952. hook_eval finish
  953. if [ $update = 1 ] ; then
  954. echo_status "Restoring backup of old package data."
  955. while read fn ; do
  956. [ -f $xroot/$fn ] && mv $xroot/$fn $xroot/$fn.new
  957. done < $builddir/backup_files.txt
  958. tar --use-compress-program=bzip2 -C $xroot/ -xpf $backup_tar
  959. while read fn ; do
  960. cmp -s $fn $fn.new && rm -f $fn.new
  961. done < $builddir/backup_files.txt
  962. fi
  963. cd $base
  964. umount -r -d -f $builddir/* 2> /dev/null
  965. umount -r -d -f -l $builddir/* 2> /dev/null
  966. if [ "$ROCKCFG_SRC_TMPFS_LOG" = 1 -a -n "$( type -p df )" ]; then
  967. if [ ! -f $root/var/adm/rock-debug/tmpfslog.txt ] ; then
  968. echo -e "# Config\tPackage\tInodes\tKB" | \
  969. expand -t20 > $root/var/adm/rock-debug/tmpfslog.txt
  970. fi
  971. echo -e "$config\t$stagelevel-$xpkg\t$(
  972. df 2> /dev/null -Pi $builddir | tail -n 1 | tr -s ' ' | cut -f3 -d' '
  973. )\t$(
  974. df 2> /dev/null -Pk $builddir | tail -n 1 | tr -s ' ' | cut -f3 -d' ')" | \
  975. expand -t20 >> $root/var/adm/rock-debug/tmpfslog.txt
  976. fi
  977. umount -r -d -f $builddir 2> /dev/null
  978. umount -r -d -f -l $builddir 2> /dev/null
  979. if [ "$ROCKCFG_PSEUDONATIVE" = 1 -a $stagelevel -eq 0 ]; then
  980. rm -f $base/build/$ROCKCFG_ID/pseudonative_handler
  981. fi
  982. if [ -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then
  983. if [ $clear_src = 1 ] ; then
  984. rm -rf $builddir/* $builddir
  985. else
  986. cp $root/var/adm/logs/$stagelevel-$xpkg.out $builddir/BUILD-LOG
  987. fi
  988. echo_status "\$root/var/adm/logs/$stagelevel-$xpkg.out" \
  989. "-> $stagelevel-$xpkg.log"
  990. mv $root/var/adm/logs/$stagelevel-$xpkg.out \
  991. $root/var/adm/logs/$stagelevel-$xpkg.log
  992. echo_pkg_finish $stagelevel $repository $xpkg
  993. exit 0
  994. else
  995. if [ $clear_src = 1 -a "$ROCKCFG_ALWAYS_CLEAN" = 1 ] ; then
  996. rm -rf $builddir/* $builddir
  997. else
  998. cp $root/var/adm/logs/$stagelevel-$xpkg.out $builddir/ERROR-LOG
  999. fi
  1000. if [ "$ROCKCFG_VERBOSE" != 1 -a "$verbose" != 1 ] ; then
  1001. echo_errorquote "$( grep -B7 -- '--- BUILD ERROR ---' \
  1002. $root/var/adm/logs/$stagelevel-$xpkg.out | \
  1003. sed '$ s,--- BUILD ERROR ---,,' | \
  1004. grep . | grep -vx -- -- )"
  1005. fi
  1006. echo_status "\$root/var/adm/logs/$stagelevel-$xpkg.out" \
  1007. "-> $stagelevel-$xpkg.err"
  1008. mv $root/var/adm/logs/$stagelevel-$xpkg.out \
  1009. $root/var/adm/logs/$stagelevel-$xpkg.err
  1010. echo_pkg_abort $stagelevel $repository $xpkg
  1011. exit 1
  1012. fi
  1013. # ---- EOF