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.

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