Skip to content

Commit

Permalink
Improvements to DAR for RHEL5 and LD_ASSUME_KERNEL handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Oct 12, 2008
1 parent 00044b4 commit c39262d
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 188 deletions.
70 changes: 18 additions & 52 deletions dar-build
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ for arg in $PKGS; do
ln -sf $CHROOTDIR/$dist/root/.distcc/state /root/.distcc/ ln -sf $CHROOTDIR/$dist/root/.distcc/state /root/.distcc/
export DISTCC_LOG="$TEMPDIR/distcc-$LOGFILE" export DISTCC_LOG="$TEMPDIR/distcc-$LOGFILE"
rm -f "$DISTCC_LOG" rm -f "$DISTCC_LOG"
export MAKEFLAGS="-j$CPUNR CC=\"$DISTCC_CC\" CXX=\"$DISTCC_CXX\" GXX=\"$DISTCC_CXX\"" export MAKEFLAGS="-j$CPUNR CC='$DISTCC_CC' CXX='$DISTCC_CXX' GXX='$DISTCC_CXX'"
export DISTCC_HOSTS CC="$DISTCC_CC" CXX="$DISTCC_CXX" GXX="$DISTCC_CXX" export DISTCC_HOSTS CC="$DISTCC_CC" CXX="$DISTCC_CXX" GXX="$DISTCC_CXX"
export PATH="/usr/lib/distcc/bin:$PATH" export PATH="/usr/lib/distcc/bin:$PATH"
else else
Expand All @@ -275,13 +275,6 @@ for arg in $PKGS; do
export CCACHE_RECACHE="1" export CCACHE_RECACHE="1"
fi fi


### Check for Setarch
if [ -x "/usr/bin/setarch" -a "$DISTARCH" != "$(uname -m)" ]; then
SETARCH="/usr/bin/setarch $DISTARCH"
else
unset SETARCH
fi

### Disable ExtUtils::AutoInstall in perl packages ### Disable ExtUtils::AutoInstall in perl packages
export PERL_EXTUTILS_AUTOINSTALL="--skipdeps --skip" export PERL_EXTUTILS_AUTOINSTALL="--skipdeps --skip"


Expand All @@ -290,9 +283,7 @@ for arg in $PKGS; do


### Prepare rpm options ### Prepare rpm options
if [ "$FORCE_VERBOSE" ]; then if [ "$FORCE_VERBOSE" ]; then
RPMBUILDOPTS="$RPMBUILDOPTS -vv --target $arch" RPMBUILDOPTS="$RPMBUILDOPTS -vv"
else
RPMBUILDOPTS="$RPMBUILDOPTS --target $arch"
fi fi


if [ "$FORCE_VERBOSE" == "yes" ]; then if [ "$FORCE_VERBOSE" == "yes" ]; then
Expand All @@ -307,14 +298,15 @@ for arg in $PKGS; do
export LD_PRELOAD="/lib/libsoapbox.so" export LD_PRELOAD="/lib/libsoapbox.so"
fi fi


BUILDCMD="/usr/bin/rpmbuild -bb --clean $RPMBUILDOPTS \ BUILDCMD="/usr/bin/rpmbuild -bb --clean $RPMBUILDOPTS --target $arch \
--define \"_smp_mflags $MAKEFLAGS\" \ --define \"_smp_mflags $MAKEFLAGS\" \
--define \"_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm\" \ --define \"_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm\" \
--define \"_initrddir %{_sysconfdir}/rc.d/init.d\" \ --define \"_initrddir %{_sysconfdir}/rc.d/init.d\" \
--define \"_rpmdir $PACKAGEDIR/$app\" \ --define \"_rpmdir $PACKAGEDIR/$app\" \
--define \"_sourcedir $SPECDIR\" \ --define \"_sourcedir $SPECDIR\" \
--define \"_builddir $BUILDDIR\" \ --define \"_builddir $ROOT/build\" \
--define \"_tmppath $TEMPDIR\" \ --define \"_tmppath $TEMPDIR\" \
--define \"_buildroot $TEMPDIR/$app-$VERSION-$RELEASE-root\" \
--define \"debug_package %nil\" \ --define \"debug_package %nil\" \
--define \"dtag $DISTNAME\" \ --define \"dtag $DISTNAME\" \
--define \"disttag $DISTNAME\" \ --define \"disttag $DISTNAME\" \
Expand All @@ -334,37 +326,10 @@ for arg in $PKGS; do
echo -e "\n----- Build log -----" echo -e "\n----- Build log -----"


