[585] | 1 | #!/bin/bash
|
---|
| 2 | # Remote build script (iboernig@suse.de)
|
---|
[621] | 3 | # $Id: build.sh,v 1.13 2002/10/11 12:35:39 joergs Exp $
|
---|
[585] | 4 | #
|
---|
| 5 | # Kurze Featuritis:
|
---|
[621] | 6 | # - build.sh sollte im Pfad liegen.
|
---|
| 7 | # Ein Link von ~/bin/build.sh ist eine gute Wahl ;)
|
---|
| 8 | # - ohne Parameter aufgerufen,
|
---|
| 9 | # erzeugt build.sh mit Hilfe des Makefiles in aktuellen Verzeichnis
|
---|
[585] | 10 | # ein tar-Archiv, überträgt dieses nach Oldwotan und baut es dort
|
---|
[621] | 11 | # - mit Parameter geht das Skript davon aus,
|
---|
| 12 | # dass der Parameter ein SRPM Paket ist.
|
---|
| 13 | # Dieses wird nach oldwotan kopiert, dort entpackt und dann gebaut.
|
---|
[585] | 14 | # - Dazu muss ein ssh-pubkey in oldwotans /root/.ssh/authorized_keys gelegt
|
---|
| 15 | # werden (build.sh verwendet ssh)
|
---|
| 16 | # Wichtige Einstellungen:
|
---|
| 17 | # - Standardmäßig baut build.sh mit --clean, wenns schnell gehen soll, die
|
---|
| 18 | # Umgebungsvariable BUILD_MODE="--no-init" exportieren
|
---|
| 19 | # - BUILD_DIST ist standard sles7-i386, kann auch durch entsprechenden Export
|
---|
| 20 | # überschrieben werden.
|
---|
| 21 | # - die fertigen Pakete werden nach DEST_DIR (kann durch env gesetzt werden)
|
---|
| 22 | # in die vorgegebene Hierarchie (src, i386/sles/7) auf den lokalen Rechner
|
---|
| 23 | # kopiert. Vorgabe ist /tmp/smartclient_build
|
---|
| 24 |
|
---|
| 25 | SSH_VERSION="1"
|
---|
| 26 | BUILDHOST="oldwotan"
|
---|
| 27 | FQBUILDHOST="$BUILDHOST.suse.de"
|
---|
| 28 | BUILDTEMP=abuildtmp
|
---|
| 29 | BUILDUSER=$USER
|
---|
| 30 |
|
---|
[619] | 31 | [ -z "$BUILD_MODE" ] && BUILD_MODE="--verify"
|
---|
| 32 | [ -z "$BUILD_DIST" ] && BUILD_DIST="sles7-i386+update"
|
---|
[585] | 33 | [ -z "$BUILD_ROOT" ] && BUILD_ROOT="/abuild/buildsystem.$BUILDHOST.$USER.$BUILD_DIST.smartclient"
|
---|
[586] | 34 | [ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
|
---|
[585] | 35 |
|
---|
[619] | 36 | [ -z $DEST_DIR ] && DEST_DIR="/tmp/smartclient_build/"
|
---|
[585] | 37 |
|
---|
[619] | 38 | ERROR=0
|
---|
[585] | 39 |
|
---|
[621] | 40 | # Hier gehts los:
|
---|
[620] | 41 |
|
---|
| 42 | if [ -z "$1" ]; then
|
---|
| 43 | # without parameter, we are in source directory
|
---|
| 44 | test -e Makefile && make
|
---|
| 45 | SPECFILE=$(ls *.spec | awk '{print $1}')
|
---|
| 46 | TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')
|
---|
| 47 | PACKAGE=$(awk '/^Name:/ {print $2}' <$SPECFILE)
|
---|
| 48 | VERSION=$(awk '/^Version:/ {print $2}' <$SPECFILE)
|
---|
| 49 | SRC_FILES="$SPECFILE $TARFILE"
|
---|
| 50 | else
|
---|
| 51 | # parameter is src.rpm file
|
---|
| 52 | PACKAGE=`echo $1 | sed 's/-[0-9]*\..*.src.rpm//'`
|
---|
| 53 | VERSION=`echo $1 | sed 's/.*-\([0-9]*\..*\)-.*.src.rpm/\1/'`
|
---|
| 54 | SRC_FILES="$1"
|
---|
| 55 | fi
|
---|
| 56 |
|
---|
[619] | 57 | echo $PACKAGE $VERSION $BUILD_DIST
|
---|
[585] | 58 |
|
---|
| 59 | # Cleaning up and install tempdir
|
---|
[621] | 60 | ssh -${SSH_VERSION} ${FQBUILDHOST} "\
|
---|
| 61 | rm -r ${BUILDTEMP}/src/${PACKAGE}; \
|
---|
| 62 | mkdir -p ${BUILDTEMP}/src/${PACKAGE} ${BUILDTEMP}/${BUILD_DIST}";
|
---|
[585] | 63 |
|
---|
[620] | 64 | scp -oProtocol=$SSH_VERSION $SRC_FILES ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}
|
---|
[585] | 65 |
|
---|
[620] | 66 | if [ "$1" ]; then
|
---|
| 67 | ssh -${SSH_VERSION} ${FQBUILDHOST} "\
|
---|
| 68 | cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i";
|
---|
| 69 | fi
|
---|
| 70 |
|
---|
[585] | 71 | # create buildscript
|
---|
| 72 |
|
---|
| 73 | cat > /tmp/tmpscript.$$ <<EOF
|
---|
| 74 | #!/bin/bash
|
---|
| 75 | # local buildscript
|
---|
| 76 | . /work/src/bin/.profile
|
---|
| 77 | export BUILD_ROOT=$BUILD_ROOT
|
---|
| 78 | export BUILD_DIST=$BUILD_DIST
|
---|
[586] | 79 | export BUILD_PREPARE_SPEC=$BUILD_PREPARE_SPEC
|
---|
| 80 |
|
---|
[620] | 81 | cd ~${BUILDUSER}/${BUILDTEMP}/src/${PACKAGE}
|
---|
[619] | 82 | build $BUILD_MODE --prefer-rpms ~${BUILDUSER}/${BUILDTEMP}/${BUILD_DIST}
|
---|
[585] | 83 | EOF
|
---|
| 84 |
|
---|
[621] | 85 | #cat /tmp/tmpscript.$$
|
---|
[585] | 86 |
|
---|
[620] | 87 | scp -oProtocol=$SSH_VERSION /tmp/tmpscript.$$ ${FQBUILDHOST}:${BUILDTEMP}/src/${PACKAGE}/buildscript
|
---|
[585] | 88 | rm /tmp/tmpscript.$$
|
---|
| 89 |
|
---|
| 90 | # build and file rpms
|
---|
| 91 | ssh -oProtocol=$SSH_VERSION root@${FQBUILDHOST} \
|
---|
[620] | 92 | . ~$BUILDUSER/${BUILDTEMP}/src/${PACKAGE}/buildscript
|
---|
[585] | 93 | ssh -oProtocol=$SSH_VERSION ${FQBUILDHOST} \
|
---|
[620] | 94 | "rm -f ${BUILDTEMP}/${BUILD_DIST}/${PACKAGE}-*.*.rpm;\
|
---|
| 95 | cp ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${BUILDTEMP}/${BUILD_DIST}/"
|
---|
[585] | 96 |
|
---|
| 97 | mkdir -p ${DEST_DIR}/src
|
---|
[620] | 98 | # delete all old versions of this package
|
---|
| 99 | rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm
|
---|
[619] | 100 | if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src ); then
|
---|
| 101 | ERROR=1
|
---|
| 102 | fi
|
---|
[585] | 103 |
|
---|
[619] | 104 | mkdir -p ${DEST_DIR}/${BUILD_DIST}
|
---|
[620] | 105 | # delete all old versions of this package
|
---|
| 106 | rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm
|
---|
[619] | 107 | if !(scp -oProtocol=$SSH_VERSION root@${FQBUILDHOST}:${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}-${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
|
---|
| 108 | ERROR=2
|
---|
[591] | 109 | fi
|
---|
| 110 |
|
---|
[619] | 111 | if [ $ERROR -ne 0 ]; then
|
---|
[591] | 112 | echo "ERROR while building packet $PACKAGE";
|
---|
[619] | 113 | for i in `seq 5`; do
|
---|
| 114 | echo -n ""; sleep 1;
|
---|
| 115 | done
|
---|
| 116 | else
|
---|
| 117 | echo "Build of ${PACKAGE} completed!"
|
---|
| 118 | echo "Packages can be found in ${DEST_DIR}"
|
---|
[591] | 119 | fi
|
---|
[585] | 120 |
|
---|
[619] | 121 | exit $ERROR
|
---|