[Groonga-commit] groonga/groonga-normalizer-mysql at 38d9de6 [master] package apt: use Vagrant to build deb for Debian

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Sep 28 18:40:08 JST 2014


Kouhei Sutou	2014-09-28 18:40:08 +0900 (Sun, 28 Sep 2014)

  New Revision: 38d9de6da8ecc0c258602c73a50dfe56b9ed0135
  https://github.com/groonga/groonga-normalizer-mysql/commit/38d9de6da8ecc0c258602c73a50dfe56b9ed0135

  Message:
    package apt: use Vagrant to build deb for Debian
    
    We drop jessie and sid support because Vagrant boxes of them don't
    exist. :<

  Added files:
    packages/apt/Vagrantfile
    packages/apt/env.sh.in
  Removed files:
    packages/apt/build-in-chroot.sh
    packages/apt/groonga-normalizer-mysql-depended-packages
  Modified files:
    .gitignore
    configure.ac
    packages/apt/Makefile.am
    packages/apt/build-deb.sh

  Modified: .gitignore (+4 -1)
===================================================================
--- .gitignore    2014-07-31 22:33:09 +0900 (be709dc)
+++ .gitignore    2014-09-28 18:40:08 +0900 (196946c)
@@ -32,7 +32,10 @@ cmake_install.cmake
 /test/groonga-command-parser
 /test/tmp
 /packages/*.tar.gz
-/packages/apt/tmp/*
+/packages/apt/tmp/
+/packages/apt/env.sh
+/packages/apt/repositories/
+/packages/apt/.vagrant/
 /packages/ubuntu/tmp/
 /packages/yum/env.sh
 /packages/yum/tmp/*

  Modified: configure.ac (+1 -0)
===================================================================
--- configure.ac    2014-07-31 22:33:09 +0900 (a2e71e4)
+++ configure.ac    2014-09-28 18:40:08 +0900 (effb588)
@@ -150,6 +150,7 @@ AC_CONFIG_FILES([
   normalizers/Makefile
   packages/Makefile
   packages/apt/Makefile
+  packages/apt/env.sh
   packages/ubuntu/Makefile
   packages/rpm/Makefile
   packages/rpm/centos/Makefile

  Modified: packages/apt/Makefile.am (+23 -16)
===================================================================
--- packages/apt/Makefile.am    2014-07-31 22:33:09 +0900 (22fd7a1)
+++ packages/apt/Makefile.am    2014-09-28 18:40:08 +0900 (cb257b9)
@@ -1,11 +1,7 @@
 REPOSITORIES_PATH = repositories
-DISTRIBUTIONS = debian ubuntu
-CHROOT_BASE = /var/lib/chroot
+DISTRIBUTIONS = debian
 ARCHITECTURES = i386 amd64
-CODES = wheezy jessie unstable precise quantal saucy trusty
-KEYRING_PACKAGE = groonga-keyring
-KEYRING_VERSION = 2012.05.29
-KEYRING_BASE_NAME = $(KEYRING_PACKAGE)-$(KEYRING_VERSION)
+CODE_NAMES = wheezy
 
 all:
 
@@ -31,14 +27,14 @@ download: ensure-rsync-path
 	done
 
 sign-packages:
-	./sign-packages.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODES)'
+	./sign-packages.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODE_NAMES)'
 
 update-repository:
 	./update-repository.sh '$(PACKAGE_NAME)' '$(REPOSITORIES_PATH)/' \
-	  '$(ARCHITECTURES)' '$(CODES)'
+	  '$(ARCHITECTURES)' '$(CODE_NAMES)'
 
 sign-repository:
-	./sign-repository.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODES)'
+	./sign-repository.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODE_NAMES)'
 
 upload: ensure-rsync-path
 	for distribution in $(DISTRIBUTIONS); do		\
@@ -49,12 +45,23 @@ upload: ensure-rsync-path
 
 build: build-package-deb
 
-build-package-deb: source
-	./build-in-chroot.sh						\
-	  $(PACKAGE) $(VERSION) $(srcdir)/.. $(REPOSITORIES_PATH)/	\
-	  $(CHROOT_BASE) '$(ARCHITECTURES)' '$(CODES)'
+build-package-deb: prepare-build-package-deb
+	vagrant destroy --force
+	for architecture in $(ARCHITECTURES); do		\
+	  for code_name in $(CODE_NAMES); do			\
+	    id=debian-$$code_name-$$architecture;		\
+	    vagrant up $$id || exit 1;				\
+	    vagrant destroy --force $$id;			\
+	  done;							\
+	done
+
+prepare-build-package-deb: source env.sh
+	cp env.sh tmp/
+	rm -rf tmp/debian
+	cp -rp $(srcdir)/../debian tmp/
 
-source: ../$(PACKAGE)-$(VERSION).tar.gz
+source: tmp/$(PACKAGE)-$(VERSION).tar.gz
 
-../$(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
+	mkdir -p tmp
+	cp $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz $@

  Added: packages/apt/Vagrantfile (+27 -0) 100644
===================================================================
--- /dev/null
+++ packages/apt/Vagrantfile    2014-09-28 18:40:08 +0900 (97ba249)
@@ -0,0 +1,27 @@
+# -*- 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 => "debian-wheezy-i386",
+      :box_url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.6-i386_chef-provisionerless.box
+",
+    },
+    {
+      :id => "debian-wheezy-amd64",
+      :box_url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.6_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-deb.sh")
+    end
+  end
+end

  Modified: packages/apt/build-deb.sh (+43 -72)
===================================================================
--- packages/apt/build-deb.sh    2014-07-31 22:33:09 +0900 (28ee628)
+++ packages/apt/build-deb.sh    2014-09-28 18:40:08 +0900 (fdfc8f5)
@@ -2,85 +2,56 @@
 
 LANG=C
 
-PACKAGE=$(cat /tmp/build-package)
-USER_NAME=$(cat /tmp/build-user)
-VERSION=$(cat /tmp/build-version)
-DEPENDED_PACKAGES=$(cat /tmp/depended-packages)
-BUILD_SCRIPT=/tmp/build-deb-in-chroot.sh
-
 run()
 {
-    "$@"
-    if test $? -ne 0; then
-	echo "Failed $@"
-	exit 1
-    fi
+  "$@"
+  if test $? -ne 0; then
+    echo "Failed $@"
+    exit 1
+  fi
 }
 
-if [ ! -x /usr/bin/lsb_release ]; then
-    run apt-get update
-    run apt-get install -y lsb-release
-fi
+. /vagrant/tmp/env.sh
 
-distribution=$(lsb_release --id --short)
-code_name=$(lsb_release --codename --short)
+run apt-get update
+run apt-get install -y lsb-release
 
-security_list=/etc/apt/sources.list.d/security.list
-if [ ! -f "${security_list}" ]; then
-    case ${distribution} in
-	Debian)
-	    if [ "${code_name}" = "sid" ]; then
-		touch "${security_list}"
-	    else
-		cat <<EOF > "${security_list}"
-deb http://security.debian.org/ ${code_name}/updates main
-deb-src http://security.debian.org/ ${code_name}/updates main
-EOF
-	    fi
-	    ;;
-	Ubuntu)
-	    cat <<EOF > "${security_list}"
-deb http://security.ubuntu.com/ubuntu ${code_name}-security main restricted
-deb-src http://security.ubuntu.com/ubuntu ${code_name}-security main restricted
+distribution=$(lsb_release --id --short | tr 'A-Z' 'a-z')
+code_name=$(lsb_release --codename --short)
+case "${distribution}" in
+  debian)
+    component=main
+    run cat <<EOF > /etc/apt/sources.list.d/groonga.list
+deb http://packages.groonga.org/debian/ wheezy main
+deb-src http://packages.groonga.org/debian/ wheezy main
 EOF
-	    ;;
-    esac
-fi
-
-sources_list=/etc/apt/sources.list
-if [ "$distribution" = "Ubuntu" ] && \
-    ! (grep '^deb' $sources_list | grep -q universe); then
-    run sed -i'' -e 's/main$/main universe/g' $sources_list
-fi
-
-if [ ! -x /usr/bin/aptitude ]; then
     run apt-get update
-    run apt-get install -y aptitude
-fi
-run aptitude update -V -D
-run aptitude safe-upgrade -V -D -y
-
-run aptitude install -V -D -y devscripts ${DEPENDED_PACKAGES}
-run aptitude clean
-
-if ! id $USER_NAME >/dev/null 2>&1; then
-    run useradd -m $USER_NAME
-fi
-
-cat <<EOF > $BUILD_SCRIPT
-#!/bin/sh
-
-rm -rf build
-mkdir -p build
-
-cp /tmp/${PACKAGE}-${VERSION}.tar.gz build/${PACKAGE}_${VERSION}.orig.tar.gz
-cd build
-tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
-cd ${PACKAGE}-${VERSION}/
-cp -rp /tmp/${PACKAGE}-debian debian
+    run apt-get install -y --allow-unauthenticated groonga-keyring
+    run apt-get update
+    ;;
+  ubuntu)
+    component=universe
+    run apt-get -y install software-properties-common
+    run add-apt-repository -y universe
+    run add-apt-repository -y ppa:groonga/ppa
+    run apt-get update
+    ;;
+esac
+
+run apt-get install -V -y build-essential devscripts ${DEPENDED_PACKAGES}
+
+run mkdir -p build
+run cp /vagrant/tmp/${PACKAGE}-${VERSION}.tar.gz \
+  build/${PACKAGE}_${VERSION}.orig.tar.gz
+run cd build
+run tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
+run cd ${PACKAGE}-${VERSION}/
+run cp -rp /vagrant/tmp/debian debian
 # export DEB_BUILD_OPTIONS=noopt
-debuild -us -uc
-EOF
+run debuild -us -uc
+run cd -
 
-run chmod +x $BUILD_SCRIPT
-run su - $USER_NAME $BUILD_SCRIPT
+package_initial=$(echo "${PACKAGE}" | sed -e 's/\(.\).*/\1/')
+pool_dir="/vagrant/repositories/${distribution}/pool/${code_name}/${component}/${package_initial}/${PACKAGE}"
+run mkdir -p "${pool_dir}/"
+run cp *.tar.gz *.dsc *.deb "${pool_dir}/"

  Deleted: packages/apt/build-in-chroot.sh (+0 -134) 100755
