Can now make deb/rpm with Docker
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 30 Dec 2016 14:36:00 +0000 (15:36 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 30 Dec 2016 14:36:00 +0000 (15:36 +0100)
id-deb-build/docker-build.sh
id-deb-build/in-docker-rpm.sh [new file with mode: 0755]

index 5546b9f..e608f79 100755 (executable)
@@ -81,10 +81,35 @@ else
 fi
 
 TAR=${PRODUCT}-${VERSION}.tar.gz
+if test ! -f "$TAR"; then
+    echo "tar $TAR missing"
+    exit 1
+fi
 
 if $upload; then
     UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${PRODUCT}
     echo "Uploading to ${UPLOAD_URI}"
+    if $centos; then
+       for dist in ${CENTOS_DIST}; do
+           case $dist in
+               centos6)
+                   D=6;;
+               centos7)
+                   D=7;;
+               *)
+                   echo "$dist not supported"
+                   exit 1
+           esac
+           ssh ${UPLOAD_HOST} "mkdir -p ${UPLOAD_PATH}/${PRODUCT}/redhat/centos/$D/RPMS"
+           ssh ${UPLOAD_HOST} "mkdir -p ${UPLOAD_PATH}/${PRODUCT}/redhat/centos/$D/SRPMS"
+           scp -r build/centos/$dist/rpmbuild/RPMS ${UPLOAD_URI}/redhat/centos/$D
+           scp -r build/centos/$dist/rpmbuild/SRPMS ${UPLOAD_URI}/redhat/centos/$D
+       done
+       if ! ssh ${UPLOAD_HOST} "sudo -n /home/indexdata/proj/git-tools/update-archive/update-yum-archive.sh" >yum-update.log 2>&1; then
+           echo "update-yum-archive.sh failed; inspect yum-update.log"
+           exit 1
+       fi
+    fi
     if $debian; then
        if test -n "${DEBIAN_DIST}"; then
            for dist in ${DEBIAN_DIST}; do
@@ -113,49 +138,27 @@ if $upload; then
     exit 0
 fi
 
-if $centos; then
-    mkdir -p rpmbuild/BUILD
-    mkdir -p rpmbuild/BUILDROOT
-    mkdir -p rpmbuild/RPMS/noarch
-    mkdir -p rpmbuild/RPMS/x86_64
-    mkdir -p rpmbuild/SOURCES
-    mkdir -p rpmbuild/SPECS
-    mkdir -p rpmbuild/SRPMS
-
-    echo "%_topdir /home/mock/rpmbuild" >rpmbuild/rpmmacros
-    echo "%_source_filedigest_algorithm   0" >>rpmbuild/rpmmacros
-    echo "%_binary_filedigest_algorithm   0" >>rpmbuild/rpmmacros
-
-    cp ${ID_DEB_BUILD}/Dockerfile.mock rpmbuild
-    cp ${TAR} rpmbuild/SOURCES
-    SPEC=${PRODUCT}.spec
-    cat ${SPEC}|sed "s/%define idmetaversion.*/%define idmetaversion ${VERSION}/" >rpmbuild/SPECS/${SPEC}
 
-    if true; then
-       for dist in ${CENTOS_DIST}; do
-           case $dist in
-               centos5)
-                   r=epel-5-x86_64 ;;
-               centos6)
-                   r=epel-6-x86_64 ;;
-               centos7)
-                   r=epel-7-x86_64 ;;
-               *)
-                   r=$dist ;;
-           esac
-           echo -n "$r"
-
-           rm -f rpmbuild/run.sh
-           echo '#!/bin/sh' >rpmbuild/run.sh
-           echo "rpmbuild -bs rpmbuild/SPECS/${SPEC}" >>rpmbuild/run.sh
-           echo "/usr/bin/mock --resultdir=rpmbuild -r $r rpmbuild/SRPMS/${PRODUCT}-${VERSION}*src.rpm" >>rpmbuild/run.sh
+if $centos; then
+    for dist in ${CENTOS_DIST}; do
+       sudo rm -fr build/centos/$dist
+       mkdir -p build/centos/$dist/rpmbuild
+       mkdir -p build/centos/$dist/rpmbuild/BUILD
+       mkdir -p build/centos/$dist/rpmbuild/BUILDROOT
+       mkdir -p build/centos/$dist/rpmbuild/RPMS/noarch
+       mkdir -p build/centos/$dist/rpmbuild/RPMS/x86_64
+       mkdir -p build/centos/$dist/rpmbuild/SOURCES
+       mkdir -p build/centos/$dist/rpmbuild/SPECS
+       mkdir -p build/centos/$dist/rpmbuild/SRPMS
+       cp ${TAR} build/centos/$dist/rpmbuild/SOURCES
+       SPEC=${PRODUCT}.spec
+       cp ${SPEC} build/centos/$dist/rpmbuild/SPECS
+       cp IDMETA build/centos/$dist/rpmbuild
+       cp ${ID_DEB_BUILD}/in-docker-rpm.sh build/centos/$dist
+    done
 
