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.

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