[585] | 1 | #!/bin/bash
|
---|
| 2 | # Remote build script (iboernig@suse.de)
|
---|
[619] | 3 | # $Id: build.sh,v 1.11 2002/10/10 15:01:08 joergs Exp $
|
---|
[585] | 4 | #
|
---|
| 5 | # Kurze Featuritis:
|
---|
| 6 | # - build.sh sollte im Pfad liegen ~/bin ist eine gute Wahl ;)
|
---|
| 7 | # - build.sh erzeugt mit Hilfe des Makefiles in jedem smartclient Verzeichnis
|
---|
| 8 | # ein tar-Archiv, überträgt dieses nach Oldwotan und baut es dort
|
---|
| 9 | # - Dazu muss ein ssh-pubkey in oldwotans /root/.ssh/authorized_keys gelegt
|
---|
| 10 | # werden (build.sh verwendet ssh)
|
---|
| 11 | # Wichtige Einstellungen:
|
---|
| 12 | # - Standardmäßig baut build.sh mit --clean, wenns schnell gehen soll, die
|
---|
| 13 | # Umgebungsvariable BUILD_MODE="--no-init" exportieren
|
---|
| 14 | # - BUILD_DIST ist standard sles7-i386, kann auch durch entsprechenden Export
|
---|
| 15 | # überschrieben werden.
|
---|
| 16 | # - ist BUILD_ROOT nicht gesetzt baut build.sh in der Umgebung
|
---|
| 17 | # /abuild/buildsystem.oldwotan.smartclient, um nicht mit Userumgebungen zu
|
---|
| 18 | # kollidieren.
|
---|
| 19 | # - die fertigen Pakete werden nach DEST_DIR (kann durch env gesetzt werden)
|
---|
| 20 | # in die vorgegebene Hierarchie (src, i386/sles/7) auf den lokalen Rechner
|
---|
| 21 | # kopiert. Vorgabe ist /tmp/smartclient_build
|
---|
| 22 |
|
---|
| 23 | SSH_VERSION="1"
|
---|
| 24 | BUILDHOST="oldwotan"
|
---|
| 25 | FQBUILDHOST="$BUILDHOST.suse.de"
|
---|
| 26 | BUILDTEMP=abuildtmp
|
---|
| 27 | BUILDUSER=$USER
|
---|
| 28 |
|
---|
[619] | 29 | [ -z "$BUILD_MODE" ] && BUILD_MODE="--verify"
|
---|
| 30 | [ -z "$BUILD_DIST" ] && BUILD_DIST="sles7-i386+update"
|
---|
[585] | 31 | [ -z "$BUILD_ROOT" ] && BUILD_ROOT="/abuild/buildsystem.$BUILDHOST.$USER.$BUILD_DIST.smartclient"
|
---|
[586] | 32 | [ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
|
---|
[585] | 33 |
|
---|
[619] | 34 | [ -z $DEST_DIR ] && DEST_DIR="/tmp/smartclient_build/"
|
---|
[585] | 35 |
|
---|
| 36 | # Hier gehts los:
|
---|
| 37 | make
|
---|
| 38 |
|
---|
| 39 | SPECFILE=$(ls *.spec | awk '{print $1}')
|
---|
[586] | 40 | TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')
|
---|
[595] | 41 | DIFFILES=$(ls *.dif* 2>/dev/null | awk '{print $1}')
|
---|
[606] | 42 | PATCHFILES=$(ls *.patch 2>/dev/null | awk '{print $1}')
|
---|
[585] | 43 |
|
---|
[586] | 44 | # sonstige files die gebraucht werden
|
---|
[617] | 45 | RESTFILES=$(ls *.init *.html 2>/dev/null | awk '{print $1}') # fuer srpm inetd
|
---|
[586] | 46 |
|
---|
[585] | 47 | PACKAGE=$(awk '/^Name:/ {print $2}' <$SPECFILE)
|
---|
| 48 | VERSION=$(awk '/^Version:/ {print $2}' <$SPECFILE)
|
---|
| 49 |
|
---|
[619] | 50 | ERROR=0
|
---|
[585] | 51 |
|
---|
[619] | 52 | echo $PACKAGE $VERSION $BUILD_DIST
|
---|
[585] | 53 |
|
---|
| 54 | # Cleaning up and install tempdir
|
---|
| 55 | ssh -${SSH_VERSION} ${FQBUILDHOST} "rm -r ${BUILDTEMP}/src/${PACKAGE}-${VERSION}; \
|
---|
[619] | 56 | mkdir -p ${BUILDTEMP}/src/${PACKAGE}-${VERSION} ${BUILDTEMP}/${BUILD_DIST}";
|
---|
[585] | 57 |
|
---|
[606] | 58 | scp -oProtocol=$SSH_VERSION $TARFILE $SPECFILE $DIFFILES $PATCHFILES $RESTFILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}-${VERSION}
|
---|
[585] | 59 |
|
---|
| 60 | # create buildscript
|
---|
| 61 |
|
---|
| 62 | cat > /tmp/tmpscript.$$ <<EOF
|
---|
| 63 | #!/bin/bash
|
---|
| 64 | # local buildscript
|
---|
| 65 | . /work/src/bin/.profile
|
---|
| 66 | export BUILD_ROOT=$BUILD_ROOT
|
---|
| 67 | export BUILD_DIST=$BUILD_DIST
|
---|
[586] | 68 | export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
|
---|
| 69 |
|
---|
[597] | 70 | #echo "BUILD_PREPARE_SPEC ist $BUILD_PREPARE_SPEC";
|
---|
[586] | 71 |
|
---|
| 72 |
|
---|
[585] | 73 | cd ~${BUILDUSER}/${BUILDTEMP}/src/${PACKAGE}-${VERSION}
|
---|
[619] | 74 | build $BUILD_MODE --prefer-rpms ~${BUILDUSER}/${BUILDTEMP}/${BUILD_DIST}
|
---|
[585] | 75 | EOF
|
---|
| 76 |
|
---|
| 77 | cat /tmp/tmpscript.$$
|
---|
| 78 |
|
---|
| 79 | scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}-${VERSION}/buildscript
|
---|
| 80 | rm /tmp/tmpscript.$$
|
---|
| 81 |
|
---|
| 82 | # build and file rpms
|
---|
| 83 | ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
|
---|
| 84 | . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}-${VERSION}/buildscript
|
---|
| 85 | ssh -oProtocol=$SSH_VERSION ${FQBUILDHOST} \
|
---|
[619] | 86 | cp ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${BUILDTEMP}/${BUILD_DIST}/
|
---|
[585] | 87 |
|
---|
| 88 | mkdir -p ${DEST_DIR}/src
|
---|
[619] | 89 | if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src ); then
|
---|
| 90 | ERROR=1
|
---|
| 91 | fi
|
---|
[585] | 92 |
|
---|
[619] | 93 | mkdir -p ${DEST_DIR}/${BUILD_DIST}
|
---|
| 94 | if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
|
---|
| 95 | ERROR=2
|
---|
[591] | 96 | fi
|
---|
| 97 |
|
---|
[619] | 98 | if [ $ERROR -ne 0 ]; then
|
---|
[591] | 99 | echo "ERROR while building packet $PACKAGE";
|
---|
[619] | 100 | for i in `seq 5`; do
|
---|
| 101 | echo -n ""; sleep 1;
|
---|
| 102 | done
|
---|
| 103 | else
|
---|
| 104 | echo "Build of ${PACKAGE} completed!"
|
---|
| 105 | echo "Packages can be found in ${DEST_DIR}"
|
---|
[591] | 106 | fi
|
---|
[585] | 107 |
|
---|
[619] | 108 | exit $ERROR
|
---|