[Groonga-commit] groonga/groonga-gobject at cdbceef [master] yum: build with Vagrant instead of chroot

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jul 3 21:24:00 JST 2014


Kouhei Sutou	2014-07-03 21:24:00 +0900 (Thu, 03 Jul 2014)

  New Revision: cdbceef580c495f788fb02db51ec5d87c59a8e43
  https://github.com/groonga/groonga-gobject/commit/cdbceef580c495f788fb02db51ec5d87c59a8e43

  Message:
    yum: build with Vagrant instead of chroot
    
    Because it is difficult that creating chroot environment for Fedora.

  Added files:
    packages/yum/Vagrantfile
    packages/yum/env.sh.in
  Removed files:
    packages/yum/build-in-chroot.sh
    packages/yum/groonga-gobject-build-options
    packages/yum/groonga-gobject-depended-packages
  Modified files:
    .gitignore
    configure.ac
    packages/yum/Makefile.am
    packages/yum/build-rpm.sh

  Modified: .gitignore (+4 -0)
===================================================================
--- .gitignore    2014-07-03 20:27:22 +0900 (e5c1a47)
+++ .gitignore    2014-07-03 21:24:00 +0900 (3d1723d)
@@ -43,5 +43,9 @@ Makefile
 /packages/rpm/fedora/*.spec
 /packages/ubuntu/tmp/
 /packages/apt/repositories/
+/packages/apt/tmp/
 /packages/yum/repositories/
+/packages/yum/.vagrant/
+/packages/yum/tmp/
+/packages/yum/env.sh
 /packages/source/files/

  Modified: configure.ac (+1 -0)
===================================================================
--- configure.ac    2014-07-03 20:27:22 +0900 (95e56d7)
+++ configure.ac    2014-07-03 21:24:00 +0900 (531b25e)
@@ -161,6 +161,7 @@ AC_CONFIG_FILES([
   packages/apt/Makefile
   packages/ubuntu/Makefile
   packages/yum/Makefile
+  packages/yum/env.sh
   packages/rpm/Makefile
   packages/rpm/fedora/Makefile
   packages/rpm/fedora/groonga-gobject.spec

  Modified: packages/yum/Makefile.am (+13 -19)
===================================================================
--- packages/yum/Makefile.am    2014-07-03 20:27:22 +0900 (4f8ffb1)
+++ packages/yum/Makefile.am    2014-07-03 21:24:00 +0900 (aa24fef)
@@ -1,6 +1,5 @@
 REPOSITORIES_PATH = repositories
 DISTRIBUTIONS = fedora
-ARCHITECTURES = i386 x86_64
 CHROOT_BASE = /var/lib/chroot
 BASE_URL_PREFIX = http://packages.groonga.org
 HAVE_DEVELOPMENT_BRANCH = no
@@ -38,21 +37,9 @@ download: ensure-rsync-path
 	     $(REPOSITORIES_PATH)/$${distribution};	\
 	done
 
-build: build-in-chroot
-
-build-in-chroot: source
-	./build-in-chroot.sh			\
-	  $(PACKAGE)				\
-	  $(VERSION)				\
-	  $(top_builddir)/$(PACKAGE)		\
-	  ../rpm				\
-	  $(REPOSITORIES_PATH)/			\
-	  $(CHROOT_BASE)			\
-	  '$(ARCHITECTURES)'			\
-	  '$(DISTRIBUTIONS)'			\
-	  '$(HAVE_DEVELOPMENT_BRANCH)'		\
-	  '$(USE_RPMFORGE)'			\
-	  '$(USE_ATRPMS)'
+build: source specs
+	vagrant up
+	vagrant destroy --force
 
 ensure-public-key:
 	gpg --list-keys '$(GPG_UID)' > /dev/null ||			\
@@ -61,10 +48,17 @@ ensure-public-key:
 RPM-GPG-KEY-$(PACKAGE): ensure-public-key
 	gpg --armor --export '$(GPG_UID)' > $@
 
-source: ../$(PACKAGE)-$(VERSION).tar.gz
+source: tmp/$(PACKAGE)-$(VERSION).tar.gz
 
-../$(PACKAGE)-$(VERSION).tar.gz: $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz
-	ln -s $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz ../
+tmp/$(PACKAGE)-$(VERSION).tar.gz: $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz
+	cp $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz tmp/
 
 $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz:
 	cd $(abs_top_builddir) && $(MAKE) dist
+
+specs: tmp/fedora/$(PACKAGE).spec
+
+tmp/fedora/$(PACKAGE).spec: $(builddir)/../rpm/fedora/$(PACKAGE).spec
+	mkdir -p tmp/fedora
+	cp $(builddir)/../rpm/fedora/$(PACKAGE).spec tmp/fedora/
+

  Added: packages/yum/Vagrantfile (+26 -0) 100644
===================================================================
--- /dev/null
+++ packages/yum/Vagrantfile    2014-07-03 21:24:00 +0900 (a27e356)
@@ -0,0 +1,26 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  vms = [
+    {
+      :id => "fedora-20-i386",
+      :box_url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-20-i386_chef-provisionerless.box",
+    },
+    {
+      :id => "fedora-20-x86_64",
+      :box_url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-20_chef-provisionerless.box",
+    },
+  ]
+
+  vms.each do |vm|
+    config.vm.define(vm[:id]) do |node|
+      node.vm.box = vm[:id]
+      node.vm.box_url = vm[:box_url]
+      node.vm.provision(:shell, :path => "build-rpm.sh")
+    end
+  end
+end

  Deleted: packages/yum/build-in-chroot.sh (+0 -182) 100755
===================================================================
--- packages/yum/build-in-chroot.sh    2014-07-03 20:27:22 +0900 (f1ae789)
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/bin/sh
-
-if [ $# != 11 ]; then
-    echo "Usage: $0 PACKAGE VERSION SOURCE_BASE_NAME SPEC_DIR DESTINATION CHROOT_BASE ARCHITECTURES DISTRIBUTIONS HAVE_DEVELOPMENT_BRANCH USE_RPMFORGE USE_ATRPMS"
-    echo " e.g.: $0 milter-manager 1.1.1 ../milter-manager ../rpm repositories/ /var/lib/chroot 'i386 x86_64' 'fedora centos' yes no no"
-    exit 1
-fi
-
-PACKAGE=$1
-VERSION=$2
-SOURCE_BASE_NAME=$3
-SPEC_DIR=$4
-DESTINATION=$5
-CHROOT_BASE=$6
-ARCHITECTURES=$7
-DISTRIBUTIONS=$8
-HAVE_DEVELOPMENT_BRANCH=$9
-USE_RPMFORGE=$10
-USE_ATRPMS=$11
-
-PATH=/usr/local/sbin:/usr/sbin:$PATH
-
-script_base_dir=`dirname $0`
-
-if test "$PARALLEL" = "yes"; then
-    parallel="yes"
-else
-    parallel="no"
-fi
-
-run()
-{
-    "$@"
-    if test $? -ne 0; then
-	echo "Failed $@"
-	exit 1
-    fi
-}
-
-run_sudo()
-{
-    run sudo "$@"
-}
-
-build_chroot()
-{
-    architecture=$1
-    distribution_name=$2
-    distribution_version=$3
-
-    if [ $architecture = "x86_64" ]; then
-	rinse_architecture="amd64"
-        distribution_architecture=$architecture
-    else
-	rinse_architecture=$architecture
-	if [ "$distribution_name-$distribution_version" = "centos-5" ]; then
-	    distribution_architecture=$architecture
-	else
-	    distribution_architecture=i686
-	fi
-    fi
-
-    run_sudo mkdir -p ${base_dir}/etc/rpm
-    rpm_platform=${distribution_architecture}-${distribution}-linux
-    run_sudo sh -c "echo ${rpm_platform} > ${base_dir}/etc/rpm/platform"
-    run_sudo rinse \
-	--arch $rinse_architecture \
-	--distribution $distribution_name-$distribution_version \
-	--directory $base_dir
-    run_sudo rinse --arch $rinse_architecture --clean-cache
-
-    run_sudo sh -c "echo >> /etc/fstab"
-    run_sudo sh -c "echo /dev ${base_dir}/dev none bind 0 0 >> /etc/fstab"
-    run_sudo sh -c "echo devpts-chroot ${base_dir}/dev/pts devpts defaults 0 0 >> /etc/fstab"
-    run_sudo sh -c "echo proc-chroot ${base_dir}/proc proc defaults 0 0 >> /etc/fstab"
-    run_sudo mount ${base_dir}/dev
-    run_sudo mount ${base_dir}/dev/pts
-    run_sudo mount ${base_dir}/proc
-}
-
-build()
-{
-    architecture=$1
-    distribution=$2
-    distribution_version=$3
-
-    target=${distribution}-${distribution_version}-${architecture}
-    base_dir=${CHROOT_BASE}/${target}
-    if [ ! -d $base_dir ]; then
-	run build_chroot $architecture $distribution $distribution_version
-    fi
-
-    build_user=${PACKAGE}-build
-    build_user_dir=${base_dir}/home/${build_user}
-    rpm_base_dir=${build_user_dir}/rpmbuild
-    rpm_dir=${rpm_base_dir}/RPMS/${architecture}
-    if [ $distribution = "fedora" ]; then
-	if [ $architecture = "i386" ]; then
-	    rpm_dir=${rpm_base_dir}/RPMS/i686
-	fi
-    fi
-    srpm_dir=${rpm_base_dir}/SRPMS
-    pool_base_dir=${DESTINATION}${distribution}/${distribution_version}
-    if test "${HAVE_DEVELOPMENT_BRANCH}" = "yes"; then
-	minor_version=$(echo $VERSION | ruby -pe '$_.gsub!(/\A\d+\.(\d+)\..*/, "\\1")')
-	if test $(expr ${minor_version} % 2) -eq 0; then
-	    branch_name=stable
-	else
-	    branch_name=development
-	fi
-	pool_base_dir=${pool_base_dir}/${branch_name}
-    fi
-    binary_pool_dir=$pool_base_dir/$architecture/Packages
-    source_pool_dir=$pool_base_dir/source/SRPMS
-    if test -f ${SOURCE_BASE_NAME}-${VERSION}-*.src.rpm; then
-	run cp ${SOURCE_BASE_NAME}-${VERSION}-*.src.rpm \
-	    ${CHROOT_BASE}/$target/tmp/
-    else
-	run cp ${SOURCE_BASE_NAME}-${VERSION}.* \
-	    ${CHROOT_BASE}/$target/tmp/
-	run cp ${SPEC_DIR}/${distribution}/${PACKAGE}.spec \
-	    ${CHROOT_BASE}/$target/tmp/
-    fi
-    run echo $PACKAGE > ${CHROOT_BASE}/$target/tmp/build-package
-    run echo $VERSION > ${CHROOT_BASE}/$target/tmp/build-version
-    run echo $(basename ${SOURCE_BASE_NAME}) > \
-	${CHROOT_BASE}/$target/tmp/build-source-base-name
-    run echo $build_user > ${CHROOT_BASE}/$target/tmp/build-user
-    run cp ${script_base_dir}/${PACKAGE}-depended-packages \
-	${CHROOT_BASE}/$target/tmp/depended-packages
-    run echo $USE_RPMFORGE > ${CHROOT_BASE}/$target/tmp/build-use-rpmforge
-    run echo $USE_ATRPMS > ${CHROOT_BASE}/$target/tmp/build-use-atrpms
-    run cp ${script_base_dir}/${PACKAGE}-build-options \
-	${CHROOT_BASE}/$target/tmp/build-options
-    run cp ${script_base_dir}/build-rpm.sh ${CHROOT_BASE}/$target/tmp/
-    run_sudo rm -rf $rpm_dir $srpm_dir
-    run_sudo su -c "chroot ${CHROOT_BASE}/$target /tmp/build-rpm.sh"
-    run mkdir -p $binary_pool_dir
-    run mkdir -p $source_pool_dir
-    run cp -p $rpm_dir/*-${VERSION}* $binary_pool_dir
-    run cp -p $srpm_dir/*-${VERSION}* $source_pool_dir
-
-    dependencies_dir=${build_user_dir}/dependencies
-    dependencies_rpm_dir=${dependencies_dir}/RPMS
-    dependencies_srpm_dir=${dependencies_dir}/SRPMS
-    if [ -d "${dependencies_rpm_dir}" ]; then
-	run cp -p ${dependencies_rpm_dir}/* $binary_pool_dir
-    fi
-    if [ -d "${dependencies_srpm_dir}" ]; then
-	run cp -p ${dependencies_srpm_dir}/* $source_pool_dir
-    fi
-}
-
-for architecture in $ARCHITECTURES; do
-    for distribution in $DISTRIBUTIONS; do
-	case $distribution in
-	    fedora)
-		distribution_versions="20"
-		;;
-	    centos)
-		if [ -n "$CENTOS_VERSIONS" ]; then
-		    distribution_versions="$CENTOS_VERSIONS"
-		else
-		    distribution_versions="5 6"
-		fi
-		;;
-	esac
-	for distribution_version in $distribution_versions; do
-	    if test "$parallel" = "yes"; then
-		build $architecture $distribution $distribution_version &
-	    else
-		mkdir -p tmp
-		build_log=tmp/build-$distribution-$distribution_version-$architecture.log
-		build $architecture $distribution $distribution_version 2>&1 | tee $build_log
-	    fi;
-	done;
-    done;
-done
-
-if test "$parallel" = "yes"; then
-    wait
-fi

  Modified: packages/yum/build-rpm.sh (+18 -105)
===================================================================
--- packages/yum/build-rpm.sh    2014-07-03 20:27:22 +0900 (58897d9)
+++ packages/yum/build-rpm.sh    2014-07-03 21:24:00 +0900 (53b3254)
@@ -1,16 +1,6 @@
 #!/bin/sh
 
-LANG=C
-
-PACKAGE=$(cat /tmp/build-package)
-VERSION=$(cat /tmp/build-version)
-SOURCE_BASE_NAME=$(cat /tmp/build-source-base-name)
-USER_NAME=$(cat /tmp/build-user)
-DEPENDED_PACKAGES=$(cat /tmp/depended-packages)
-USE_RPMFORGE=$(cat /tmp/build-use-rpmforge)
-USE_ATRPMS=$(cat /tmp/build-use-atrpms)
-BUILD_OPTIONS=$(cat /tmp/build-options)
-BUILD_SCRIPT=/tmp/build-${PACKAGE}.sh
+set -x
 
 run()
 {
@@ -21,110 +11,33 @@ run()
     fi
 }
 
-if ! id $USER_NAME >/dev/null 2>&1; then
-    run useradd -m $USER_NAME
-fi
+rpmbuild_options=
+
+. /vagrant/env.sh
 
-yum_options=
+run yum groupinstall -y "Development Tools"
+run yum install -y rpm-build rpmdevtools tar ${DEPENDED_PACKAGES}
 
-distribution=$(cut -d ' ' -f 1 /etc/redhat-release | tr 'A-Z' 'a-z')
+distribution=$(cut -d " " -f 1 /etc/redhat-release | tr "A-Z" "a-z")
 if grep -q Linux /etc/redhat-release; then
-    distribution_version=$(cut -d ' ' -f 4 /etc/redhat-release)
+    distribution_version=$(cut -d " " -f 4 /etc/redhat-release)
 else
-    distribution_version=$(cut -d ' ' -f 3 /etc/redhat-release)
-fi
-if ! rpm -q ${distribution}-release > /dev/null 2>&1; then
-    packages_dir=/var/cache/yum/core/packages
-    release_rpm=${distribution}-release-${distribution_version}-*.rpm
-    run rpm -Uvh --force ${packages_dir}/${release_rpm}
-    run rpm -Uvh --force ${packages_dir}/ca-certificates-*.rpm
-fi
-
-if test "$USE_RPMFORGE" = "yes"; then
-    if ! rpm -q rpmforge-release > /dev/null 2>&1; then
-	architecture=$(cut -d '-' -f 1 /etc/rpm/platform)
-	rpmforge_url=http://packages.sw.be/rpmforge-release
-	rpmforge_rpm_base=rpmforge-release-0.5.2-2.el5.rf.${architecture}.rpm
-	wget $rpmforge_url/$rpmforge_rpm_base
-	run rpm -Uvh $rpmforge_rpm_base
-	rm $rpmforge_rpm_base
-	sed -i'' -e 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo
-    fi
-    yum_options="$yum_options --enablerepo=rpmforge"
+    distribution_version=$(cut -d " " -f 3 /etc/redhat-release)
 fi
 
-if test "$USE_ATRPMS" = "yes"; then
-    case "$(cat /etc/redhat-release)" in
-	CentOS*)
-	    repository_label=CentOS
-	    repository_prefix=el
-	    ;;
-	*)
-	    repository_label=Fedora
-	    repository_prefix=f
-	    ;;
-    esac
-    cat <<EOF > /etc/yum.repos.d/atrpms.repo
-[atrpms]
-name=${repository_label} \$releasever - \$basearch - ATrpms
-baseurl=http://dl.atrpms.net/${repository_prefix}\$releasever-\$basearch/atrpms/stable
-gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
-gpgcheck=1
-enabled=0
-EOF
-    yum_options="$yum_options --enablerepo=atrpms"
-fi
-
-rpmbuild_options="${BUILD_OPTIONS}"
-
-run yum update ${yum_options} -y
-run yum install ${yum_options} -y rpm-build rpmdevtools tar ${DEPENDED_PACKAGES}
-run yum clean ${yum_options} packages
-
 # for debug
 # rpmbuild_options="$rpmbuild_options --define 'optflags -O0 -ggdb3'"
 
-cat <<EOF > $BUILD_SCRIPT
-#!/bin/sh
+cd
 
-if [ -x /usr/bin/rpmdev-setuptree ]; then
-    rm -rf .rpmmacros
-    rpmdev-setuptree
-else
-    cat <<EOM > ~/.rpmmacros
-%_topdir \$HOME/rpmbuild
-EOM
-
-    mkdir -p rpmbuild/SOURCES
-    mkdir -p rpmbuild/SPECS
-    mkdir -p rpmbuild/BUILD
-    mkdir -p rpmbuild/RPMS
-    mkdir -p rpmbuild/SRPMS
-fi
-
-if test -f /tmp/${SOURCE_BASE_NAME}-$VERSION-*.src.rpm; then
-    if ! rpm -Uvh /tmp/${SOURCE_BASE_NAME}-$VERSION-*.src.rpm; then
-        cd rpmbuild/SOURCES
-        rpm2cpio /tmp/${SOURCE_BASE_NAME}-$VERSION-*.src.rpm | cpio -id
-        if ! yum info tcp_wrappers-devel >/dev/null 2>&1; then
-            sed -i'' -e 's/tcp_wrappers-devel/tcp_wrappers/g' ${PACKAGE}.spec
-        fi
-        if ! yum info libdb-devel >/dev/null 2>&1; then
-            sed -i'' -e 's/libdb-devel/db4-devel/g' ${PACKAGE}.spec
-        fi
-        sed -i'' -e 's/BuildArch: noarch//g' ${PACKAGE}.spec
-        mv ${PACKAGE}.spec ../SPECS/
-        cd
-    fi
-else
-    cp /tmp/${SOURCE_BASE_NAME}-$VERSION.* rpmbuild/SOURCES/
-    cp /tmp/${PACKAGE}.spec rpmbuild/SPECS/
-fi
+run rm -rf .rpmmacros
+run rpmdev-setuptree
 
-chmod o+rx . rpmbuild rpmbuild/RPMS rpmbuild/SRPMS
+run cp /vagrant/tmp/${PACKAGE}-${VERSION}.* rpmbuild/SOURCES/
+run cp /vagrant/tmp/${distribution}/${PACKAGE}.spec rpmbuild/SPECS/
 
-rpmbuild -ba ${rpmbuild_options} rpmbuild/SPECS/${PACKAGE}.spec
-EOF
+run rpmbuild -ba ${rpmbuild_options} rpmbuild/SPECS/${PACKAGE}.spec
 
-run chmod +x $BUILD_SCRIPT
-run su - $USER_NAME $BUILD_SCRIPT
+repository="/vagrant/repositories/${distribution}/${distribution_version}"
+run cp rpmbuild/RPMS/$(arch)/* ${repository}/$(arch)/Packages/
+run cp rpmbuild/SRPMS/* ${repository}/source/SRPMS/

  Added: packages/yum/env.sh.in (+3 -0) 100644
===================================================================
--- /dev/null
+++ packages/yum/env.sh.in    2014-07-03 21:24:00 +0900 (757129f)
@@ -0,0 +1,3 @@
+PACKAGE=@PACKAGE@
+VERSION=@VERSION@
+DEPENDED_PACKAGES="intltool gcc-c++ groonga-devel gobject-introspection-devel"

  Deleted: packages/yum/groonga-gobject-build-options (+0 -0) 100644
===================================================================
--- packages/yum/groonga-gobject-build-options    2014-07-03 20:27:22 +0900 (e69de29)
+++ /dev/null

  Deleted: packages/yum/groonga-gobject-depended-packages (+0 -8) 100644
===================================================================
--- packages/yum/groonga-gobject-depended-packages    2014-07-03 20:27:22 +0900 (da290f2)
+++ /dev/null
@@ -1,8 +0,0 @@
-intltool
-libtool
-gcc
-gcc-c++
-make
-tar
-groonga-devel
-gobject-introspection-devel
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index