-           docker build -t indexdata-fedora-mock -f rpmbuild/Dockerfile.mock .
-           docker run --privileged -it --rm indexdata-fedora-mock rpmbuild/run.sh
-           echo "done"
-       done
-    fi
 fi
+
 if $debian; then
     MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
     if test ! -x $MKDEBSRC; then
@@ -197,20 +200,37 @@ if $debian; then
            cp ${ID_DEB_BUILD}/in-docker.sh build/ubuntu/$dist
        done
     fi
-    if test "${DEBIAN_DIST}"; then
-       for dist in ${DEBIAN_DIST}; do
-           cd build/debian/$dist
-           docker run -it --rm  -v "$PWD:/build" -w /build/$PRODUCT-$VERSION debian:$dist ../in-docker.sh debian $dist
-           cd ../../..
-       done
-    fi
-    if test "${UBUNTU_DIST}"; then
-       for dist in ${UBUNTU_DIST}; do
-           cd build/ubuntu/$dist
-           docker run -it --rm  -v "$PWD:/build" -w /build/$PRODUCT-$VERSION ubuntu:$dist ../in-docker.sh ubuntu $dist
-           cd ../../..
-       done
-    fi
+fi
+
+if test "${CENTOS_DIST}"; then
+    for dist in ${CENTOS_DIST}; do
+       case $dist in
+           centos6)
+               D=6;;
+           centos7)
+               D=7;;
+           *)
+               echo "$dist not supported"
+               exit 1
+       esac
+       cd build/centos/$dist
+       docker run -it --rm  -v "$PWD:/build" -w /build/rpmbuild centos:$D ../in-docker-rpm.sh centos $D
+       cd ../../..
+    done
+fi
+if test "${DEBIAN_DIST}"; then
+    for dist in ${DEBIAN_DIST}; do
+       cd build/debian/$dist
+       docker run -it --rm  -v "$PWD:/build" -w /build/$PRODUCT-$VERSION debian:$dist ../in-docker.sh debian $dist
+       cd ../../..
+    done
+fi
+if test "${UBUNTU_DIST}"; then
+    for dist in ${UBUNTU_DIST}; do
+       cd build/ubuntu/$dist
+       docker run -it --rm  -v "$PWD:/build" -w /build/$PRODUCT-$VERSION ubuntu:$dist ../in-docker.sh ubuntu $dist
+       cd ../../..
+    done
 fi
 
 # Local Variables:
diff --git a/id-deb-build/in-docker-rpm.sh b/id-deb-build/in-docker-rpm.sh
new file mode 100755 (executable)
index 0000000..8f915a5
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+# in-docker-rpm.sh
+
+set -x
+DIST=$1
+STEP=$2
+
+yum install -y wget yum-utils rpm-build gcc gcc-c++ make
+
+rpm --import http://ftp.indexdata.com/pub/yum/centos/$STEP/RPM-GPG-KEY-indexdata
+
+wget http://ftp.indexdata.com/pub/yum/centos/$STEP/indexdata.repo -P /etc/yum.repos.d/
+
+echo "%_topdir /build/rpmbuild" >$HOME/.rpmmacros
+echo "%_source_filedigest_algorithm   0" >>$HOME/.rpmmacros
+echo "%_binary_filedigest_algorithm   0" >>$HOME/.rpmmacros
+
+yum-builddep -y SPECS/*.spec
+
+rpmbuild -ba SPECS/*.spec
+
+RET=$?
+
+exit $RET
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation: 4
+# sh-basic-offset: 4
+# End:
+