===================================================================
--- packages/apt/build-in-chroot.sh    2014-07-31 22:33:09 +0900 (6697b1e)
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/sh
-
-if [ $# != 7 ]; then
-    echo "Usage: $0 PACKAGE VERSION SOURCE_DIR DESTINATION CHROOT_BASE ARCHITECTURES CODES"
-    echo " e.g.: $0 groonga 0.1.9 SOURCE_DIR repositories/ /var/lib/chroot 'i386 amd64' 'lenny unstable hardy karmic'"
-    exit 1
-fi
-
-PACKAGE=$1
-VERSION=$2
-SOURCE_DIR=$3
-DESTINATION=$4
-CHROOT_BASE=$5
-ARCHITECTURES=$6
-CODES=$7
-
-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
-    code_name=$2
-
-    run_sudo debootstrap --arch $architecture $code_name $base_dir
-
-    case $code_name in
-	lenny|squeeze|wheezy|unstable)
-	    run_sudo sed -i'' -e 's/us/jp/' $base_dir/etc/apt/sources.list
-	    ;;
-	*)
-	    run_sudo sed -i'' \
-		-e 's,http://archive,http://jp.archive,' \
-		-e 's/main$/main universe/' \
-		$base_dir/etc/apt/sources.list
-	    ;;
-    esac
-
-    run_sudo sh -c "echo >> /etc/fstab"
-    run_sudo sh -c "echo /sys ${base_dir}/sys none bind 0 0 >> /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}/sys
-    run_sudo mount ${base_dir}/dev
-    run_sudo mount ${base_dir}/dev/pts
-    run_sudo mount ${base_dir}/proc
-}
-
-build()
-{
-    architecture=$1
-    code_name=$2
-
-    target=${code_name}-${architecture}
-    base_dir=${CHROOT_BASE}/${target}
-    if [ ! -d $base_dir ]; then
-	run build_chroot $architecture $code_name
-    fi
-
-    case ${code_name} in
-	squeeze|wheezy|jessie|unstable)
-	    distribution=debian
-	    component=main
-	    ;;
-	*)
-	    distribution=ubuntu
-	    component=universe
-	    ;;
-    esac
-
-    source_dir=${SOURCE_DIR}
-    build_user=${PACKAGE}-build
-    build_user_dir=${base_dir}/home/$build_user
-    build_dir=${build_user_dir}/build
-    pool_base_dir=${DESTINATION}${distribution}/pool/${code_name}/${component}
-    package_initial=$(echo ${PACKAGE} | sed -e 's/\(.\).*/\1/')
-    pool_dir=${pool_base_dir}/${package_initial}/${PACKAGE}
-    run cp $source_dir/${PACKAGE}-${VERSION}.tar.gz \
-	${CHROOT_BASE}/$target/tmp/
-    run rm -rf ${CHROOT_BASE}/$target/tmp/${PACKAGE}-debian
-    run cp -rp $source_dir/debian/ \
-	${CHROOT_BASE}/$target/tmp/${PACKAGE}-debian
-    run echo $PACKAGE > ${CHROOT_BASE}/$target/tmp/build-package
-    run echo $VERSION > ${CHROOT_BASE}/$target/tmp/build-version
-    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 cp ${script_base_dir}/build-deb.sh \
-	${CHROOT_BASE}/$target/tmp/
-    run_sudo rm -rf $build_dir
-    run_sudo su -c "/usr/sbin/chroot ${CHROOT_BASE}/$target /tmp/build-deb.sh"
-    run mkdir -p $pool_dir
-    for path in $build_dir/*; do
-	[ -f $path ] && run cp -p $path $pool_dir/
-    done
-}
-
-for architecture in $ARCHITECTURES; do
-    for code_name in $CODES; do
-	if test "$parallel" = "yes"; then
-	    build $architecture $code_name &
-	else
-	    mkdir -p tmp
-	    build_log=tmp/build-$code_name-$architecture.log
-	    build $architecture $code_name 2>&1 | tee $build_log
-	fi;
-    done;
-done
-
-if test "$parallel" = "yes"; then
-    wait
-fi

  Added: packages/apt/env.sh.in (+8 -0) 100644
===================================================================
--- /dev/null
+++ packages/apt/env.sh.in    2014-09-28 18:40:08 +0900 (6fb3e84)
@@ -0,0 +1,8 @@
+PACKAGE=@PACKAGE@
+VERSION=@VERSION@
+DEPENDED_PACKAGES="
+debhelper
+autotools-dev
+pkg-config
+libgroonga-dev
+"

  Deleted: packages/apt/groonga-normalizer-mysql-depended-packages (+0 -4) 100644
===================================================================
--- packages/apt/groonga-normalizer-mysql-depended-packages    2014-07-31 22:33:09 +0900 (5bc35c3)
+++ /dev/null
@@ -1,4 +0,0 @@
-debhelper
-autotools-dev
-pkg-config
-libgroonga-dev
-------------- next part --------------
HTML����������������������������...
Descargar 



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