From 59bd10fb387c1460bf9438b27942bfc499944b98 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 29 Jun 2015 12:50:19 +0000 Subject: [PATCH] Support CentOS 7 packages SA-745 Use mochi as build host with lxc YAZ 5.14.3 released with the updated id-pbuild.sh script. --- id-deb-build/id-pbuild-root.sh | 69 ------- id-deb-build/id-pbuild.sh | 412 ++++++++++++++++--------------------- id-rpm-build/id-setup-rpmbuild.sh | 18 -- id-rpm-build/upload-rpms.sh | 67 ------ 4 files changed, 181 insertions(+), 385 deletions(-) delete mode 100755 id-deb-build/id-pbuild-root.sh delete mode 100755 id-rpm-build/id-setup-rpmbuild.sh delete mode 100755 id-rpm-build/upload-rpms.sh diff --git a/id-deb-build/id-pbuild-root.sh b/id-deb-build/id-pbuild-root.sh deleted file mode 100755 index 1707786..0000000 --- a/id-deb-build/id-pbuild-root.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -usage() -{ - cat <&2 +fi + +if test -f IDMETA; then + . ./IDMETA +else + echo "IDMETA missing" + exit 1 +fi +UPLOAD_HOST=${UPLOAD_HOST:=ftp.indexdata.dk} +UPLOAD_PATH=${UPLOAD_PATH:=/home/ftp/pub} if test "$DEBIAN_DIST_A" -o "$UBUNTU_DIST_A" -o "$CENTOS_DIST_A"; then DEBIAN_DIST=$DEBIAN_DIST_A UBUNTU_DIST=$UBUNTU_DIST_A CENTOS_DIST=$CENTOS_DIST_A fi - -if test "$do_help" = "yes"; then - usage 1 1>&2 -fi - +ID_DEB_BUILD=~/proj/git-tools/id-deb-build if test "$DEBIAN_DIST" -o "$UBUNTU_DIST"; then debian=true + DNAME=`awk '/Source:/ {print $2}' debian/control` + if test "$NAME" -a "$NAME" != "$DNAME"; then + echo "NAME in IDMETA ($NAME) does not match debian/control ($DNAME)" + exit 1 + fi + PRODUCT=$DNAME else debian=false fi - -D0=`dirname $0` -ID_DEB_BUILD=`cd $D0; pwd` -PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh -if test ! -x $PBUILDROOT; then - echo "$PBUILDROOT not found" - exit 1 -fi - if test "$CENTOS_DIST"; then + centos=true RNAME=`awk '/Name:/ {print $2}' *.spec` - echo "RNAME=$RNAME" if test "$NAME" -a "$NAME" != "$RNAME"; then echo "NAME in IDMETA ($NAME) does not match RPM spec NAME ($RNAME)" exit 1 fi PRODUCT=$RNAME -fi -if $debian; then - DNAME=`awk '/Source:/ {print $2}' debian/control` - if test "$NAME" -a "$NAME" != "$DNAME"; then - echo "NAME in IDMETA ($NAME) does not match debian/control ($DNAME)" - exit 1 + if test ! -d ~/rpmbuild; then + mkdir -p ~/pmbuild/BUILD + mkdir -p ~/rpmbuild/RPMS/noarch + mkdir -p ~/rpmbuild/RPMS/x86_64 + mkdir -p ~/rpmbuild/SOURCES + mkdir -p ~/rpmbuild/SPECS + mkdir -p ~/rpmbuild/SRPMS fi - PRODUCT=$DNAME - if ! $upload; then - MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh - if test ! -x $MKDEBSRC; then - echo "$MKDEBSRC not found" +else + centos=false +fi +TAR=${PRODUCT}-${VERSION}.tar.gz + +if $upload; then + UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${PRODUCT} + echo "Uploading to ${UPLOAD_URI}" + if $centos; then + pkg_names=`rpm -q --specfile ${PRODUCT}.spec --queryformat "%{NAME}-%{VERSION}-%{RELEASE}\n"` + for dist in ${CENTOS_DIST}; do + case $dist in + centos5) + ftpdir=centos/5.5 + r=id-epel-5-x86_64 ;; + centos6) + ftpdir=centos/6 + r=id-epel-6-x86_64 ;; + centos7) + ftpdir=centos/7 + r=id-epel-7-x86_64 ;; + *) + ftpdir=centos/$dist + r=$dist ;; + esac + echo "$r" + for pkg in ${pkg_names}; do + ssh ${UPLOAD_HOST} "mkdir -p ${UPLOAD_PATH}/${PRODUCT}/redhat/${ftpdir}/SRPMS" + if test -f ~/rpmbuild/SRPMS/${pkg}.src.rpm; then + scp ~/rpmbuild/SRPMS/${pkg}.src.rpm ${UPLOAD_URI}/redhat/${ftpdir}/SRPMS + fi + for arch in x86_64 noarch; do + if test -f ~/rpmbuild/$r/${pkg}.${arch}.rpm; then + ssh ${UPLOAD_HOST} "mkdir -p ${UPLOAD_PATH}/${PRODUCT}/redhat/${ftpdir}/RPMS/${arch}" + scp ~/rpmbuild/$r/${pkg}.${arch}.rpm ${UPLOAD_URI}/redhat/${ftpdir}/RPMS/${arch} + fi + done + done + done + if ! ssh ${UPLOAD_HOST} "sudo -n /home/indexdata/proj/git-tools/update-archive/update-yum-archive.sh" >~/rpmbuild/yum-update.log 2>&1; then + echo "update-yum-archive.sh failed. Inspect ~/rpmbuild/yum-update.log" exit 1 fi - if ! ${ID_DEB_BUILD}/id-mk-deb-changelog.sh; then - echo "id-mk-deb-changelog.sh failed" + fi + + if $debian; then + cd deb-src + if test -n "${UBUNTU_DIST}"; then + for dist in ${UBUNTU_DIST}; do + ssh ${UPLOAD_HOST} "mkdir -p ${UPLOAD_PATH}/${PRODUCT}/ubuntu/${dist}" + if ! scp ${dist}-*/* ${UPLOAD_URI}/ubuntu/${dist}; then + echo "Upload failed for $dist" + exit 1 + fi + done fi - if test "${SUDO_USER}"; then - if test ! -d deb-src; then - $MKDEBSRC - fi - else - if test -d deb-src; then - rm -f deb-src/*.gz - if test $? -ne 0; then - echo "deb-src could not be removed. Remove deb-src manually" + if test -n "${DEBIAN_DIST}"; then + for dist in ${DEBIAN_DIST}; do + ssh ${UPLOAD_HOST} "mkdir -p ${UPLOAD_PATH}/${PRODUCT}/debian/${dist}" + if ! scp ${dist}-*/* ${UPLOAD_URI}/debian/${dist}; then + echo "Upload failed for $dist" exit 1 fi - rm -f deb-src/*.dsc - fi - $MKDEBSRC + done fi - fi -else - mkdir -p deb-src -fi - -cd deb-src - -if $debian; then - for f in *.dsc; do - if test -f "$f"; then - PKG=$f + if ! ssh ${UPLOAD_HOST} "sudo -n /home/indexdata/proj/git-tools/update-archive/update-archive.sh --ubuntu=\"${UBUNTU_DIST}\" --debian=\"${DEBIAN_DIST}\""; then + echo "update-archive.sh failed" + exit 1 fi - done - if test -z "$PKG"; then - echo "Specify .dsc file" - exit 1 - fi - if test ! -e "$PKG"; then - echo "${PKG} does not exist" - exit 1 - fi - if grep "Architecture: all" $PKG >/dev/null; then - USE_ARCHS=i386 - else - USE_ARCHS=$ARCHS - fi -fi - -echo "Product: $PRODUCT" -echo "Ubuntu distros: $UBUNTU_DIST" -echo "Debian distros: $DEBIAN_DIST" -echo "Centos distros: $CENTOS_DIST" - -if $debian; then - if test "${SUDO_USER}"; then - echo "Running as sudo." - echo "Tip: You can avoid it by adding the following in /etc/sudoers" - echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh" - HOME_EXPORT=/home/${SUDO_USER} - else - sudo -k - HOME_EXPORT=$HOME - fi - if test ! -f ${HOME_EXPORT}/.pbuilderrc; then - echo "${HOME_EXPORT}/.pbuilderrc missing" - echo "You may need to run: ln -s ~/proj/git-tools/id-deb-build/pbuilderrc ~/.pbuilderrc" - exit 1 fi + echo "Upload successful - we hope" + exit 0 fi -if $upload; then +if $centos; then + SPEC=${PRODUCT}.spec + cp ${TAR} ~/rpmbuild/SOURCES + cat ${SPEC}|sed "s/%define idmetaversion.*/%define idmetaversion ${VERSION}/" >~/rpmbuild/SPECS/${SPEC} + sudo lxc-attach -n mockbuild -- rpmbuild -bs ~/rpmbuild/SPECS/${SPEC} for dist in ${CENTOS_DIST}; do - arch=amd64 - prodver=${PRODUCT}-${VERSION} - if ! scp ${ID_DEB_BUILD}/../id-rpm-build/upload-rpms.sh ${dist}:rpmbuild/SOURCES/${prodver}/; then - echo "Copy of upload-rpms.sh to $dist failed" - exit 1 - fi - if ssh $dist "cd rpmbuild/SOURCES/${prodver} && chmod +x upload-rpms.sh && ./upload-rpms.sh ${PRODUCT}.spec"; then - : + case $dist in + centos5) + r=id-epel-5-x86_64 ;; + centos6) + r=id-epel-6-x86_64 ;; + centos7) + r=id-epel-7-x86_64 ;; + *) + r=$dist ;; + esac + echo -n "$r" + mkdir -p ~/rpmbuild/$r + if sudo lxc-attach -n mockbuild -- mock -q --resultdir=~/rpmbuild/$r -r $r ~/rpmbuild/SRPMS/${PRODUCT}-${VERSION}*src.rpm; then + echo " done" else - echo "Upload failed for $dist" + echo " failed. Inspect ~/rpmbuild/$r/build.log" exit 1 fi done - for dist in ${UBUNTU_DIST}; do - ssh ftp.indexdata.dk "mkdir -p /home/ftp/pub/${PRODUCT}/ubuntu/${dist}" - if ! scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}; then - echo "Upload failed for $dist" - exit 1 - fi - done - for dist in ${DEBIAN_DIST}; do - ssh ftp.indexdata.dk "mkdir -p /home/ftp/pub/${PRODUCT}/debian/${dist}" - if ! scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}; then - echo "Upload failed for $dist" - exit 1 - fi - done - if test "${CENTOS_DIST}"; then - if ! ssh ftp.indexdata.dk "sudo -n /home/indexdata/proj/git-tools/update-archive/update-yum-archive.sh"; then - echo "update-yum-archive.sh failed" - exit 1 - fi - fi - if test "${UBUNTU_DIST}" -o "${DEBIAN_DIST}"; then - if ! ssh ftp.indexdata.dk "sudo -n /home/indexdata/proj/git-tools/update-archive/update-archive.sh --ubuntu=\"${UBUNTU_DIST}\" --debian=\"${DEBIAN_DIST}\""; then - echo "update-archive.sh failed" - exit 1 - fi - fi - echo "Upload successful - we hope" - exit 0 fi - -rm -f *.log - -# copy tars to centos build hosts -for dist in ${CENTOS_DIST}; do - arch=amd64 - prodver=${PRODUCT}-${VERSION} - tarname=${prodver}.tar.gz - if test ! -f ../${tarname}; then - echo "$tarname: missing" +if $debian; then + sudo rm -fr deb-src + MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh + if test ! -x $MKDEBSRC; then + echo "$MKDEBSRC not found" exit 1 fi - - if ssh $dist "test -f .rpmmacros && test -d rpmbuild/SOURCES && test -d rpmbuild/RPMS && test -d rpmbuild/SRPMS"; then - : - else - echo "Host $dist does not seem to be prepared with rpmbuild directories" - exit 1 + if ! ${ID_DEB_BUILD}/id-mk-deb-changelog.sh; then + echo "id-mk-deb-changelog.sh failed" fi - - if scp ../${tarname} $dist:rpmbuild/SOURCES/ ; then - : - else - echo "Could not copy $tarname to $dist" + if ! ${MKDEBSRC}; then + echo "id-mk-deb-src.sh failed" + fi + cd deb-src + for f in *.dsc; do + if test -f "$f"; then + DSC=$f + fi + done + if test -z "$DSC"; then + echo "${DSC}does not exist" exit 1 fi - if ssh $dist "cd rpmbuild/SOURCES && rm -fr $prodver && tar zxf $tarname && cd ${prodver} && rpmbuild -ba ${PRODUCT}.spec" >${dist}-${arch}.log 2>&1; then - : + if grep "Architecture: all" $DSC >/dev/null; then + USE_ARCHS=i386 else - echo "FAILED: See ${dist}-${arch}.log" - exit 1 + USE_ARCHS="i386 amd64" fi -done - -# call our privileged wrapper to clean the directories, no --dsc option -for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do - for arch in ${USE_ARCHS}; do - sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch - if test $? -ne 0; then - echo "FAILED" - echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:" - echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh" - exit 1 - fi - done -done - -# call our privileged wrapper to do the real work, with --dsc option -i=0 -date -for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do - for arch in ${USE_ARCHS}; do - sudo -n $PBUILDROOT --home=${HOME_EXPORT} \ - --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 & - i=`expr $i + 1` - if test $i -eq $concurrency; then - i=0 - wait - if test -f ${dist}-${arch}/*.dsc; then - : + for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do + for arch in ${USE_ARCHS}; do + echo -n "dist=$dist arch=$arch" + rm -f ~/.pbuilderrc + echo "DIST=$dist" > ~/.pbuilderrc + echo "ARCH=$arch" >> ~/.pbuilderrc + cat ${ID_DEB_BUILD}/pbuilderrc >> ~/.pbuilderrc + echo -n " update" + if ! sudo lxc-attach -n pbuilder -- pbuilder --update --override-config >update-${dist}-${arch}.log 2>&1; then + echo -n " create" + if ! sudo lxc-attach -n pbuilder -- pbuilder --create >create-${dist}-${arch}.log 2>&1; then + echo " failed. Inspect deb-src/create-${dist}-${arch}.log" + exit 1 + fi + echo -n " update" + if ! sudo lxc-attach -n pbuilder -- pbuilder --update --override-config >update-${dist}-${arch}.log 2>&1; then + echo " failed. Inspect deb-src/update-${dist}-${arch}.log" + exit 1 + fi + fi + echo -n " build" + if sudo lxc-attach -n pbuilder -- pbuilder --build $DSC >build-${dist}-${arch}.log 2>&1; then + echo " done" else - echo "FAILED: No .dsc file for ${dist}-${arch}" + echo " failed. Inspect deb-src/build-${dist}-${arch}.log" exit 1 fi - fi + done done -done -wait -for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do - for arch in ${USE_ARCHS}; do - if test -f ${dist}-${arch}/*.dsc; then - : - else - echo "FAILED: No .dsc file for ${dist}-${arch}" - exit 1 - fi - done -done +fi -date -echo "Done" # Local Variables: # mode:shell-script -# sh-indentation: 2 +# sh-indentation: 4 # sh-basic-offset: 4 # End: + diff --git a/id-rpm-build/id-setup-rpmbuild.sh b/id-rpm-build/id-setup-rpmbuild.sh deleted file mode 100755 index 0cba257..0000000 --- a/id-rpm-build/id-setup-rpmbuild.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Thie script will create an .rpmmacros file that will allow rpmbuild -# as non-root. Results will be put in in rpmbuild of your home directory -cd $HOME -if test -f .rpmmacros; then - echo ".rpmmacros already exist" -else - echo "creating .rpmmacros" - echo "%_topdir $HOME/rpmbuild" >.rpmmacros -fi -if test ! -d rpmbuild; then - mkdir -p rpmbuild/BUILD - mkdir -p rpmbuild/RPMS/noarch - mkdir -p rpmbuild/RPMS/x86_64 - mkdir -p rpmbuild/SOURCES - mkdir -p rpmbuild/SPECS - mkdir -p rpmbuild/SRPMS -fi diff --git a/id-rpm-build/upload-rpms.sh b/id-rpm-build/upload-rpms.sh deleted file mode 100755 index 9450fbe..0000000 --- a/id-rpm-build/upload-rpms.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -PWD=`pwd` -UPLOAD_PATH=${UPLOAD_PATH:=/home/ftp/pub} -UPLOAD_HOST=${UPLOAD_HOST:=ftp.indexdata.dk} -specfile=$1 -if test ! -f "${specfile}"; then - echo "Missing .spec file argument." - exit 1 -fi -if test ! -x /bin/rpm; then - echo "$0: /bin/rpm missing. Install rpm" - exit 1 -fi -if test ! -f /etc/redhat-release; then - echo "/etc/redhat-release missing" - exit 1 -fi -if test -z "$DISTRO"; then - if grep 'release 6' /etc/redhat-release >/dev/null; then - DISTRO="centos/6" - elif grep 'release 7' /etc/redhat-release > /dev/null; then - DISTRO="centos/7" - else - DISTRO="centos/5.5" - fi -fi -topdir=`rpm --eval "%{_topdir}"` -BUILD_DIR=${BUILD_DIR:=${topdir}} -pkg_names=`rpm -q --specfile ${specfile} --queryformat "%{NAME}-%{VERSION}-%{RELEASE}\n"` -pkg_short=`rpm -q --specfile ${specfile} --queryformat "%{NAME};" | cut -d ";" -f1` - -UPLOAD_DIR=${UPLOAD_DIR:=${pkg_short}} -UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${UPLOAD_DIR} -echo "Uploading to ${UPLOAD_URI}..." -inc_src=true -if test ! -d ${BUILD_DIR}/SRPMS; then - echo "No SRPMS dir under ${BUILD_DIR}" - inc_src=false -fi -inc_bin=true -if test ! -d ${BUILD_DIR}/RPMS; then - echo "No RPMS dir under ${BUILD_DIR}" - inc_bin=false -fi - -for pkg in ${pkg_names}; do - copy=false - if $inc_src; then - if test -f ${BUILD_DIR}/SRPMS/${pkg}.src.rpm; then - scp ${BUILD_DIR}/SRPMS/${pkg}.src.rpm ${UPLOAD_URI}/redhat/${DISTRO}/SRPMS/ - copy=true - fi - fi - if $inc_bin; then - for dir in ${BUILD_DIR}/RPMS/*; do - arch=`basename ${dir}` - if test -f ${dir}/${pkg}.${arch}.rpm; then - copy=true - scp ${dir}/${pkg}.${arch}.rpm ${UPLOAD_URI}/redhat/${DISTRO}/RPMS/${arch}/ - fi - done - if ! $copy; then - echo "FAILED: No RPM copied for: ${pkg}" - exit 1 - fi - fi -done -- 1.7.10.4