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

Last change on this file since 675 was 675, checked in by joergs, on May 15, 2004 at 10:26:56 AM

adding keyword properties

  • 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 675 2004-05-15 08:26:56Z 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
27#SSH_VERSION="1"
28#BUILDHOST="oldwotan"
29#FQBUILDHOST="$BUILDHOST.suse.de"
30#BUILDTEMP=abuildtmp
31BUILDUSER=$USER
32BUILDTEMP=/tmp/abuildtmp/$BUILDUSER
33
34BUILDSCRIPT=$BUILDTEMP/buildscript.$$
35
36[ -z "$BUILD_MODE" ] && BUILD_MODE="--verify"
37[ -z "$BUILD_DIST" ] && BUILD_DIST="sles8-i386+update"
38[ -z "$BUILD_ROOT" ] && BUILD_ROOT="/var/tmp/buildsystem.$USER.$BUILD_DIST"
39[ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
40
41[ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"
42
43if [ -r $CONFIG_FILE ]; then
44 source $CONFIG_FILE
45 MOD_BUILD_DIST=`echo $BUILD_DIST | sed "s/[-+.]/_/g"`
46 #echo MOD_BUILD_DIST: $MOD_BUILD_DIST
47 #RPMS_PATHS=$[BUILD_RPMS_$MOD_BUILD_DIST]
48 #echo RPMS_PATHS: $RPM_PATHS
49 #if [ -n "$[BUILD_RPMS_$MOD_BUILD_DIST]" ]; then
50 # BUILD_RPMS=$[BUILD_RPMS_$MOD_BUILD_DIST]
51 #fi
52 #echo OUTPUT: $[BUILD_RPMS_$MOD_BUILD_DIST]
53 #:$BUILD_RPMS
54 case "$BUILD_DIST" in
55 "9.0-i386")
56 BUILD_RPMS_TEST=$BUILD_RPMS_9_0_i386 ;;
57 "sles8-i386")
58 BUILD_RPMS_TEST=$BUILD_RPMS_sles8_i386 ;;
59 "sles8-i386+update")
60 BUILD_RPMS_TEST=$BUILD_RPMS_sles8_i386_update ;;
61 esac
62 if [ "$BUILD_RPMS_TEST" ]; then
63 if [ "$BUILD_RPMS" ]; then
64 BUILD_RPMS=$BUILD_RPMS:$BUILD_RPMS_TEST
65 else
66 BUILD_RPMS=$BUILD_RPMS_TEST
67 fi
68 fi
69fi
70
71echo BUILD_RPMS: $BUILD_RPMS
72
73ERROR=0
74
75# Hier gehts los:
76
77if [ -z "$1" ]; then
78 # without parameter, we are in source directory
79 test -e Makefile && make
80 SPECFILE=$(ls *.spec | awk '{print $1}')
81 TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')
82 PACKAGE=$(awk '/^Name:/ {print $2}' <$SPECFILE)
83 VERSION=$(awk '/^Version:/ {print $2}' <$SPECFILE)
84 SRC_FILES="$SPECFILE $TARFILE"
85else
86 # parameter is src.rpm file
87 PACKAGE=`echo $1 | sed 's/-[0-9]*\..*.src.rpm//'`
88 VERSION=`echo $1 | sed 's/.*-\([0-9]*\..*\)-.*.src.rpm/\1/'`
89 SRC_FILES="$1"
90fi
91
92echo $PACKAGE $VERSION $BUILD_DIST $BUILD_MODE
93
94# Cleaning up and install tempdir
95#ssh -${SSH_VERSION} ${FQBUILDHOST} "\
96 rm -rf ${BUILDTEMP}/src/${PACKAGE}; \
97 mkdir -p ${BUILDTEMP}/src/${PACKAGE} ${BUILDTEMP}/${BUILD_DIST};
98
99#scp -oProtocol=$SSH_VERSION $SRC_FILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}
100cp -a $SRC_FILES ${BUILDTEMP}/src/${PACKAGE}
101
102if [ "$1" ]; then
103 # extract RPM in a tempoary directory
104 #ssh -${SSH_VERSION} ${FQBUILDHOST} "\
105 cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i
106fi
107
108# create buildscript
109
110cat > $BUILDSCRIPT <<EOF
111#!/bin/bash
112# local buildscript
113#. /work/src/bin/.profile
114export BUILD_ROOT=$BUILD_ROOT
115export BUILD_DIST=$BUILD_DIST
116export BUILD_RPMS=${BUILDTEMP}/${BUILD_DIST}:$BUILD_RPMS
117export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
118
119cd ${BUILDTEMP}/src/${PACKAGE}
120#build $BUILD_MODE --prefer-rpms ${BUILDTEMP}/${BUILD_DIST}
121build $BUILD_MODE
122EOF
123chmod a+x $BUILDSCRIPT
124
125#cat /tmp/tmpscript.$$
126
127#scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}/buildscript
128#rm /tmp/tmpscript.$$
129
130# build and file rpms
131#ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
132# . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}/buildscript
133
134sudo su -c $BUILDSCRIPT
135rm -f $BUILDSCRIPT
136
137#ssh -oProtocol=$SSH_VERSION ${FQBUILDHOST} \
138 rm -f ${BUILDTEMP}/${BUILD_DIST}/${PACKAGE}-*.*.rpm
139 cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${BUILDTEMP}/${BUILD_DIST}
140
141mkdir -p ${DEST_DIR}/src
142# delete all old versions of this package
143rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm
144#if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src ); then
145 #ERROR=1
146#fi
147if !(cp -a ${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src 2> /dev/null); then
148 ERROR=1
149fi
150
151mkdir -p ${DEST_DIR}/${BUILD_DIST}
152# delete all old versions of this package
153rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm
154#if !(scp -oProtocol=$SSH_VERSION #root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
155# ERROR=2
156#fi
157if !(cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
158 ERROR=2
159fi
160
161if [ $ERROR -ne 0 ]; then
162 echo "ERROR while building packet $PACKAGE";
163 for i in `seq 5`; do
164 echo -n "";
165 done
166else
167 echo "Build of ${PACKAGE} completed!"
168 echo "Packages can be found in ${DEST_DIR}"
169fi
170
171exit $ERROR
Note: See TracBrowser for help on using the repository browser.