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.

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