2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: scripts/Build-Pkg
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 Clifford Wolf
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- SDE-COPYRIGHT-NOTE-END ---
20 buildstart
="`date "+%m
/%d
/%Y from
%T
"`"
22 sderootdirs
="scripts bin etc lib doc src package architecture target"
52 echo "Usage: ./scripts/Build-Pkg" \
53 "[ -0 | -1 | -2 ... | -8 | -9 ] \\"
54 echo "$spacer [ -v ] [ -xtrace ] [ -chroot ] \\"
55 echo "$spacer [ -root { <rootdir> | auto } ] \\"
56 echo "$spacer [ -cfg <config> ] [ -update ] \\"
57 echo "$spacer [ -prefix <prefix-dir> ] [ -norebuild ] \\"
58 echo "$spacer [ -noclearsrc ] [ -pkgdir <pkgdir> ] \\"
59 echo "$spacer [ -id <id> ] [ -debug ] pkg-name(s)"
64 # ---- Parse options + config and make Build-Pkg sub-calls
69 -this_is_the_2nd_run) this_is_the_2nd_run
=1 ;;
70 -[0-9]) options
="$options $1" ; stagelevel
=${1#-} ;;
71 -v) options
="$options $1" ; verbose
=1 ;;
72 -xtrace) options
="$options $1" ; xtrace
=1 ;;
73 -debug) options
="$options $1" ; debug
=1 ; clear_src
=0 ;;
74 -update) options
="$options $1" ; update
=1 ;;
75 -chroot) options
="$options $1" ; chroot
=1 ;;
76 -chr-sub) options
="$options $1" ; chroot
=0 ;;
77 -cfg) options
="$options $1 $2" ; config
="$2" ; shift ;;
78 -root) options
="$options $1 $2" ; root
="$2" ; shift ;;
79 -prefix) options
="$options $1 $2" ;
80 prefix_auto
=0 ; prefix
="$2" ; shift ;;
81 -id) options
="$options $1 $2" ; id
="$2" ; shift ;;
82 -pkgdir) options
="$options $1 $2" ; pkgdir
="$2" ; shift ;;
83 -noclearsrc) options
="$options $1" ; clear_src
=0 ;;
84 -norebuild) options
="$options $1" ; norebuild
=1 ;;
85 -*) help_msg
; exit 1 ;;
91 # check if arguments are left as package names
99 if [ -z "$root" -a $stagelevel -le 1 ] ||
100 [ -z "$root" -a $chroot -eq 1 ] ||
101 [ "$root" = auto
]; then
102 if atstage toolchain
; then
103 root
="build/$SDECFG_ID/TOOLCHAIN/$toolsdir"
105 # the new systems root
106 root
="build/$SDECFG_ID";
110 [ "$pkgdir" -a "${pkgdir#/}" = "$pkgdir" ] && pkgdir
="$base/$pkgdir"
111 [ "$root" -a "${root#/}" = "$root" ] && root
="$base/$root"
113 # remove leading and trailing / on prefix and root
114 prefix
=${prefix%/} ; prefix=${prefix#/} ; root=${root%/}
116 # xroot is for internal use and always points to the new system
118 if ! atstage native
; then
119 sysroot
="$base/build/$SDECFG_ID" # always fresh sandbox
126 if [ -z "$id" ] ; then
128 options
="$options -id $id"
131 # more than one package is passed
132 if [ $# -gt 1 ] ; then
134 if ! .
/scripts
/Build-Pkg
$options $x && \
135 [ $stagelevel -le "$SDECFG_CONTINUE_ON_ERROR_AFTER" ] ; then
141 pkg
="${1%=*}" ; xpkg
="${1#*=}"
142 builddir
="$base/src.$pkg.$config.$id"
144 if [ "$chroot" = 1 ] ; then
146 cd "$xroot" ||
exit 1
149 if [ ! -c "$1" -a ! -b "$1" ]; then
155 x_mknod dev
/null c
1 3
156 x_mknod dev
/zero c
1 5
157 x_mknod dev
/random c
1 8
158 x_mknod dev
/urandom c
1 9
159 x_mknod dev
/loop
/0 b
7 0
160 x_mknod dev
/loop
/1 b
7 1
161 x_mknod dev
/loop
/2 b
7 2
162 x_mknod dev
/loop
/3 b
7 3
163 #_mknod dev/tty c 5 0
165 if [ ! -L dev
/fd
]; then
166 ln -s /proc
/self
/fd dev
/fd
169 realconf
=$
(cd $base/config
; pwd -P)
170 realdown
=$
(cd $base/download
; pwd -P)
171 realbase
=$
(dirname $
(cd $base/scripts
; pwd -P))
173 if [ ! -e TOOLCHAIN
/loop
/scripts
]; then
174 mkdir
-p TOOLCHAIN
/{loop
,config
,download
}
175 mount
--bind $realbase TOOLCHAIN
/loop
176 mount
--bind $realconf TOOLCHAIN
/config
177 mount
--bind $realdown TOOLCHAIN
/download
180 if [ ! -f proc
/mounts
]; then
181 mount
-nt proc none proc
184 for x
in $sderootdirs; do
185 if [ ! -e TOOLCHAIN
/$x ]; then ln -s "loop/$x" "TOOLCHAIN/$x"; fi
188 if [ ! -e "TOOLCHAIN/build/$SDECFG_ID" ]; then
189 mkdir
-p "TOOLCHAIN/build"
190 ln -snf ..
/..
"TOOLCHAIN/build/$SDECFG_ID"
193 mkdir
-p "TOOLCHAIN/src.$pkg.$config.$id"
194 ln -s "$PWD/TOOLCHAIN/src.$pkg.$config.$id" "$builddir"
196 cat > $builddir/chroot.sh
<<- EOT
197 export ROCK_THIS_IS_CHROOT=1; cd /TOOLCHAIN
198 ./scripts/Build-Pkg $options -chr-sub -root "/" "$1"
201 cat > $builddir/debug.sh
<<- EOT
203 if [ ! -f "$xroot/proc/mounts" ]; then
204 mount -nt proc none "$xroot/proc"
206 if [ ! -e "$xroot/TOOLCHAIN/loop/scripts" ]; then
207 mkdir -p "$xroot/"TOOLCHAIN/{loop,config,download}
208 mount --bind $realbase "$xroot/TOOLCHAIN/loop"
209 mount --bind $realconf "$xroot/TOOLCHAIN/config"
210 mount --bind $realdown "$xroot/TOOLCHAIN/download"
213 export ROCK_THIS_IS_CHROOT=1
214 /usr/sbin/chroot "$xroot" /bin/bash TOOLCHAIN/src.$pkg.$config.$id/debug_x.sh
216 if ! fuser -s "$xroot/TOOLCHAIN/" ; then
217 echo "Loop mounts appear unused - un-mounting ..."
218 umount "$xroot/TOOLCHAIN/"{loop,config,download}
222 chmod +x
$builddir/debug.sh
225 if [ "${TZ#/}" != "$TZ" ] ; then
226 cp $TZ TOOLCHAIN
/localtime
228 cp /usr
/share
/zoneinfo
/$TZ TOOLCHAIN
/localtime
231 if [ -f /etc
/localtime
] ; then
232 cp /etc
/localtime TOOLCHAIN
/localtime
234 ln -sf /usr
/share
/zoneinfo
/Factory TOOLCHAIN
/localtime
238 if [ "$SDECFG_PKG_DISTCC_HOST_RESOLV" = "1" ]; then
239 cat /etc
/resolv.conf
> etc
/resolv.conf
242 TZ
="/TOOLCHAIN/localtime" chroot . bin
/bash TOOLCHAIN
/src.
$pkg.
$config.
$id/chroot.sh
245 if [ ! -d "$builddir/." ]; then
252 .
/bin
/sde-build-tools
-$stagelevel -c $config ||
exit 1
254 if [ "$SDECFG_FLIST" = "flwrapper" -a -z "$FLWRAPPER" ] ; then
255 export FLWRAPPER_WLOG
="$builddir/fl_wrapper.wlog"
256 export FLWRAPPER_RLOG
="$builddir/fl_wrapper.rlog"
257 export FLWRAPPER_BASEPID
=$$
258 export FLWRAPPER_FILTERDIR
="/tmp/:$builddir"
259 [ "$LD_PRELOAD" ] && LD_PRELOAD
="${LD_PRELOAD}:"
260 export FLWRAPPER
="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/lib/fl_wrapper.so"
261 export LD_PRELOAD
="${LD_PRELOAD}$FLWRAPPER"
263 export INSTALL_WRAPPER_LOGFILE
="$builddir/install_wrapper.log"
264 export CMD_WRAPPER_LOGFILE
="$builddir/cmd_wrapper.log"
265 export UNAME_WRAPPER_LOGFILE
="$builddir/uname_wrapper.log"
267 export HOME
=$root/root
269 if [ $norebuild = 1 -a -f $root/var
/adm
/logs
/$stagelevel-$xpkg.log
] ; then
270 echo_pkg_deny
$stagelevel $pkg "already built"
274 # TODO: should i be pedantic and force rebuild of low stages even if $norebuild? /mnemoc
275 if [ "$SDECFG_RETRY_BROKEN" = 0 -a $norebuild = 1 -a \
276 -f $root/var
/adm
/logs
/$stagelevel-$xpkg.err
] ; then
277 echo_pkg_deny
$stagelevel $pkg "already failed"
281 archdir
="$builddir/archdir"
285 if [ -z "$confdir" ] ; then
286 echo_pkg_deny
$stagelevel $pkg "does not exist" ; exit 1
289 mkdir
-p $root/var
/adm
/logs
290 mkdir
-p $root/var
/adm
/flists
291 mkdir
-p $root/var
/adm
/olists
292 mkdir
-p $root/var
/adm
/cksums
293 mkdir
-p $root/var
/adm
/md5sums
294 mkdir
-p $root/var
/adm
/packages
295 mkdir
-p $root/var
/adm
/dependencies
296 mkdir
-p $root/var
/adm
/dep-debug
297 mkdir
-p $root/var
/adm
/parse-config
298 mkdir
-p $root/var
/adm
/cache
299 mkdir
-p $root/var
/adm
/descs
301 [ "$root" ] && chmod 0755 $root
303 rm -f $root/var
/adm
/logs
/$stagelevel-$xpkg.out
304 rm -f $root/var
/adm
/logs
/$stagelevel-$xpkg.log
305 rm -f $root/var
/adm
/logs
/$stagelevel-$xpkg.err
307 if [ $this_is_the_2nd_run = 0 ] ; then
308 if [ "$toolsdir" = "tools.chroot" ]; then
312 options
="-this_is_the_2nd_run $options $pkg=$xpkg"
313 if [ "$SDECFG_CREATE_CACHE" = 1 -a "$toolsdir" != "$tools.cross" ] ; then
315 mkdir
-p $root/var
/adm
/cache
316 rm -f $root/var
/adm
/cache
/$xpkg
317 rm -f $root/var
/adm
/cache
/$xpkg.tm
319 /usr
/bin
/time -o "$root/var/adm/cache/$xpkg.tm" \
320 -f 'buildtime=$(qcalc %U + %S)' $0 $options
322 [ ! -e "$root/var/adm/cache/$xpkg.tm" ] && exit $returncode
324 qcalc
() { gawk
"BEGIN { printf(\"%d\n\", ($*)*100); }"; }
325 eval "`grep -v '^Command ' < $root/var/adm/cache/$xpkg.tm`"
326 rm -f $root/var
/adm
/cache
/$xpkg.tm
328 # store reference time
329 if [ $pkg = binutils
]; then
330 echo $buildtime > $sysroot/TOOLCHAIN
/reftime
332 # compute relative build time to binutils (LFS-style)
333 if [ -e $root/TOOLCHAIN
/reftime
]; then
334 reftime
=`cat $root/TOOLCHAIN/reftime`
336 reftime
=$buildtime # so until we have a ref all will be 100%
338 # quantisized to 5% steps
339 buildtime
=`gawk "BEGIN { printf(\"%d\n\", int($buildtime * 20 / $reftime) * 5 ); }"`
342 date '+%n[TIMESTAMP] %s %c'
344 [ -f $root/var
/adm
/logs
/$stagelevel-$xpkg.err
] &&
347 echo "[BUILDTIME] $buildtime ($stagelevel)$x"
349 x
="$root/var/adm/packages/$xpkg"
351 echo "[SIZE] `grep "^Package Size
: " \
352 $x | cut -f3- -d' '`"
356 x
="$root/var/adm/dependencies/$xpkg"
357 [ "$pkg" != "sde-debug" -a -f $x ] &&
358 sed 's,^[^:]*:,[DEP],' $x
359 } > $root/var
/adm
/cache
/$xpkg
369 # ---- Setting Build Variables
372 # allowed toplevel directories that will be flisted
373 flistroot
="bin boot etc lib sbin usr var opt"
375 # add lib32 and lib64 in the case the target has multilib support
376 if [ "$SDECFG_MULTILIB" = 1 ]; then
377 var_append flistroot
' ' "lib32 lib64"
380 # remove the obvious noise: ldconfig and our /var/adm as well as due to
381 # rare i18n locale directories ...
382 flistrfilter
="ldconfig\..*: .*|.*: /var/adm/.*|.*: .*/share/locale/.*"
384 flistdel
="etc/ld.so.cache|etc/blkid.tab|var/tmp/.*|usr/tmp/.*|var/adm/logs/.*|.*\\.old"
385 flistvalid
="$base|/tmp|/var/backups|/proc|/dev"
386 foodirlist
="bindir sbindir libdir datadir includedir sysconfdir localstatedir docdir"
391 # ---- Read various config files
396 echo_pkg_start
$stagelevel $repository $xpkg $ver $extraver
398 if [ "$SDECFG_PARANOIA_CHECK" = 1 -a -z "$pkgdir" ] ; then
399 x
="`./scripts/Check-PkgFormat $pkg`"
400 [ "$x" ] && abort
"$x\nDisable the 'Paranoia Check' config `
401 `option to ignore such errors."
404 targetdir
="$base/target/$target"
408 if atstage toolchain
; then
409 var_append patchfiles
' ' "`ls $confdir/*.patch.toolchain{,.$arch} \
410 2>/dev/null | tr '\n' ' '`"
413 if atstage cross
; then
414 var_append patchfiles
' ' "`ls $confdir/*.patch.cross{,.$arch} \
415 2>/dev/null | tr '\n' ' '`"
420 if atstage native
; then
421 for pc_file
in $xroot/var
/adm
/parse-config
/* ; do
422 if [ -s "$pc_file" -a "${pc_file##*/}" != "$xpkg" ]
423 then .
"$pc_file" ; fi
427 .
$base/build
/$SDECFG_ID/TOOLCHAIN
/$toolsdir/lib
/parse-config
429 # Erase positional parameters to prevent unintended parameter
430 # passing. We do not want to pass the current positional parameters
431 # to the loaded script.
435 # include package pre config - if any
436 if [ -f $base/build
/$SDECFG_ID/TOOLCHAIN
/$toolsdir/lib
/pkg_
${pkg}_pre.conf
] ; then
437 # echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_pre.conf"
438 .
$base/build
/$SDECFG_ID/TOOLCHAIN
/$toolsdir/lib
/pkg_
${pkg}_pre.conf
441 for x
in $
( get_expanded
$base/target
/%/pkg_
$pkg.conf
$targetchain ) \
442 $confdir/$pkg.conf
; do
444 # if [[ $x = */$pkg.conf ]]; then
445 # echo_status "Reading package configuration from package directory."
447 # echo_status "Reading package configuration from target directory."
454 # include package post config - if any
455 if [ -f $base/build
/$SDECFG_ID/TOOLCHAIN
/$toolsdir/lib
/pkg_
${pkg}_post.conf
] ; then
456 # echo_status "Reading build/.../$toolsdir/lib/pkg_${pkg}_post.conf"
457 .
$base/build
/$SDECFG_ID/TOOLCHAIN
/$toolsdir/lib
/pkg_
${pkg}_post.conf
460 if [ -f $base/architecture
/$arch/pkg-header
] ; then
461 # echo_status "Reading overwrites from architecture/$arch/pkg-header."
462 .
$base/architecture
/$arch/pkg-header
465 for x
in $
( get_expanded
$base/target
/%/pkg-header
`get_reverted $targetchain` ); do
467 # echo_status "Reading overwrites from ${x#$base/}."
473 # ---- Variable updates based on the configuration files read
476 if [ -z "$prefix" -o "${prefix#usr}" != "$prefix" ] ; then
477 flistdel
="$flistdel|usr/share/info/(dir|standards.info)"
478 if [ "$SDECFG_DISABLE_NLS" = 1 ] ; then
479 flistdel
="$flistdel|usr/share/locale/..[/_].*"
480 flistdel
="$flistdel|usr/share/man/..[/_].*"
483 flistdel
="$flistdel|$prefix/info/(dir|standards.info)"
484 if [ "$SDECFG_DISABLE_NLS" = 1 ] ; then
485 flistdel
="$flistdel|$prefix/share/locale/..[/_].*"
486 flistdel
="$flistdel|$prefix/man/..[/_].*"
494 echo_status
"Preparing build in src.$pkg.$config.$id"
496 if [ $clear_src = 1 ] ; then
497 mkdir
-p $builddir; chmod 0755 $builddir
498 if [ "$SDECFG_SRC_TMPFS" = 1 ]; then
499 mount
-t tmpfs
-n ${SDECFG_SRC_TMPFS_OPT:+-o $SDECFG_SRC_TMPFS_OPT} none
$builddir
502 mkdir
-p $builddir; chmod 0755 $builddir
505 if [ $update = 1 -a ! -f $xroot/var
/adm
/md5sums
/$xpkg ] ; then
506 echo_status
"Ignoring update mode since package isn't installed already."
510 if [ $update = 1 ] ; then
511 echo_status
"Creating backup of old package data."
514 md5sum --check var
/adm
/md5sums
/$xpkg 2>&1 < /dev
/null |
515 grep ': FAILED$' | cut
-f1 -d:
516 ) > $builddir/backup_files.txt
517 if [ -s $builddir/backup_files.txt
] ; then
518 mkdir
-p "$xroot/var/adm/backup"
519 chmod 700 "$xroot/var/adm/backup"
520 backup_tar
="$xroot/var/adm/backup/$(
521 date '+%Y%m%d%H%M%S')_$xpkg.tar.bz2"
522 ( cd $xroot/; tar --no-recursion -cf - -T $builddir/`
523 `backup_files.txt || true
; ) |
bzip2 > $backup_tar
529 if [ "$SDECFG_FLIST" = "flwrapper" ] ; then
530 rm -f $builddir/fl_wrapper.wlog
$builddir/fl_wrapper.rlog
531 touch $builddir/fl_wrapper.wlog
$builddir/fl_wrapper.rlog
532 elif [ "$SDECFG_FLIST" = "find" ] ; then
533 touch $builddir/temp.time_stamp
539 # define new abort function for errors while building
542 [ "$*" ] && echo "$*"; echo "--- BUILD ERROR ---"
543 rm -vf $root/var
/adm
/logs
/$stagelevel-$xpkg.log
548 trap 'echo "Got SIGINT (Crtl-C). Aborting build." ; exit 1' INT
551 # Makes debugging build problems easier
553 hook_dump
> $builddir/debug.hooks
558 PS1='\\[\\e[00m\\e[01;31m\\]debug-`
559 `$xpkg\\[\\e[00m\\]:[\\W]\\\$ '
560 alias cp="cp -i" ; alias mv="mv -i"
561 alias rm="rm -i" ; alias ls="ls --color=auto -a"
562 alias ..="cd .." ; alias ...="cd ../.."
564 # we use .vanilla to not rediff backup .orig from patch
565 [ -f \$1.vanilla ] || cp \$1 \$1.vanilla
566 # maybe we do not have the editor yet?
567 which \$EDITOR > /dev/null || EDITOR=nvi
571 find -name '*.vanilla' -printf '%P\n' | while read x ; do
572 diff -u \$x \${x/.vanilla/}
576 } > $builddir/debug.buildenv
578 cat > $builddir/debug_x.sh
<<- EOT
580 cd $builddir; exec bash --rcfile debug.buildenv 200>> build.pid
583 if [ "$ROCK_THIS_IS_CHROOT" != 1 ]; then
584 mv $builddir/debug_x.sh
$builddir/debug.sh
585 chmod +x
$builddir/debug.sh
590 # The builtin-variable '$$' is not this pid because this proc
591 # is just a sub-proc of $$. That's why the $builddir/strace.tmp
592 # hack is required to get the right pid to trace.
594 # We also conntect filedescriptor 3 with the pid file. So the command
595 # 'fuser' can be used to create a list of all processes which are part
596 # of this build process.
598 sh
-c 'echo $PPID' > $builddir/build.pid
599 exec 200>> $builddir/build.pid
601 echo "Command Wrapper Debug: running '${CC} --version' .."
602 type ${CC}; CMD_WRAPPER_DEBUG
=1 ${CC} --version
603 echo "[ writing debug log to $builddir/cmd_wrapper.log ]"
605 if [ "$debug" = 1 ] ; then
606 echo "Everything is set up." \
607 "We are in debug mode - so exit now."
611 if [ "$SDECFG_FLIST" = "strace" ] ; then
612 strace
-o $builddir/strace.out
-F -f -q -e open
,creat
,mkdir
,`
613 `mknod
,link
,symlink
,rename
,utime
,chdir
,execve
,fork
,`
614 `vfork
,_exit
,exit_group
-p `cat $builddir/build.pid` &
615 strace_pid
=$
! ; sleep 1 ; cd $base
621 mkdir
-p "$builddir/archdir"
624 echo "Running main build function '$mainfunction' ..."
625 if [ $xtrace -eq 1 -o $SDECFG_XTRACE -eq 1 ] ; then
626 PS4
=$
'=[$FUNCNAME:$LINENO (last \\\$?=$?)> ' ; set -o xtrace
627 cd $builddir ; eval "$mainfunction"
630 cd $builddir ; eval "$mainfunction"
632 touch $root/var
/adm
/logs
/$stagelevel-$xpkg.log
634 [ -f $root/var
/adm
/logs
/$stagelevel-$xpkg.log
] ||
635 abort
"Due to previous errors, no $stagelevel-$xpkg.log file!
636 (Try enabling xtrace in the config to track an error inside the build system.)"
638 hook_eval postinstall
640 echo "Creating file list and doing final adaptions ... "
643 [ -s "var/adm/parse-config/$xpkg" ] &&
644 echo "var/adm/parse-config/$xpkg" >> $builddir/flist.txt
645 for x
in var
/adm
/flists
/$xpkg var
/adm
/md5sums
/$xpkg \
646 var
/adm
/cksums
/$xpkg var
/adm
/packages
/$xpkg \
647 var
/adm
/descs
/$xpkg var
/adm
/dependencies
/$xpkg ; do
648 touch $x ; echo "$x" >> $builddir/flist.txt
651 if [ "$SDECFG_FLIST" = "strace" ] ; then
652 sleep 1 ; kill -INT $strace_pid ; sleep 1
653 fl_stparse
-w $builddir/fl_wrapper.wlog \
654 -r $builddir/fl_wrapper.rlog
< $builddir/strace.out
658 # sanitize accidental //s
659 sed -i -e 's,//*,/,g' $builddir/fl_wrapper.wlog
660 sed -i -e 's,//*,/,g' $builddir/fl_wrapper.rlog
662 if [ "$SDECFG_FLIST" = "flwrapper" -o \
663 "$SDECFG_FLIST" = "strace" ] ; then
664 if [ "$toolsdir" = "tools.cross" ]; then
665 xbase
="$( cd $xroot/ 2> /dev/null ; pwd -P )"
666 flistvalid
="$xbase|$flistvalid"
668 if egrep -qv " ($flistvalid)/" $builddir/fl_wrapper.wlog
671 if [ -e "$file" ] ; then
672 echo "Created file outside basedir: $file"
674 else # non fatal for now (configure junk)
675 echo "Created (vanished) file outside basedir (ignored): $file"
677 done < <( egrep -v " ($flistvalid)/" \
678 $builddir/fl_wrapper.wlog |
681 echo "base #1: $base"
682 echo "base #2: $xbase"
683 [ "$abort_soon" = 1 ] && abort
687 fl_wrparse
-D -s -r "$xroot/" < $builddir/fl_wrapper.wlog
> \
688 $builddir/flist.txt.tmp
690 # check for file creation beside the allowed top-level
691 # directories - allow root since qt, wxwidgets, ... create some
692 # profile there ... - on stage 0 we have an ugly symlink hack
693 # so we get doc, $arch_machine, ... in the top level dir :-(
694 if [ $stagelevel -gt 0 ]; then
695 fr
="$flistroot root TOOLCHAIN"
698 echo "Created file outside allowed top-level dir: $file"
700 done < <( egrep -v "^(${fr// /|})(/|$)" \
701 $builddir/flist.txt.tmp
)
702 [ "$abort_soon" = 1 ] && abort
705 egrep "^(${flistroot// /|})(/|$)" $builddir/flist.txt.tmp
>> \
708 elif [ "$SDECFG_FLIST" = "find" ] ; then
710 \
( -not -type d
-or -type d
-empty \
) \
711 -and \
( -newer $builddir/temp.time_stamp
-or \
712 -cnewer $builddir/temp.time_stamp \
) -printf "%p\n" >> \
717 egrep -v "^($flistdel)\$" $builddir/flist.txt
> $builddir/flist.txt.new
718 mv $builddir/flist.txt
{.new
,}
722 # save the old flist for later orphaned file check
723 [ -e var
/adm
/flists
/$xpkg ] &&
724 cp -f var
/adm
/flists
/$xpkg $builddir/flist.txt.old
726 fl_wrparse
-D -p "$xpkg" -r "$xroot/" < $builddir/flist.txt |
727 sort -u > $builddir/flist.txt.new
729 # analyze which files have not been reinstalled and thus are (normally)
730 # no longer needed (orphaned)
731 if [ -e $builddir/flist.txt.old
]; then
732 echo "Searching for orphaned files ..."
733 diff --normal $builddir/flist.txt.
{old
,new
} |
734 grep '^<' | cut
-d ' ' -f 2- > $builddir/olist.txt.new
735 [ -e var
/adm
/olists
/$xpkg ] &&
736 cp -f var
/adm
/olists
/$xpkg $builddir/olist.txt.old ||
737 touch $builddir/olist.txt.old
738 cat $builddir/olist.txt.
{old
,new
} |
sort -u > \
742 # until all olist regressions are fixed merge the two lists ... :-(
743 touch $builddir/flist.txt.old
744 cat $builddir/flist.txt.
{old
,new
} |
egrep -v "^$xpkg: ($flistdel)\$" |
745 sort -u > var
/adm
/flists
/$xpkg
746 echo Found
`wc -l < var/adm/flists/$xpkg` "files for this package."
747 echo Found
`wc -l < var/adm/olists/$xpkg` "orphaned files for this package."
749 echo "Clear (old) md5sums and cksums ..."
750 echo -n > var
/adm
/md5sums
/$xpkg
751 echo -n > var
/adm
/cksums
/$xpkg
753 if [ "$SDECFG_FLIST" = "flwrapper" -o \
754 "$SDECFG_FLIST" = "strace" ] && atstage native
; then
755 echo "Calculating package dependencies ..."
757 ! egrep -v "^($flistrfilter)\$" $builddir/fl_wrapper.
[rw
]log |
758 sort -u | fl_wrparse
-D -s -r "$xroot/" -p '' |
sort -u |
759 grep -v ' var/adm/' |
awk '
760 # read the var/adm/... file content in
762 if ( $1 != "'$xpkg':" )
763 f[$2] = $1 " " f[$2];
765 # iterate over the read file list streamed to stdin
769 print f[file] " " file;
772 ' var
/adm
/flists
/* - >> $builddir/dependencies.debug
774 awk 'BEGIN { FS=": "; } { print "'$xpkg': " $1; }' \
775 < $builddir/dependencies.debug \
776 >> $builddir/dependencies.txt
778 sort -u $builddir/dependencies.debug
> var
/adm
/dep-debug
/$xpkg
780 # merge the dependencies defined by the package
781 for x
in `echo "$desc_E" | egrep '^add ' | sed 's/^add //' ` ; do
782 echo "Adding dependency: $x ..."
783 echo "$xpkg: $x" >> $builddir/dependencies.txt
786 # remove dependencies as requested by the package
787 # TODO: goups are not used yet (and it is not easy here)
789 for x
in `echo "$desc_E" | egrep '^del ' | sed 's/^del //' ` ; do
790 del_pattern
="$del_pattern -e \".*: $x\$\""
792 if [ -n "$del_pattern" ] ; then
793 echo "Deleting dependencies, pattern: $del_pattern ..."
794 eval egrep -v $del_pattern \
795 $builddir/dependencies.txt
> \
796 $builddir/dependencies.txt.new
797 mv $builddir/dependencies.txt
{.new
,}
800 sort -u $builddir/dependencies.txt
> var
/adm
/dependencies
/$xpkg
803 echo -n "Creating md5sum and cksum files ..."
804 getfiles
< var
/adm
/flists
/$xpkg > $builddir/files.lst
805 if [ -s $builddir/files.lst
] ; then
806 cat $builddir/files.lst | \
807 grep -v '^var/adm/' |
sed -e 's,^.*,"\0",' | \
808 xargs -r md5sum > var
/adm
/md5sums
/$xpkg
809 cat $builddir/files.lst | \
810 grep -v '^var/adm/' |
sed -e 's,^.*,"\0",' | \
811 xargs -r cksum > var
/adm
/cksums
/$xpkg
815 echo "Creating package description ..."
817 rocksrcck
=$
( pkgchksum
$base/package
/*/$pkg )
818 buildlist
="$( grep "^Build \
[.\
] at " var/adm/packages/$xpkg || true
819 echo "Build
[$stagelevel] at $buildstart to
`date "+%T %Z"`")"
821 cat > var
/adm
/packages
/$xpkg << EOT
822 Package Name and Version: $xpkg $ver $extraver
823 Package Size: `getdu $root/ < var/adm/flists/$xpkg`, `
824 wc -l < var/adm/flists/$xpkg | tr -d ' '` files
825 OpenSDE Package Source Checksum: $rocksrcck
826 OpenSDE Version and Architecture: $sdever $arch
831 # Location libdir: /opt/openldap/lib
832 for x
in $foodirlist; do
833 if [ "`eval echo \\$$x`" != "`pkggetdir $x`" ]; then
834 echo "Location $x: `eval echo \\$$x`" \
835 >> var
/adm
/packages
/$xpkg
839 cat >> var
/adm
/packages
/$xpkg << EOT
840 Status: ${desc_S:-ALPHA}, License: ${desc_L:-Unknown}
844 $( echo "${desc_T:-No description available.}" | sed 's,^, ,' )
847 $( echo "${desc_U:-http://www.t2-project.org/packages/$pkg.html}" | sed 's,^, ,' )
850 $( echo "${desc_A:-Unknown}" | sed 's,^, ,' )
852 Package Maintainer(s):
853 $( echo "${desc_M:-Unknown}" | sed 's,^, ,' )
856 $( echo "${desc_D:-None}" | awk '{ print " " $3 $2; }' )
859 echo "[CONFIG] ${SDECFG_ID#*-}"
860 descfile
=$base/package
/*/$pkg/$pkg.desc
862 if [ "${x#\[}" != "$x" ] ; then
863 x
="`echo ${x// /|} | tr -d '[]'`"
864 y
="${x%%|*}" ; x
="(${x%|(*)})"
865 egrep "^\[$x\]" $descfile |
expand |
sed "s,^[^ ]*,[$y],"
867 done < $base/etc
/desc_format
868 } > var
/adm
/descs
/$xpkg
870 echo "Making post-install adaptions."
872 if [ "$SDECFG_PARANOIA_CHECK" = 1 ] ; then
876 # check for files which are 'shared' with other packages
877 if [ "$check_shared" != "0" ]; then
878 while read dummy
file; do
879 if [ $found_dups = 0 ] ; then
880 echo "Found shared files with other packages:"
881 found_errors
=1; found_dups
=1
883 echo "$file:" $
( cd $root/var
/adm
/flists
884 grep -l " $file\$" * )
885 done < <( echo $root/var
/adm
/flists
/* |
xargs -n 128 cat |
sed "s,^$xpkg:,.," | \
886 sort -k2 |
uniq -d -f1 |
grep '^\. ' )
891 # check for files in /usr/local
892 if [ "$check_usrlocal" != "0" ]; then
894 if [ $found_local = 0 ] ; then
895 echo "Found files in /usr/local:"
896 found_errors
=1; found_local
=1
899 done < <( sed "s,^$xpkg: ,/," $root/var
/adm
/flists
/$xpkg | \
900 egrep "^/usr/local" )
905 # check for registered 'bad files'
906 if [ "$check_badfiles" != "0" -a -n "$badfiles" ]; then
907 echo "$badfiles" > $builddir/badfiles.txt
908 while read x
file; do
909 if [ $found_bad = 0 ]; then
910 echo "Found registered 'bad files' in package:"
911 found_errors
=1; found_bad
=1
913 desc
="No description found!"
914 for ((x
=0; x
<badfiles_nr
; x
++)); do
915 if echo " $file" |
grep -q "${badfiles_desc[x]%%$'\n'*}"
916 then desc
="${badfiles_desc[x]#*$'\n'}"; fi
919 done < <( grep -f $builddir/badfiles.txt
$root/var
/adm
/flists
/$xpkg )
922 [ $found_errors != 0 ] && abort
"Due to previous errors."
929 echo_status
"Writing build output to" \
930 "\$root/var/adm/logs/$stagelevel-$xpkg.out"
932 if [ "$SDECFG_VERBOSE" = 1 -o "$verbose" = 1 ] ; then
933 tee $root/var
/adm
/logs
/$stagelevel-$xpkg.out
935 cat > $root/var
/adm
/logs
/$stagelevel-$xpkg.out
941 if [ $update = 1 ] ; then
942 echo_status
"Restoring backup of old package data."
945 [ -f $xroot/$fn ] && mv $xroot/$fn $xroot/$fn.new
946 done < $builddir/backup_files.txt
948 tar --use-compress-program=bzip2 -C $xroot/ -xpf $backup_tar
951 cmp -s $fn $fn.new
&& rm -f $fn.new
952 done < $builddir/backup_files.txt
957 umount
-r -d -f $builddir/* 2> /dev
/null
958 umount
-r -d -f -l $builddir/* 2> /dev
/null
960 if [ "$SDECFG_SRC_TMPFS_LOG" = 1 -a -n "$( type -p df )" ]; then
961 mkdir
-p $root/var
/adm
/sde-debug
962 if [ ! -f $root/var
/adm
/sde-debug
/tmpfslog.txt
] ; then
963 echo -e "# Config\tPackage\tInodes\tKB" | \
964 expand -t20 > $root/var
/adm
/sde-debug
/tmpfslog.txt
966 echo -e "$config\t$stagelevel-$xpkg\t$(
967 df 2> /dev/null -Pi $builddir | tail -n 1 | tr -s ' ' | cut -f3 -d' '
969 df 2> /dev/null -Pk $builddir | tail -n 1 | tr -s ' ' | cut -f3 -d' ')" | \
970 expand -t20 >> $root/var
/adm
/sde-debug
/tmpfslog.txt
973 umount
-r -d -f $builddir 2> /dev
/null
974 umount
-r -d -f -l $builddir 2> /dev
/null
976 if [ -f $root/var
/adm
/logs
/$stagelevel-$xpkg.log
] ; then
977 if [ $clear_src = 1 ] ; then
978 rm -rf $builddir/* $builddir
980 cp $root/var
/adm
/logs
/$stagelevel-$xpkg.out
$builddir/BUILD-LOG
982 echo_status
"\$root/var/adm/logs/$stagelevel-$xpkg.out" \
983 "-> $stagelevel-$xpkg.log"
984 mv $root/var
/adm
/logs
/$stagelevel-$xpkg.out \
985 $root/var
/adm
/logs
/$stagelevel-$xpkg.log
986 echo_pkg_finish
$stagelevel $repository $xpkg
989 if [ $clear_src = 1 -a "$SDECFG_ALWAYS_CLEAN" = 1 ] ; then
990 rm -rf $builddir/* $builddir
992 cp $root/var
/adm
/logs
/$stagelevel-$xpkg.out
$builddir/ERROR-LOG
994 if [ "$SDECFG_VERBOSE" != 1 -a "$verbose" != 1 ] ; then
995 echo_errorquote
"$( grep -v 'make[^ ]*:' \
996 $root/var/adm/logs/$stagelevel-$xpkg.out |
997 grep -B8 -- '--- BUILD ERROR ---' |
998 sed '/--- BUILD ERROR ---/d' )"
1000 echo_status
"\$root/var/adm/logs/$stagelevel-$xpkg.out" \
1001 "-> $stagelevel-$xpkg.err"
1002 mv $root/var
/adm
/logs
/$stagelevel-$xpkg.out \
1003 $root/var
/adm
/logs
/$stagelevel-$xpkg.err
1004 echo_pkg_abort
$stagelevel $repository $xpkg