[585] | 1 | #!/bin/bash
|
---|
| 2 | # Remote build script (iboernig@suse.de)
|
---|
[606] | 3 | # $Id: build.sh,v 1.9 2002/09/09 18:29:36 stephand 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 | # setzen der Zielarchtitektur. Wird bei Bedarf durch noarch überschrieben.
|
---|
| 29 | ARCH=i386
|
---|
| 30 | OS_TYPE=sles
|
---|
| 31 | OS_VER=7
|
---|
| 32 |
|
---|
| 33 | [ -z "$BUILD_MODE" ] && BUILD_MODE="--clean"
|
---|
| 34 | [ -z "$BUILD_DIST" ] && BUILD_DIST="${OS_TYPE}${OS_VER}-$ARCH"
|
---|
| 35 | [ -z "$BUILD_ROOT" ] && BUILD_ROOT="/abuild/buildsystem.$BUILDHOST.$USER.$BUILD_DIST.smartclient"
|
---|
[586] | 36 | [ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
|
---|
[585] | 37 |
|
---|
[590] | 38 | [ -z $DEST_DIR ] && DEST_DIR="/tmp/smartclient_build/$BUILD_DIST"
|
---|
[585] | 39 |
|
---|
| 40 | # Hier gehts los:
|
---|
| 41 | make
|
---|
| 42 |
|
---|
| 43 | SPECFILE=$(ls *.spec | awk '{print $1}')
|
---|
[586] | 44 | TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')
|
---|
[595] | 45 | DIFFILES=$(ls *.dif* 2>/dev/null | awk '{print $1}')
|
---|
[606] | 46 | PATCHFILES=$(ls *.patch 2>/dev/null | awk '{print $1}')
|
---|
[585] | 47 |
|
---|
[586] | 48 | # sonstige files die gebraucht werden
|
---|
[595] | 49 | RESTFILES=$(ls *.init 2>/dev/null | awk '{print $1}') # fuer srpm inetd
|
---|
[586] | 50 |
|
---|
[585] | 51 | PACKAGE=$(awk '/^Name:/ {print $2}' <$SPECFILE)
|
---|
| 52 | VERSION=$(awk '/^Version:/ {print $2}' <$SPECFILE)
|
---|
| 53 |
|
---|
| 54 | BUILDARCH=$(awk '/^BuildArch:/ {print $2}' <$SPECFILE)
|
---|
| 55 | [ -z "$BUILDARCH" ] && BUILDARCH=$ARCH
|
---|
| 56 |
|
---|
| 57 | echo $PACKAGE $VERSION $ARCH $BUILDARCH
|
---|
| 58 |
|
---|
| 59 | # Cleaning up and install tempdir
|
---|
| 60 | ssh -${SSH_VERSION} ${FQBUILDHOST} "rm -r ${BUILDTEMP}/src/${PACKAGE}-${VERSION}; \
|
---|
[597] | 61 | mkdir -p ${BUILDTEMP}/src/${PACKAGE}-${VERSION}\
|
---|
| 62 | mkdir -p ${BUILDTEMP}/${ARCH}/${OS_TYPE}/${OS_VER}";
|
---|
[585] | 63 |
|
---|
[606] | 64 | scp -oProtocol=$SSH_VERSION $TARFILE $SPECFILE $DIFFILES $PATCHFILES $RESTFILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}-${VERSION}
|
---|
[585] | 65 |
|
---|
| 66 | # create buildscript
|
---|
| 67 |
|
---|
| 68 | cat > /tmp/tmpscript.$$ <<EOF
|
---|
| 69 | #!/bin/bash
|
---|
| 70 | # local buildscript
|
---|
| 71 | . /work/src/bin/.profile
|
---|
| 72 | export BUILD_ROOT=$BUILD_ROOT
|
---|
| 73 | export BUILD_DIST=$BUILD_DIST
|
---|
[586] | 74 | export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
|
---|
| 75 |
|
---|
[597] | 76 | #echo "BUILD_PREPARE_SPEC ist $BUILD_PREPARE_SPEC";
|
---|
[586] | 77 |
|
---|
| 78 |
|
---|
[585] | 79 | cd ~${BUILDUSER}/${BUILDTEMP}/src/${PACKAGE}-${VERSION}
|
---|
[586] | 80 | build $BUILD_MODE --prefer-rpms ~${BUILDUSER}/${BUILDTEMP}/$ARCH/$OS_TYPE/$OS_VER
|
---|
[585] | 81 | EOF
|
---|
| 82 |
|
---|
| 83 | cat /tmp/tmpscript.$$
|
---|
| 84 |
|
---|
| 85 | scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}-${VERSION}/buildscript
|
---|
| 86 | rm /tmp/tmpscript.$$
|
---|
| 87 |
|
---|
| 88 | # build and file rpms
|
---|
| 89 | ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
|
---|
| 90 | . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}-${VERSION}/buildscript
|
---|
| 91 | ssh -oProtocol=$SSH_VERSION ${FQBUILDHOST} \
|
---|
[586] | 92 | cp ${BUILD_ROOT}/usr/src/packages/RPMS/${BUILDARCH}/${PACKAGE}-${VERSION}-*.${BUILDARCH}.rpm ${BUILDTEMP}/$ARCH/$OS_TYPE/$OS_VER/
|
---|
[585] | 93 |
|
---|
| 94 | mkdir -p ${DEST_DIR}/src
|
---|
| 95 |
|
---|
[591] | 96 | if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src;)
|
---|
| 97 | then
|
---|
| 98 | echo "ERROR while building packet $PACKAGE";
|
---|
| 99 | echo "";sleep 1;echo "";sleep 1;echo "";sleep 1;echo "";sleep 1;echo "";sleep 1;
|
---|
| 100 | sleep 10;
|
---|
| 101 | fi
|
---|
| 102 |
|
---|
[585] | 103 | mkdir -p ${DEST_DIR}/$ARCH/$OS_TYPE/$OS_VER
|
---|
[591] | 104 | if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/RPMS/${BUILDARCH}/${PACKAGE}-${VERSION}-*.${BUILDARCH}.rpm ${DEST_DIR}/$ARCH/$OS_TYPE/$OS_VER;)
|
---|
| 105 | then
|
---|
| 106 | echo "ERROR while building packet $PACKAGE";
|
---|
| 107 | echo "";sleep 1;echo "";sleep 1;echo "";sleep 1;echo "";sleep 1;echo "";sleep 1;
|
---|
| 108 | sleep 10;
|
---|
[595] | 109 | exit 1;
|
---|
[591] | 110 | fi
|
---|
[585] | 111 |
|
---|
| 112 | echo "Build of ${PACKAGE} completed!"
|
---|
| 113 | echo "Packages can be found in ${DEST_DIR}"
|
---|