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

Last change on this file since 679 was 679, checked in by joergs, on Aug 10, 2004 at 4:05:36 PM

build for Suse Linux 9.1

  • Property svn:executable set to *
  • Property svn:keywords set to Id LastChangedDate LastChangedRevision
File size: 5.4 KB
Line 
1
2#!/bin/bash
3# Remote build script (iboernig@suse.de)
4# $Id: build.sh 679 2004-08-10 14:05:36Z 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�t 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 "9.1-i386")
63 BUILD_RPMS_TEST=$BUILD_RPMS_9_1_i386 ;;
64 esac
65 if [ "$BUILD_RPMS_TEST" ]; then
66 if [ "$BUILD_RPMS" ]; then
67 BUILD_RPMS=$BUILD_RPMS:$BUILD_RPMS_TEST
68 else
69 BUILD_RPMS=$BUILD_RPMS_TEST
70 fi
71 fi
72fi
73
74echo BUILD_RPMS: $BUILD_RPMS
75
76ERROR=0
77
78# Hier gehts los:
79
80if [ -z "$1" ]; then
81 # without parameter, we are in source directory
82 test -e Makefile && make
83 SPECFILE=$(ls *.spec | awk '{print $1}')
84 TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')
85 PACKAGE=$(awk '/^Name:/ {print $2}' <$SPECFILE)
86 VERSION=$(awk '/^Version:/ {print $2}' <$SPECFILE)
87 SRC_FILES="$SPECFILE $TARFILE"
88else
89 # parameter is src.rpm file
90 PACKAGE=`echo $1 | sed 's/-[0-9]*\..*.src.rpm//'`
91 VERSION=`echo $1 | sed 's/.*-\([0-9]*\..*\)-.*.src.rpm/\1/'`
92 SRC_FILES="$1"
93fi
94
95echo $PACKAGE $VERSION $BUILD_DIST $BUILD_MODE
96
97# Cleaning up and install tempdir
98#ssh -${SSH_VERSION} ${FQBUILDHOST} "\
99 rm -rf ${BUILDTEMP}/src/${PACKAGE}; \
100 mkdir -p ${BUILDTEMP}/src/${PACKAGE} ${BUILDTEMP}/${BUILD_DIST};
101
102#scp -oProtocol=$SSH_VERSION $SRC_FILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}
103cp -a $SRC_FILES ${BUILDTEMP}/src/${PACKAGE}
104
105if [ "$1" ]; then
106 # extract RPM in a tempoary directory
107 #ssh -${SSH_VERSION} ${FQBUILDHOST} "\
108 cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i
109fi
110
111# create buildscript
112
113cat > $BUILDSCRIPT <<EOF
114#!/bin/bash
115# local buildscript
116#. /work/src/bin/.profile
117export BUILD_ROOT=$BUILD_ROOT
118export BUILD_DIST=$BUILD_DIST
119export BUILD_RPMS=${BUILDTEMP}/${BUILD_DIST}:$BUILD_RPMS
120export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
121
122cd ${BUILDTEMP}/src/${PACKAGE}
123#build $BUILD_MODE --prefer-rpms ${BUILDTEMP}/${BUILD_DIST}
124#build $BUILD_MODE
125$BUILD_CMD $BUILD_MODE
126EOF
127chmod a+x $BUILDSCRIPT
128
129#cat /tmp/tmpscript.$$
130
131#scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}/buildscript
132#rm /tmp/tmpscript.$$
133
134# build and file rpms
135#ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
136# . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}/buildscript
137
138sudo su -c $BUILDSCRIPT
139rm -f $BUILDSCRIPT
140
141#ssh -oProtocol=$SSH_VERSION ${FQBUILDHOST} \
142 rm -f ${BUILDTEMP}/${BUILD_DIST}/${PACKAGE}-*.*.rpm
143 cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${BUILDTEMP}/${BUILD_DIST}
144
145mkdir -p ${DEST_DIR}/src
146# delete all old versions of this package
147rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm
148#if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src ); then
149 #ERROR=1
150#fi
151if !(cp -a ${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src 2> /dev/null); then
152 ERROR=1
153fi
154
155mkdir -p ${DEST_DIR}/${BUILD_DIST}
156# delete all old versions of this package
157rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm
158#if !(scp -oProtocol=$SSH_VERSION #root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
159# ERROR=2
160#fi
161if !(cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
162 ERROR=2
163fi
164
165if [ $ERROR -ne 0 ]; then
166 echo "ERROR while building packet $PACKAGE";
167 for i in `seq 5`; do
168 echo -n "";
169 done
170else
171 echo "Build of ${PACKAGE} completed!"
172 echo "Packages can be found in ${DEST_DIR}"
173fi
174
175exit $ERROR
Note: See TracBrowser for help on using the repository browser.