Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: register gcs as a service
- Loading branch information
Showing
15 changed files
with
1,013 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| /node_modules | ||
| /node_modules/ | ||
| /test/tmp | ||
| /packages/*.tar.gz | ||
| /packages/all-in-one/tmp/ | ||
| /packages/all-in-one/*.tar.gz | ||
| /packages/yum/repositories/ | ||
| /packages/apt/repositories/ | ||
| /packages/apt/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| REPOSITORIES_PATH = repositories | ||
| DISTRIBUTIONS = debian ubuntu | ||
| CHROOT_BASE = /var/lib/chroot | ||
| ARCHITECTURES = i386 amd64 | ||
| CODES = squeeze wheezy unstable lucid oneiric precise | ||
|
|
||
| PACKAGE = gcs | ||
| VERSION = $(shell ruby -rjson -e 'print JSON.parse(ARGF.read)["version"]' ../../package.json) | ||
| RSYNC_PATH = packages@packages.groonga.org:public | ||
| GPG_UID = 45499429 | ||
|
|
||
| srcdir = . | ||
|
|
||
| all: | ||
|
|
||
| release: download build sign-packages update-repository sign-repository upload | ||
|
|
||
| download: | ||
| for distribution in $(DISTRIBUTIONS); do \ | ||
| rsync -avz --progress --delete \ | ||
| $(RSYNC_PATH)/$${distribution} \ | ||
| ${REPOSITORIES_PATH}/; \ | ||
| done | ||
|
|
||
| sign-packages: ensure-public-key | ||
| ./sign-packages.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODES)' | ||
|
|
||
| update-repository: | ||
| ./update-repository.sh '$(PACKAGE_NAME)' '$(REPOSITORIES_PATH)/' \ | ||
| '$(ARCHITECTURES)' '$(CODES)' | ||
|
|
||
| sign-repository: ensure-public-key | ||
| ./sign-repository.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODES)' | ||
|
|
||
| upload: | ||
| for distribution in $(DISTRIBUTIONS); do \ | ||
| (cd $(REPOSITORIES_PATH)/$${distribution}; \ | ||
| rsync -avz --progress --delete \ | ||
| dists pool $(RSYNC_PATH)/$${distribution}); \ | ||
| done | ||
|
|
||
| build: build-package-deb | ||
|
|
||
| build-package-deb: source | ||
| ./build-in-chroot.sh \ | ||
| $(PACKAGE) $(VERSION) $(srcdir)/.. $(REPOSITORIES_PATH)/ \ | ||
| $(CHROOT_BASE) '$(ARCHITECTURES)' '$(CODES)' | ||
|
|
||
| source: ../$(PACKAGE)-$(VERSION).tar.gz | ||
|
|
||
| ../$(PACKAGE)-$(VERSION).tar.gz: | ||
| rm -rf $(PACKAGE)-$(VERSION) | ||
| mkdir -p $(PACKAGE)-$(VERSION) | ||
| cp -a ../../.npmignore $(PACKAGE)-$(VERSION) | ||
| cp -a ../../MIT-LICENSE $(PACKAGE)-$(VERSION) | ||
| cp -a ../../README.md $(PACKAGE)-$(VERSION) | ||
| cp -a ../../bin/ $(PACKAGE)-$(VERSION) | ||
| cp -a ../../client_templates/ $(PACKAGE)-$(VERSION) | ||
| cp -a ../../examples/ $(PACKAGE)-$(VERSION) | ||
| cp -a ../../lib/ $(PACKAGE)-$(VERSION) | ||
| cp -a ../../npm-shrinkwrap.json $(PACKAGE)-$(VERSION) | ||
| cp -a ../../package.json $(PACKAGE)-$(VERSION) | ||
| cp -a ../../test/ $(PACKAGE)-$(VERSION) | ||
| cp -a ../../tools/ $(PACKAGE)-$(VERSION) | ||
| cp -a ../../views/ $(PACKAGE)-$(VERSION) | ||
| tar cvzf ../$(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) | ||
| rm -rf $(PACKAGE)-$(VERSION) | ||
|
|
||
| ensure-public-key: | ||
| gpg --list-keys '$(GPG_UID)' > /dev/null || \ | ||
| gpg --keyserver keyserver.ubuntu.com --recv-key '$(GPG_UID)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| #!/bin/sh | ||
|
|
||
| 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 [ ! -x /usr/bin/lsb_release ]; then | ||
| run apt-get update | ||
| run apt-get install -y lsb-release | ||
| fi | ||
|
|
||
| distribution=$(lsb_release --id --short) | ||
| code_name=$(lsb_release --codename --short) | ||
|
|
||
| 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 | ||
| 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 | ||
|
|
||
| groonga_list=/etc/apt/sources.list.d/groonga.list | ||
| if [ ! -f "${groonga_list}" ]; then | ||
| case ${distribution} in | ||
| Debian) | ||
| component=main | ||
| ;; | ||
| Ubuntu) | ||
| component=universe | ||
| ;; | ||
| esac | ||
| downcased_distribtion=$(echo ${distribution} | tr A-Z a-z) | ||
| run cat <<EOF | run tee ${groonga_list} | ||
| deb http://packages.groonga.org/${downcased_distribtion}/ ${code_name} ${component} | ||
| deb-src http://packages.groonga.org/${downcased_distribtion}/ ${code_name} ${component} | ||
| EOF | ||
| apt-get update -V | ||
| run apt-get -V -y --allow-unauthenticated install groonga-keyring | ||
| 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 ruby | ||
|
|
||
| eval $(dpkg-architecture) | ||
| if [ -n "${DEB_HOST_MULTIARCH}" ]; then | ||
| ruby -i'' -pe '$_.gsub!(/\/lib\//, "/lib/*/")' \ | ||
| /tmp/${PACKAGE}-debian/*.install | ||
| fi | ||
|
|
||
| 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 | ||
| # export DEB_BUILD_OPTIONS=noopt | ||
| debuild -us -uc | ||
| EOF | ||
|
|
||
| run chmod +x $BUILD_SCRIPT | ||
| run su - $USER_NAME $BUILD_SCRIPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| #!/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 | ||
| lenny|squeeze|wheezy|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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| libgroonga-dev | ||
| pkg-config | ||
| npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/bin/sh | ||
|
|
||
| script_base_dir=`dirname $0` | ||
|
|
||
| if [ $# != 3 ]; then | ||
| echo "Usage: $0 GPG_UID DESITINATION CODES" | ||
| echo " e.g.: $0 'F10399C0' repositories/ 'lenny unstable hardy karmic'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| GPG_UID=$1 | ||
| DESTINATION=$2 | ||
| CODES=$3 | ||
|
|
||
| run() | ||
| { | ||
| "$@" | ||
| if test $? -ne 0; then | ||
| echo "Failed $@" | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| for code_name in ${CODES}; do | ||
| case ${code_name} in | ||
| lenny|squeeze|wheezy|unstable) | ||
| distribution=debian | ||
| ;; | ||
| *) | ||
| distribution=ubuntu | ||
| ;; | ||
| esac | ||
|
|
||
| base_directory=${DESTINATION}${distribution} | ||
| debsign -pgpg2 --re-sign -k${GPG_UID} \ | ||
| $(find ${base_directory} -name '*.dsc' -or -name '*.changes') & | ||
| if [ "${PARALLEL}" != "yes" ]; then | ||
| wait | ||
| fi | ||
| done | ||
|
|
||
| wait |
Oops, something went wrong.