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.

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