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.

1212 lines
36 KiB

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