From: Adam Dickmeiss Date: Tue, 11 Oct 2016 14:45:31 +0000 (+0200) Subject: Using mock inside container X-Git-Url: http://jira.indexdata.com/?a=commitdiff_plain;h=49f3f5d3cc12090d1951e659fb255776cb198646;p=git-tools-moved-to-github.git Using mock inside container Not complete because we don't get resulting RPMs out yet. --- diff --git a/id-deb-build/Dockerfile.mock b/id-deb-build/Dockerfile.mock new file mode 100644 index 0000000..cb07aa4 --- /dev/null +++ b/id-deb-build/Dockerfile.mock @@ -0,0 +1,17 @@ +FROM fedora:23 + +RUN dnf install -y mock rpm-build + +COPY rpmbuild /home/mock/rpmbuild +COPY rpmbuild/rpmmacros /home/mock/.rpmmacros + +RUN mkdir -p /home/mock/rpmbuild && \ + chmod +x /home/mock/rpmbuild/run.sh && \ + useradd -r -d /home/mock -g mock mock && \ + chown -R mock.mock /home/mock/rpmbuild + +USER mock + +WORKDIR /home/mock + +# ENTRYPOINT ["/bin/sh", "-c"] diff --git a/id-deb-build/docker-build.sh b/id-deb-build/docker-build.sh index ad8a797..5546b9f 100755 --- a/id-deb-build/docker-build.sh +++ b/id-deb-build/docker-build.sh @@ -57,8 +57,12 @@ if test "$DEBIAN_DIST_A" -o "$UBUNTU_DIST_A" -o "$CENTOS_DIST_A"; then fi if test "$CENTOS_DIST"; then - echo "CentOS not yet supported" - exit 1 + RNAME=`awk '/Name:/ {print $2}' *.spec` + if test "$NAME" -a "$NAME" != "$RNAME"; then + echo "NAME in IDMETA ($NAME) does not match RPM spec NAME ($RNAME)" + exit 1 + fi + PRODUCT=$RNAME centos=true else centos=false @@ -76,6 +80,8 @@ else debian=false fi +TAR=${PRODUCT}-${VERSION}.tar.gz + if $upload; then UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${PRODUCT} echo "Uploading to ${UPLOAD_URI}" @@ -107,6 +113,49 @@ 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 + + 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