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
Line 
1
2#!/bin/bash
3# Remote build script (iboernig@suse.de)
4# $Id: build.sh 677 2004-07-14 12:02:30Z joergs $
5#
6# Kurze Featuritis:
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
11# ein tar-Archiv, überträgt dieses nach Oldwotan und baut es dort
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.
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
26CONFIG_FILE=/usr/local/etc/build
27BUILD_CMD=build
28#SSH_VERSION="1"
29#BUILDHOST="oldwotan"
30#FQBUILDHOST="$BUILDHOST.suse.de"
31#BUILDTEMP=abuildtmp
32BUILDUSER=$USER
33BUILDTEMP=/tmp/abuildtmp/$BUILDUSER
34
35BUILDSCRIPT=$BUILDTEMP/buildscript.$$
36
37[ -z "$BUILD_MODE" ] && BUILD_MODE="--verify"
38[ -z "$BUILD_DIST" ] && BUILD_DIST="sles8-i386+update"
39[ -z "$BUILD_ROOT" ] && BUILD_ROOT="/var/tmp/buildsystem.$USER.$BUILD_DIST"
40[ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
41
42[ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"
43
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
74ERROR=0
75
76# Hier gehts los:
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
93echo $PACKAGE $VERSION $BUILD_DIST $BUILD_MODE
94
95# Cleaning up and install tempdir
96#ssh -${SSH_VERSION} ${FQBUILDHOST} "\
97 rm -rf ${BUILDTEMP}/src/${PACKAGE}; \
98 mkdir -p ${BUILDTEMP}/src/${PACKAGE} ${BUILDTEMP}/${BUILD_DIST};
99
100#scp -oProtocol=$SSH_VERSION $SRC_FILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}
101cp -a $SRC_FILES ${BUILDTEMP}/src/${PACKAGE}
102
103if [ "$1" ]; then
104 # extract RPM in a tempoary directory
105 #ssh -${SSH_VERSION} ${FQBUILDHOST} "\
106 cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i
107fi
108
109# create buildscript
110
111cat > $BUILDSCRIPT <<EOF
112#!/bin/bash
113# local buildscript
114#. /work/src/bin/.profile
115export BUILD_ROOT=$BUILD_ROOT
116export BUILD_DIST=$BUILD_DIST
117export BUILD_RPMS=${BUILDTEMP}/${BUILD_DIST}:$BUILD_RPMS
118export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
119
120cd ${BUILDTEMP}/src/${PACKAGE}
121#build $BUILD_MODE --prefer-rpms ${BUILDTEMP}/${BUILD_DIST}
122#build $BUILD_MODE
123$BUILD_CMD $BUILD_MODE
124EOF
125chmod a+x $BUILDSCRIPT
126
127#cat /tmp/tmpscript.$$
128
129#scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}/buildscript
130#rm /tmp/tmpscript.$$
131
132# build and file rpms
133#ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
134# . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}/buildscript
135
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
143mkdir -p ${DEST_DIR}/src
144# delete all old versions of this package
145rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm
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
150 ERROR=1
151fi
152
153mkdir -p ${DEST_DIR}/${BUILD_DIST}
154# delete all old versions of this package
155rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm
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
160 ERROR=2
161fi
162
163if [ $ERROR -ne 0 ]; then
164 echo "ERROR while building packet $PACKAGE";
165 for i in `seq 5`; do
166 echo -n "";
167 done
168else
169 echo "Build of ${PACKAGE} completed!"
170 echo "Packages can be found in ${DEST_DIR}"
171fi
172
173exit $ERROR
Note: See TracBrowser for help on using the repository browser.