### Check for building as user ### Check for building as user
if [ $AS_ROOT -eq 1 ]; then if [ $AS_ROOT -ne 1 ]; then
$SETARCH chroot "$CHROOTDIR/$dist" /usr/bin/rpmbuild -bb --clean $RPMBUILDOPTS \ echo "$BUILDCMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$dist" /bin/su -lm $BUILD_USER -c "/bin/bash --login -s"
--define "_smp_mflags $MAKEFLAGS" \
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
--define "_initrddir %{_sysconfdir}/rc.d/init.d" \
--define "_rpmdir $PACKAGEDIR/$app" \
--define "_sourcedir $SPECDIR" \
--define "_builddir $ROOT/build" \
--define "_buildroot $TEMPDIR/$app-$VERSION-$RELEASE-root" \
--define "debug_package %nil" \
--define "dtag $DISTNAME" \
--define "disttag $DISTNAME" \
--define "$DISTNAME 1" \
--define "$DISTNICK 1" \
"$NEWSPECFILE"
else else
$SETARCH chroot "$CHROOTDIR/$dist" /bin/su -lm $BUILD_USER -c "/usr/bin/rpmbuild -bb --clean $RPMBUILDOPTS \ echo "$BUILDCMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$dist" /bin/bash --login -s
--define '_smp_mflags $MAKEFLAGS' \
--define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \
--define '_initrddir %{_sysconfdir}/rc.d/init.d' \
--define '_rpmdir $PACKAGEDIR/$app' \
--define '_sourcedir $SPECDIR' \
--define '_builddir $ROOT/build' \
--define '_tmppath $TEMPDIR' \
--define '_buildroot $TEMPDIR/$app-$VERSION-$RELEASE-root' \
--define 'debug_package %nil' \
--define 'dtag $DISTNAME' \
--define 'disttag $DISTNAME' \
--define '$DISTNAME 1' \
--define '$DISTNICK 1' \
$NEWSPECFILE"
fi fi


) >>"$PACKAGEDIR/$app/_buildlogs/$LOGFILE_KO" 2>&1 ) >>"$PACKAGEDIR/$app/_buildlogs/$LOGFILE_KO" 2>&1
Expand Down Expand Up @@ -460,15 +425,16 @@ for arg in $PKGS; do
if [ "$FORCE_VERBOSE" == "yes" ]; then if [ "$FORCE_VERBOSE" == "yes" ]; then
echo "Building source package $app using \"$SPECFILE\" for $dist" echo "Building source package $app using \"$SPECFILE\" for $dist"
fi fi
chroot "$CHROOTDIR/$dist" /usr/bin/rpmbuild -bs \ BUILDCMD="/usr/bin/rpmbuild -bs \
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ --define \"_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm\" \
--define "_srcrpmdir $PACKAGEDIR/$app" \ --define \"_srcrpmdir $PACKAGEDIR/$app\" \
--define "_sourcedir $SPECDIR" \ --define \"_sourcedir $SPECDIR\" \
--define "$dist 1" \ --define \"$dist 1\" \
--define "dist $DISTNAME" \ --define \"dist $DISTNAME\" \
--define "disttag $DISTNAME" \ --define \"disttag $DISTNAME\" \
--define "$DISTNAME 1" \ --define \"$DISTNAME 1\" \
"$NEWSPECFILE" &>/dev/null \"$NEWSPECFILE\""
echo "$BUILDCMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$dist" /bin/su -lm $BUILD_USER -c "/bin/bash --login -s" &>/dev/null
RC=$? RC=$?
if [ $RC -eq 0 ]; then if [ $RC -eq 0 ]; then
if [ "$FORCE_VERBOSE" == "yes" ]; then if [ "$FORCE_VERBOSE" == "yes" ]; then
Expand Down
65 changes: 28 additions & 37 deletions dar-exec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
source "/usr/share/dar/dar-functions" source "/usr/share/dar/dar-functions"


