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.

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