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.

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