source: trunk/technical/common/build/build.sh@ 678

Last change on this file since 678 was 677, checked in by joergs, on Jul 14, 2004 at 2:02:30 PM

BUILDCMD konfigurierbar

  • Property svn:keywords set to Id LastChangedDate LastChangedRevision
File size: 5.3 KB
RevLine 
[668]1
[585]2#!/bin/bash
3# Remote build script (iboernig@suse.de)
[675]4# $Id: build.sh 677 2004-07-14 12:02:30Z joergs $
[585]5#
6# Kurze Featuritis:
[621]7# - build.sh sollte im Pfad liegen.
8# Ein Link von ~/bin/build.sh ist eine gute Wahl ;)
9# - ohne Parameter aufgerufen,
10# erzeugt build.sh mit Hilfe des Makefiles in aktuellen Verzeichnis
[585]11# ein tar-Archiv, überträgt dieses nach Oldwotan und baut es dort
[621]12# - mit Parameter geht das Skript davon aus,
13# dass der Parameter ein SRPM Paket ist.
14# Dieses wird nach oldwotan kopiert, dort entpackt und dann gebaut.
[585]15# - Dazu muss ein ssh-pubkey in oldwotans /root/.ssh/authorized_keys gelegt
16# werden (build.sh verwendet ssh)
17# Wichtige Einstellungen:
18# - Standardmäßig baut build.sh mit --clean, wenns schnell gehen soll, die
19# Umgebungsvariable BUILD_MODE="--no-init" exportieren
20# - BUILD_DIST ist standard sles7-i386, kann auch durch entsprechenden Export
21# überschrieben werden.
22# - die fertigen Pakete werden nach DEST_DIR (kann durch env gesetzt werden)
23# in die vorgegebene Hierarchie (src, i386/sles/7) auf den lokalen Rechner
24# kopiert. Vorgabe ist /tmp/smartclient_build
25
[668]26CONFIG_FILE=/usr/local/etc/build
[677]27BUILD_CMD=build
[668]28#SSH_VERSION="1"
29#BUILDHOST="oldwotan"
30#FQBUILDHOST="$BUILDHOST.suse.de"
31#BUILDTEMP=abuildtmp
[585]32BUILDUSER=$USER
[668]33BUILDTEMP=/tmp/abuildtmp/$BUILDUSER
[585]34
[668]35BUILDSCRIPT=$BUILDTEMP/buildscript.$$
36
[619]37[ -z "$BUILD_MODE" ] && BUILD_MODE="--verify"
[668]38[ -z "$BUILD_DIST" ] && BUILD_DIST="sles8-i386+update"
39[ -z "$BUILD_ROOT" ] && BUILD_ROOT="/var/tmp/buildsystem.$USER.$BUILD_DIST"
[586]40[ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
[585]41
[668]42[ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"
[585]43
[668]44if [ -r $CONFIG_FILE ]; then
45 source $CONFIG_FILE
46 MOD_BUILD_DIST=`echo $BUILD_DIST | sed "s/[-+.]/_/g"`
47 #echo MOD_BUILD_DIST: $MOD_BUILD_DIST
48 #RPMS_PATHS=$[BUILD_RPMS_$MOD_BUILD_DIST]
49 #echo RPMS_PATHS: $RPM_PATHS
50 #if [ -n "$[BUILD_RPMS_$MOD_BUILD_DIST]" ]; then
51 # BUILD_RPMS=$[BUILD_RPMS_$MOD_BUILD_DIST]
52 #fi
53 #echo OUTPUT: $[BUILD_RPMS_$MOD_BUILD_DIST]
54 #:$BUILD_RPMS
55 case "$BUILD_DIST" in
56 "9.0-i386")
57 BUILD_RPMS_TEST=$BUILD_RPMS_9_0_i386 ;;
58 "sles8-i386")
59 BUILD_RPMS_TEST=$BUILD_RPMS_sles8_i386 ;;
60 "sles8-i386+update")
61 BUILD_RPMS_TEST=$BUILD_RPMS_sles8_i386_update ;;
62 esac
63 if [ "$BUILD_RPMS_TEST" ]; then
64 if [ "$BUILD_RPMS" ]; then
65 BUILD_RPMS=$BUILD_RPMS:$BUILD_RPMS_TEST
66 else
67 BUILD_RPMS=$BUILD_RPMS_TEST
68 fi
69 fi
70fi
71
72echo BUILD_RPMS: $BUILD_RPMS
73
[619]74ERROR=0
[585]75
[621]76# Hier gehts los:
[620]77
78if [ -z "$1" ]; then
79 # without parameter, we are in source directory
80 test -e Makefile && make
81 SPECFILE=$(ls *.spec | awk '{print $1}')
82 TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')
83 PACKAGE=$(awk '/^Name:/ {print $2}' <$SPECFILE)
84 VERSION=$(awk '/^Version:/ {print $2}' <$SPECFILE)
85 SRC_FILES="$SPECFILE $TARFILE"
86else
87 # parameter is src.rpm file
88 PACKAGE=`echo $1 | sed 's/-[0-9]*\..*.src.rpm//'`
89 VERSION=`echo $1 | sed 's/.*-\([0-9]*\..*\)-.*.src.rpm/\1/'`
90 SRC_FILES="$1"
91fi
92
[622]93echo $PACKAGE $VERSION $BUILD_DIST $BUILD_MODE
[585]94
95# Cleaning up and install tempdir
[668]96#ssh -${SSH_VERSION} ${FQBUILDHOST} "\
97 rm -rf ${BUILDTEMP}/src/${PACKAGE}; \
98 mkdir -p ${BUILDTEMP}/src/${PACKAGE} ${BUILDTEMP}/${BUILD_DIST};
[585]99
[668]100#scp -oProtocol=$SSH_VERSION $SRC_FILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}
101cp -a $SRC_FILES ${BUILDTEMP}/src/${PACKAGE}
[585]102
[620]103if [ "$1" ]; then
[668]104 # extract RPM in a tempoary directory
105 #ssh -${SSH_VERSION} ${FQBUILDHOST} "\
106 cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i
[620]107fi
108
[585]109# create buildscript
110
[668]111cat > $BUILDSCRIPT <<EOF
[585]112#!/bin/bash
113# local buildscript
[668]114#. /work/src/bin/.profile
[585]115export BUILD_ROOT=$BUILD_ROOT
116export BUILD_DIST=$BUILD_DIST
[668]117export BUILD_RPMS=${BUILDTEMP}/${BUILD_DIST}:$BUILD_RPMS
[586]118export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
119
[668]120cd ${BUILDTEMP}/src/${PACKAGE}
121#build $BUILD_MODE --prefer-rpms ${BUILDTEMP}/${BUILD_DIST}
[677]122#build $BUILD_MODE
123$BUILD_CMD $BUILD_MODE
[585]124EOF
[668]125chmod a+x $BUILDSCRIPT
[585]126
[621]127#cat /tmp/tmpscript.$$
[585]128
[668]129#scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}/buildscript
130#rm /tmp/tmpscript.$$
[585]131
132# build and file rpms
[668]133#ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
134# . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}/buildscript
[585]135
[668]136sudo su -c $BUILDSCRIPT
137rm -f $BUILDSCRIPT
138
139#ssh -oProtocol=$SSH_VERSION ${FQBUILDHOST} \
140 rm -f ${BUILDTEMP}/${BUILD_DIST}/${PACKAGE}-*.*.rpm
141 cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${BUILDTEMP}/${BUILD_DIST}
142
[585]143mkdir -p ${DEST_DIR}/src
[620]144# delete all old versions of this package
145rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm
[668]146#if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src ); then
147 #ERROR=1
148#fi
149if !(cp -a ${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src 2> /dev/null); then
[619]150 ERROR=1
151fi
[585]152
[619]153mkdir -p ${DEST_DIR}/${BUILD_DIST}
[620]154# delete all old versions of this package
155rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm
[668]156#if !(scp -oProtocol=$SSH_VERSION #root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
157# ERROR=2
158#fi
159if !(cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
[619]160 ERROR=2
[591]161fi
162
[619]163if [ $ERROR -ne 0 ]; then
[591]164 echo "ERROR while building packet $PACKAGE";
[619]165 for i in `seq 5`; do
[625]166 echo -n "";
[619]167 done
168else
169 echo "Build of ${PACKAGE} completed!"
170 echo "Packages can be found in ${DEST_DIR}"
[591]171fi
[585]172
[619]173exit $ERROR
Note: See TracBrowser for help on using the repository browser.