function help { function help {
cat <<EOF cat <<EOF
usage: dar-exec [-q] [-d dist,dist2] cmd usage: dar-exec [-q] [-d dist,dist2] cmd
Run a command in one or more DAR build environments Run a command in one or more DAR build environments
dar-exec options: dar-exec options:
Expand Down Expand Up @@ -32,48 +32,39 @@ shift $((OPTIND-1))
CMD=$@ CMD=$@


if [ ! -d "$ROOT" ]; then if [ ! -d "$ROOT" ]; then
echo "ERROR: probably in chroot jail" >&2 echo "ERROR: probably in chroot jail" >&2
exit 1 exit 1
fi fi


set_dists set_dists
set_as_root set_as_root
AS_ROOT=1 AS_ROOT=1


for distname in $DISTS; do for distname in $DISTS; do
if [ -z "$QUIET" ]; then if [ -z "$QUIET" ]; then
echo -e "$_BL_$_WH= Executing \"$_YE$CMD$_WH\" for $_YE$distname$_WH.$_DE" echo -e "$_BL_$_WH= Executing \"$_YE$CMD$_WH\" for $_YE$distname$_WH.$_DE"
fi fi


if [ -r "$CONFIGDIR/dists/$distname/config" ]; then if [ -r "$CONFIGDIR/dists/$distname/config" ]; then
source "$CONFIGDIR/dists/$distname/config" source "$CONFIGDIR/dists/$distname/config"
export arch="$DISTARCH" dist="${DISTNAME// *}" nick="$DISTNICK" path="$DISTPATH" repo="$REPO" tag="${DISTTAG// *}" export arch="$DISTARCH" dist="${DISTNAME// *}" nick="$DISTNICK" path="$DISTPATH" repo="$REPO" tag="${DISTTAG// *}"
fi fi


### Check for building as user ### Check for building as user
if [ $AS_ROOT -eq 1 ]; then if [ $AS_ROOT -eq 1 -a -z "$FORCE_VERBOSE" ]; then
# DO_SU="/bin/su -l -c" echo "$CMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$distname" /bin/bash --login -s
if [ "$FORCE_VERBOSE" ]; then elif [ $AS_ROOT -eq 1 -a "$FORCE_VERBOSE" ]; then
DO_SU="/bin/bash -x -s" echo "$CMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$distname" /bin/bash --login -x -s
else elif [ $AS_ROOT -ne 1 -a -z "$FORCE_VERBOSE" ]; then
DO_SU="/bin/bash -s" echo "$CMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$distname" /bin/su -lm $BUILD_USER -c "/bin/bash --login -s"
fi else
else echo "$CMD" | setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$distname" /bin/su -lm $BUILD_USER -c "/bin/bash --login -x -s"
if [ "$FORCE_VERBOSE" ]; then fi
DO_SU="/bin/su -lm $BUILD_USER -- /bin/bash -x -s" RC=$?
else
DO_SU="/bin/su -lm $BUILD_USER -- /bin/bash -s" if [ $RC -ne 0 ]; then
fi error "$_RE_${_WH}Failed execution (RC=$_YE$RC$_WH)$_DE"
fi fi

# echo chroot "$CHROOTDIR/$distname" $DO_SU $CMD
# chroot "$CHROOTDIR/$distname" $DO_SU $CMD
echo "$CMD" | chroot "$CHROOTDIR/$distname" $DO_SU
RC=$?

if [ $RC -ne 0 ]; then
error "$_RE_${_WH}Failed execution (RC=$_YE$RC$_WH)$_DE"
fi
done done


exit 0 exit 0
2 changes: 1 addition & 1 deletion dar-list-perl.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def download(url):
filename = os.path.join(tmppath, os.path.basename(url)) filename = os.path.join(tmppath, os.path.basename(url))
try: try:
st = os.stat(filename) st = os.stat(filename)
if st and st.st_mtime + 1800 > time.time(): if st and st.st_mtime + 3600 > time.time():
# print >>sys.stderr, "File %s is recent, skip download." % os.path.basename(url) # print >>sys.stderr, "File %s is recent, skip download." % os.path.basename(url)
return True return True
except: except:
Expand Down
2 changes: 1 addition & 1 deletion dar-perl.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def download(url):
filename = os.path.join(tmppath, os.path.basename(url)) filename = os.path.join(tmppath, os.path.basename(url))
try: try:
st = os.stat(filename) st = os.stat(filename)
if st and st.st_mtime + 1800.0 > time.time(): if st and st.st_mtime + 3600.0 > time.time():
# print >>sys.stderr, "File %s is recent, skip download." % os.path.basename(url) # print >>sys.stderr, "File %s is recent, skip download." % os.path.basename(url)
return True return True
except: except:
Expand Down
44 changes: 22 additions & 22 deletions dar-prepare
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
source "/usr/share/dar/dar-functions" source "/usr/share/dar/dar-functions"


if [ -z "$DEFAULT_DISTS" -o -z "$ROOT" ]; then if [ -z "$DEFAULT_DISTS" -o -z "$ROOT" ]; then
echo "ERROR: There's something wrong with your configuration !" >&2 echo "ERROR: There's something wrong with your configuration !" >&2
exit 1 exit 1
fi fi


umount /dar/build 2>/dev/null umount /dar/build 2>/dev/null
mount -o bind /dev/shm /dar/build/ #mount -o bind /dev/shm /dar/build/


for distname in $DEFAULT_DISTS; do for distname in $DEFAULT_DISTS; do
if [ "${DEFAULT_DISTS// */}" != $distname ]; then if [ "${DEFAULT_DISTS// */}" != $distname ]; then
ln -f $CHROOTDIR/${DEFAULT_DISTS// */}/root/.bash_history $CHROOTDIR/$distname/root/.bash_history ln -f $CHROOTDIR/${DEFAULT_DISTS// */}/root/.bash_history $CHROOTDIR/$distname/root/.bash_history
fi fi


umount $CHROOTDIR/$distname{/dev/pts,/proc,/sys,/tmp,$ROOT/build,$ROOT/} 2>/dev/null umount $CHROOTDIR/$distname{/dev/pts,/proc,/sys,/tmp,$ROOT/build,$ROOT/} 2>/dev/null


# rm -rf $CHROOTDIR/$distname{$RPMTMPPATH}/* # rm -rf $CHROOTDIR/$distname{$RPMTMPPATH}/*
mkdir -p $CHROOTDIR/$distname/$ROOT/ mkdir -p $CHROOTDIR/$distname/$ROOT/
mount -o bind $ROOT $CHROOTDIR/$distname/$ROOT/ mount -o bind $ROOT $CHROOTDIR/$distname/$ROOT/


mkdir -p $CHROOTDIR/$distname/proc/ mkdir -p $CHROOTDIR/$distname/proc/
mount -t proc proc $CHROOTDIR/$distname/proc/ mount -t proc proc $CHROOTDIR/$distname/proc/


mkdir -p $CHROOTDIR/$distname/sys/ mkdir -p $CHROOTDIR/$distname/sys/
mount -t sysfs sys $CHROOTDIR/$distname/sys/ mount -t sysfs sys $CHROOTDIR/$distname/sys/


mkdir -p $CHROOTDIR/$distname/dev/pts/ mkdir -p $CHROOTDIR/$distname/dev/pts/
mount -t devpts devpts $CHROOTDIR/$distname/dev/pts/ mount -t devpts devpts $CHROOTDIR/$distname/dev/pts/


### Use this when you want to speed up building :) ### Use this when you want to speed up building :)
mkdir -p $CHROOTDIR/$distname/$ROOT/build/ # mkdir -p $CHROOTDIR/$distname/$ROOT/build/
mount -o bind /dev/shm $CHROOTDIR/$distname$ROOT/build/ # mount -o bind /dev/shm $CHROOTDIR/$distname$ROOT/build/


### Use thise when using X processes inside chroots ### Use thise when using X processes inside chroots
mkdir -p $CHROOTDIR/$distname/tmp/ # mkdir -p $CHROOTDIR/$distname/tmp/
mount -o bind /tmp/ $CHROOTDIR/$distname/tmp/ # mount -o bind /tmp/ $CHROOTDIR/$distname/tmp/
done done
33 changes: 19 additions & 14 deletions dar-shell
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
source "/usr/share/dar/dar-functions" source "/usr/share/dar/dar-functions"


function help { function help {
cat <<EOF cat <<EOF
usage: dar-shell [-q] [-d dist,dist2] cmd usage: dar-shell [-q] [-v] [-d dist,dist2] cmd
Acquire a shell in one or more DAR build environments Acquire a shell in one or more DAR build environments
dar-exec options: dar-exec options:
-d dist,dist2 select build envs -d dist,dist2 select build envs
-h this help message -h this help message
-q be very quiet -q be very quiet
-v more verbose
exported variables: exported variables:
Expand All @@ -20,32 +21,36 @@ EOF
exit 1 exit 1
} }


daropts "d:hq" $@ daropts "d:hqv" $@
CMD="$OPTS" CMD="$OPTS"


if [ ! -d "$ROOT" ]; then if [ ! -d "$ROOT" ]; then
echo "ERROR: probably in chroot jail" >&2 echo "ERROR: probably in chroot jail" >&2
exit 1 exit 1
fi fi


set_dists set_dists
set_as_root set_as_root
AS_ROOT=1 AS_ROOT=1


if [ -z "$QUIET" ]; then if [ -z "$QUIET" ]; then
echo -e "$_BL_$_WH= Entering shells.$_DE" echo -e "$_BL_$_WH= Entering shells.$_DE"
fi fi
for distname in $DISTS; do for distname in $DISTS; do
if [ -r "$CONFIGDIR/dists/$distname/config" ]; then if [ -r "$CONFIGDIR/dists/$distname/config" ]; then
source "$CONFIGDIR/dists/$distname/config" source "$CONFIGDIR/dists/$distname/config"
export arch="$DISTARCH" dist="${DISTNAME// *}" nick="$DISTNICK" path="$DISTPATH" repo="$REPO" tag="${DISTTAG// *}" export arch="$DISTARCH" dist="${DISTNAME// *}" nick="$DISTNICK" path="$DISTPATH" repo="$REPO" tag="${DISTTAG// *}"
fi fi


setarch $DISTARCH chroot $CHROOTDIR/$distname if [ -z "$FORCE_VERBOSE" ]; then
setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$distname" /bin/bash --login
else
setarch $DISTARCH /usr/sbin/chroot "$CHROOTDIR/$distname" /bin/bash --login -x
fi
done done
if [ -z "$QUIET" ]; then if [ -z "$QUIET" ]; then
echo -en "$_BL_$_WH= Returning to parent shell. Press ENTER.$_DE" echo -en "$_BL_$_WH= Returning to parent shell. Press ENTER.$_DE"
read a read a
fi fi


exit 0 exit 0
Loading

0 comments on commit c39262d

Please sign in to comment.