From 79d9581742df2850183113d5abfe5cbc182e8092 Mon Sep 17 00:00:00 2001 From: Thomas Oulevey Date: Oct 27 2014 10:29:19 +0000 Subject: - Initial import. --- diff --git a/buildsys-tools/buildsys-macros-el7.spec b/buildsys-tools/buildsys-macros-el7.spec new file mode 100644 index 0000000..c841840 --- /dev/null +++ b/buildsys-tools/buildsys-macros-el7.spec @@ -0,0 +1,40 @@ +%global _el_version el7 +%global _el_sub .buildsys + +Name: buildsys-macros-%{_el_version} +Summary: Macros for the Buildsystem +Version: 1.0 +Release: 0%{dist} +License: GPL +Group: Development/Buildsystem +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildArch: noarch + +%description +This particular package contains the macros needed for the buildsys for Centos el7. + +%prep + +%build + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/etc/rpm/ +VERSION=%{version} +printf %s%b "%" "rhel 7\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "dist .%{_el_version}\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "el7 1\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "__arch_install_post /usr/lib/rpm/check-buildroot\n" >> %{buildroot}/etc/rpm/macros.checkbuild + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +/etc/rpm/macros.disttag +/etc/rpm/macros.checkbuild + +%changelog +* Tue Jul 08 2014 Thomas 'alphacc' Oulevey +- Initial Centos build. + diff --git a/buildsys-tools/buildsys-tools.spec b/buildsys-tools/buildsys-tools.spec new file mode 100644 index 0000000..c7297aa --- /dev/null +++ b/buildsys-tools/buildsys-tools.spec @@ -0,0 +1,48 @@ +Name: buildsys-tools +Version: 0.1 +Release: 14%{?dist} +Summary: Tools from centos-git-common git repository + +License: GPLv2 +URL: https://git.centos.org/summary/centos-git-common.git +#Source0: %{name}-%{version}.tgz +Source0: get_sources.sh +Source1: return_disttag.sh +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +Requires: python +Requires: bash +Requires: which +Requires: git + +%description + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}%{_bindir} +cp %{SOURCE0} %{buildroot}%{_bindir} +cp %{SOURCE1} %{buildroot}%{_bindir} + +cat >%{buildroot}%{_bindir}/get_sources <<'EOF' +#!/bin/bash +#MAJOR=`cat /etc/rpm/macros.dist | grep rhel | cut -d " " -f 2` +#git checkout c$MAJOR >> log +COMMIT=`git rev-parse HEAD` +BRANCH=`git branch -r --contains | cut -d / -f 2` +get_sources.sh -b $BRANCH >> log +EOF + +chmod a+x %{buildroot}%{_bindir}/get_sources + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%{_bindir}/* + + +%changelog +* Mon Jul 28 2014 Thomas Oulevey - 0.1-1 +- Initial version + diff --git a/cron.d/mash b/cron.d/mash new file mode 100644 index 0000000..55df52b --- /dev/null +++ b/cron.d/mash @@ -0,0 +1 @@ +*/10 * * * * root /home/backup/cbs/scripts/mash_run.sh diff --git a/cron.d/mash_run.sh b/cron.d/mash_run.sh new file mode 100755 index 0000000..cc0ed9d --- /dev/null +++ b/cron.d/mash_run.sh @@ -0,0 +1,132 @@ +usage() +{ +cat << EOF +usage: $0 [-t ] + +This script generate mash repo from all SIG tags. + +OPTIONS: + -t tag(s) : storage7-release, storage7-testing etc... +EOF +} + +# Global config +# mash binary +MASH="/usr/bin/mash" +# mash config containing mash.conf +MASH_CONF="/etc/mash" +# repos destination +MASH_DEST="/mnt/kojishare/repos" +# repoviewurl in mash config +MASH_VIEWURL="http://cbs.centos.org/repos" +# log directory +LOG_DIR="/var/log/mash" +# End Global + +optiont=false +optionv=false +while getopts ":hvt:" OPTION +do + case ${OPTION} in + h) + usage + exit 0 + ;; + t) + optiont=true + TAGS="${OPTARG}" + ;; + v) + optionv=true + ;; + ?) + exit 0 + ;; + :) + echo "Option -${OPTARG} requires an argument." + exit 1 + ;; + esac +done + +shift $((${OPTIND} - 1)) + +if ( ! ${optiont} ) +then + # Check if user is allowed to send command to koji and has 'admin' permission + KOJI=`which koji` + PERM=`${KOJI} list-permissions --mine` + if [ "${PERM}" != "admin" ] + then + echo "[ERROR] Koji misconfigure/missing admin privilege for creating SIG tags" + exit 1 + fi + TEST_TAGS=`koji list-tags | grep "\-testing"` + RELEASE_TAGS=`koji list-tags | grep "\-release"` + TAGS="${TEST_TAGS} ${RELEASE_TAGS}" +fi + +print_mash_template() +{ + local tag=$1 +cat << EOF +[${tag}] +rpm_path = ${MASH_DEST}/${tag}/%(arch)s/os/Packages +repodata_path = ${MASH_DEST}/${tag}/%(arch)s/os/ +source_path = source/SRPMS +debuginfo = True +multilib = True +multilib_method = devel +tag = ${tag} +inherit = False +strict_keys = False +repoviewurl = ${MASH_VIEWURL}/${tag}/%(arch)s/os/ +repoviewtitle = "${tag^^}" +arches = i386 x86_64 +delta = True +EOF +} + +mash_prepare () +{ + local tag=$1 + local log=$2 + ( $optionv ) && echo "* Checking ${tag} mash config..." + # config mash already ok + [ -f ${MASH_CONF}/${tag}.mash ] && return + ( $optionv ) && echo " -> [INFO] creating mash config: ${tag}.mash..." + print_mash_template "${tag}" > ${MASH_CONF}/${tag}.mash +} + +mash_run () { + local tag=$1 + local log=$2 + ${MASH} -p ${MASH_DEST}/ -o ${MASH_DEST}/ ${tag} &> ${log} + [ $? -gt 0 ] && echo " -> [ERROR] mash run failed ${log} " + ( $optionv ) && echo " -> [INFO] mash run succeeded ${log}" +} + +# Ensure we do not have parallel runs +pidfile=/var/run/mash-run.pid +if [ -e $pidfile ]; then + pid=`cat $pidfile` + if kill -0 &> /dev/null $pid; then + ( $optionv ) && echo "Mash is already running PID:$pid" + exit 1 + else + rm $pidfile &>/dev/null + fi +fi + +echo $$ > $pidfile + +for TAG in ${TAGS} +do + LOG="${LOG_DIR}/mash.${TAG}.log" + mash_prepare "${TAG}" "${LOG}" + mash_run "${TAG}" "${LOG}" & +done + +wait +rm $pidfile +exit 0 diff --git a/scripts/create_sig.sh b/scripts/create_sig.sh new file mode 100755 index 0000000..fc8d069 --- /dev/null +++ b/scripts/create_sig.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +usage() +{ +cat << EOF +usage: $0 -d -s -t + +This script generate new build target in koji for SIGS. + +OPTIONS: + -d Distribution : 5 6 7 + -s SIG name : bananas, storage + -t DISTTAGS : "el7 el7.centos el7_0" +EOF +} + +optiond=false +options=false +optiont=false + +while getopts ":hd:s:t:" OPTION +do + case $OPTION in + h) + usage + exit 0 + ;; + d) + optiond=true + DISTS="${OPTARG}" + ;; + s) + options=true + SIGS="${OPTARG}" + ;; + t) + optiont=true + TAGS="${OPTARG}" + ;; + ?) + exit 0 + ;; + :) + echo "Option -$OPTARG requires an argument." + exit 1 + ;; + esac +done + +shift $(($OPTIND - 1)) + +if ! ( $optiond && $options && $optiont ) +then + usage + exit 0 +fi + +# Check if user is allowed to send command to koji and has 'admin' permission +KOJI=`which koji` +PERM=`$KOJI list-permissions --mine` +if [ "$PERM" != "admin" ] +then + echo "[ERROR] Koji misconfigure/missing admin privilege for creating SIG tags" + exit 1 +fi + +for DIST in $DISTS +do + + case $DIST in + 5) echo "* Checking distribution el$DIST configuration..."; ARCHES="i386 x86_64"; DEFAULT_DISTTAG="el5" + ;; + 6) echo "* Checking distribution el$DIST configuration..."; ARCHES="i686 x86_64"; DEFAULT_DISTTAG="el6" + ;; + 7) echo "* Checking distribution el$DIST configuration..."; ARCHES="x86_64"; DEFAULT_DISTTAG="el7.centos" + ;; + *) echo "It seems your distribution el${DIST} is unsupported" && continue + ;; + esac + + $KOJI list-tags | grep buildsys${DIST} &> /dev/null + [ $? -gt 0 ] && echo " -> [ERROR] Something is wrong buildsys${DIST} tag not found." && continue + + $KOJI list-external-repos | grep ^centos${DIST}-os &> /dev/null + [ $? -gt 0 ] && echo " -> [ERROR] centos${DIST}-os external repo not configured in koji." && continue + + $KOJI list-external-repos | grep ^centos${DIST}-updates &> /dev/null + [ $? -gt 0 ] && echo " -> [ERROR] centos${DIST}-updates external repo not configured in koji." && continue + + for SIG in $SIGS + do + echo " -> Checking $SIG config..." + $KOJI add-user $SIG &> /dev/null + [ $? -eq 0 ] && echo "Creating user : ${SIG}" + SIG="${SIG}${DIST}" + $KOJI list-tags | grep $SIG-testing &> /dev/null + [ $? -gt 0 ] && echo "Creating tag : ${SIG}-testing" && $KOJI add-tag $SIG-testing + $KOJI list-tags | grep $SIG-release &> /dev/null + [ $? -gt 0 ] && echo "Creating tag : ${SIG}-release" && $KOJI add-tag $SIG-release + + for TAG in $TAGS + do + $KOJI list-tags | grep $SIG-$TAG-build &> /dev/null + [ $? -eq 0 ] && echo " -> $SIG-$TAG target already exists. skipping." && continue + echo " -> creating $SIG-$TAG" + $KOJI add-tag --arches "$ARCHES" $SIG-$TAG-build + $KOJI add-target $SIG-$TAG $SIG-$TAG-build $SIG-testing + $KOJI add-external-repo --tag=$SIG-$TAG-build centos${DIST}-os + $KOJI add-external-repo --tag=$SIG-$TAG-build centos${DIST}-updates + $KOJI add-group $SIG-$TAG-build build + $KOJI add-group $SIG-$TAG-build srpm-build + $KOJI add-group-pkg $SIG-$TAG-build build bash bzip2 coreutils cpio diffutils redhat-release findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux-ng which buildsys-macros-$TAG tar buildsys-tools + $KOJI add-group-pkg $SIG-$TAG-build srpm-build bash buildsys-macros curl cvs redhat-release gnupg make redhat-rpm-config rpm-build shadow-utils buildsys-macros-$TAG tar buildsys-tools + $KOJI add-tag-inheritance --priority 1 $SIG-$TAG-build buildsys${DIST} + $KOJI add-tag-inheritance --priority 2 $SIG-$TAG-build $SIG-testing + $KOJI list-tagged buildsys${DIST} | grep buildsys-macros-$TAG &> /dev/null + if [ $? -gt 0 ] + then + if [ "x$TAG" != "x$DEFAULT_DISTTAG" ] + then + echo " -> [WARN] buildsys-macros-$TAG rpm not found. Please build it within koji." + [ -f $PWD/etc/buildsys.spec.template ] && echo " -> Generating buildsys-macros-$TAG.spec" + fi + fi + done + done +done diff --git a/scripts/etc/buildsys-macros-7.spec b/scripts/etc/buildsys-macros-7.spec new file mode 100644 index 0000000..c841840 --- /dev/null +++ b/scripts/etc/buildsys-macros-7.spec @@ -0,0 +1,40 @@ +%global _el_version el7 +%global _el_sub .buildsys + +Name: buildsys-macros-%{_el_version} +Summary: Macros for the Buildsystem +Version: 1.0 +Release: 0%{dist} +License: GPL +Group: Development/Buildsystem +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildArch: noarch + +%description +This particular package contains the macros needed for the buildsys for Centos el7. + +%prep + +%build + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/etc/rpm/ +VERSION=%{version} +printf %s%b "%" "rhel 7\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "dist .%{_el_version}\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "el7 1\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "__arch_install_post /usr/lib/rpm/check-buildroot\n" >> %{buildroot}/etc/rpm/macros.checkbuild + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +/etc/rpm/macros.disttag +/etc/rpm/macros.checkbuild + +%changelog +* Tue Jul 08 2014 Thomas 'alphacc' Oulevey +- Initial Centos build. + diff --git a/scripts/etc/buildsys-macros-el7.spec b/scripts/etc/buildsys-macros-el7.spec new file mode 100644 index 0000000..c841840 --- /dev/null +++ b/scripts/etc/buildsys-macros-el7.spec @@ -0,0 +1,40 @@ +%global _el_version el7 +%global _el_sub .buildsys + +Name: buildsys-macros-%{_el_version} +Summary: Macros for the Buildsystem +Version: 1.0 +Release: 0%{dist} +License: GPL +Group: Development/Buildsystem +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildArch: noarch + +%description +This particular package contains the macros needed for the buildsys for Centos el7. + +%prep + +%build + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/etc/rpm/ +VERSION=%{version} +printf %s%b "%" "rhel 7\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "dist .%{_el_version}\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "el7 1\n" >> %{buildroot}/etc/rpm/macros.disttag +printf %s%b "%" "__arch_install_post /usr/lib/rpm/check-buildroot\n" >> %{buildroot}/etc/rpm/macros.checkbuild + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +/etc/rpm/macros.disttag +/etc/rpm/macros.checkbuild + +%changelog +* Tue Jul 08 2014 Thomas 'alphacc' Oulevey +- Initial Centos build. +