null+****@clear*****
null+****@clear*****
2010年 9月 2日 (木) 14:52:29 JST
Kouhei Sutou 2010-09-02 05:52:29 +0000 (Thu, 02 Sep 2010) New Revision: ecdd33e4ad7f6c49dfc5e0c89d4b2a398a0b0c44 Log: add yum related files. Added files: yum/Makefile.am yum/build-in-chroot.sh yum/build-repository-rpm.sh yum/build-rpm.sh yum/gpg-public-key.sh yum/gpg-uid.sh yum/groonga-depended-packages yum/groonga-repository.spec yum/sign-rpm.sh yum/update-repository.sh Copied files: rpm/centos/groonga.spec.in (from groonga.spec.in) Modified files: .gitignore Makefile.am configure.ac Renamed files: rpm/fedora/groonga.spec.in (from groonga.spec.in) Modified: .gitignore (+1 -0) =================================================================== --- .gitignore 2010-09-02 05:26:14 +0000 (3ad4d13) +++ .gitignore 2010-09-02 05:52:29 +0000 (e5edb60) @@ -70,3 +70,4 @@ version.sh /apt/ubuntu/*.db /apt/ubuntu/*.conf /configure.lineno +/rpm/*/*.spec Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2010-09-02 05:26:14 +0000 (1da15ab) +++ Makefile.am 2010-09-02 05:52:29 +0000 (b891b67) @@ -1,5 +1,5 @@ AUTOMAKE_OPTIONS = 1.9.7 -SUBDIRS = lib modules src examples test apt data resource doc +SUBDIRS = lib modules src examples test apt yum data resource doc #dist_data_DATA = EXTRA_DIST = bindings version-gen.sh pkginclude_HEADERS = groonga.h Modified: configure.ac (+3 -1) =================================================================== --- configure.ac 2010-09-02 05:26:14 +0000 (9d66cf6) +++ configure.ac 2010-09-02 05:52:29 +0000 (a5f5ef5) @@ -94,6 +94,7 @@ AC_CONFIG_FILES([Makefile modules/suggest/Makefile examples/Makefile apt/Makefile + yum/Makefile data/Makefile data/munin/Makefile resource/Makefile @@ -682,7 +683,8 @@ AC_DEFINE_UNQUOTED(GRN_CONFIG_PATH, ["$GRN_CONFIG_PATH"], [Default command line option configuration file.]) AC_OUTPUT([ - groonga.spec + rpm/centos/groonga.spec + rpm/fedora/groonga.spec groonga.pc ]) Copied: rpm/centos/groonga.spec.in (+0 -0) 100% =================================================================== Renamed: rpm/fedora/groonga.spec.in (+0 -0) 100% =================================================================== Added: yum/Makefile.am (+48 -0) 100644 =================================================================== --- /dev/null +++ yum/Makefile.am 2010-09-02 05:52:29 +0000 (189761f) @@ -0,0 +1,48 @@ +DISTRIBUTIONS = fedora centos +ARCHITECTURES = i386 x86_64 +CHROOT_BASE = /var/lib/chroot + +all: + +release: remove-existing-packages build sign update upload + +remove-existing-packages: + for distribution in $(DISTRIBUTIONS); do \ + find $${distribution} -name "*.rpm" -delete; \ + done + +ensure-rsync-path: + @if test -z "$(RSYNC_PATH)"; then \ + echo "--with-rsync-path configure option must be specified."; \ + false; \ + fi + +download: ensure-rsync-path + for distribution in $(DISTRIBUTIONS); do \ + rsync -avz $(RSYNC_PATH)/$${distribution}/ $${distribution}; \ + done + +sign: + ./sign-rpm.sh '$(DISTRIBUTIONS)' + +update: + ./update-repository.sh '$(DISTRIBUTIONS)' + +upload: ensure-rsync-path + for distribution in $(DISTRIBUTIONS); do \ + rsync -avz --exclude .gitignore \ + $${distribution}/ $(SERVER_PATH)/$${distribution}; \ + done + +build: build-in-chroot build-repository-rpm + +build-in-chroot: + ./build-in-chroot.sh \ + $(PACKAGE) $(VERSION) $(CHROOT_BASE) \ + '$(ARCHITECTURES)' '$(DISTRIBUTIONS)' + +build-repository-rpm: RPM-GPG-KEY-groonga + ./build-repository-rpm.sh $(PACKAGE) '$(DISTRIBUTIONS)' + +RPM-GPG-KEY-groonga: + ./gpg-public-key.sh > $@ Added: yum/build-in-chroot.sh (+123 -0) 100755 =================================================================== --- /dev/null +++ yum/build-in-chroot.sh 2010-09-02 05:52:29 +0000 (b621f34) @@ -0,0 +1,123 @@ +#!/bin/sh + +if [ $# != 5 ]; then + echo "Usage: $0 PACKAGE VERSION CHROOT_BASE ARCHITECTURES DISTRIBUTIONS" + echo " e.g.: $0 groonga 1.1.1 /var/lib/chroot 'i386 x86_64' 'fedora centos'" + exit 1 +fi + +PACKAGE=$1 +VERSION=$2 +CHROOT_BASE=$3 +ARCHITECTURES=$4 +DISTRIBUTIONS=$5 + +PATH=/usr/local/sbin:/usr/sbin:$PATH + +script_base_dir=`dirname $0` + +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 + case $distribution_name in + fedora) + distribution_architecture=i686 + ;; + *) + distribution_architecture=$architecture + ;; + esac + 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 + + case $distribution in + fedora) + distribution_version=13 + ;; + centos) + distribution_version=5 + ;; + esac + target=${distribution}-${distribution_version}-${architecture} + base_dir=${CHROOT_BASE}/${target} + if [ ! -d $base_dir ]; then + run build_chroot $architecture $distribution $distribution_version + fi + + source_dir=${script_base_dir}/.. + build_user=${PACKAGE}-build + build_user_dir=${base_dir}/home/${build_user} + rpm_base_dir=${build_user_dir}/rpm + rpm_dir=${rpm_base_dir}/RPMS/${architecture} + srpm_dir=${rpm_base_dir}/SRPMS + pool_base_dir=${distribution}/${distribution_version} + binary_pool_dir=$pool_base_dir/$architecture/Packages + source_pool_dir=$pool_base_dir/source/SRPMS + run cp $source_dir/${PACKAGE}-${VERSION}.tar.gz \ + ${CHROOT_BASE}/$target/tmp/ + run cp $source_dir/rpm/${distribution}/${PACKAGE}.spec \ + ${CHROOT_BASE}/$target/tmp/ + 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-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 +} + +for architecture in $ARCHITECTURES; do + for distribution in $DISTRIBUTIONS; do + build $architecture $distribution + done; +done Added: yum/build-repository-rpm.sh (+69 -0) 100755 =================================================================== --- /dev/null +++ yum/build-repository-rpm.sh 2010-09-02 05:52:29 +0000 (bb707ca) @@ -0,0 +1,69 @@ +#!/bin/sh + +script_base_dir=`dirname $0` + +if [ $# != 2 ]; then + echo "Usage: $0 PACKAGE DISTRIBUTIONS" + echo " e.g.: $0 groonga 'fedora centos'" + exit 1 +fi + +PACKAGE=$1 +DISTRIBUTIONS=$2 + +run() +{ + "$@" + if test $? -ne 0; then + echo "Failed $@" + exit 1 + fi +} + +rpm_base_dir=$HOME/rpm + +if [ ! -f ~/.rpmmacros ]; then + run cat <<EOM > ~/.rpmmacros +%_topdir $rpm_base_dir +EOM +fi + +run mkdir -p $rpm_base_dir/SOURCES +run mkdir -p $rpm_base_dir/SPECS +run mkdir -p $rpm_base_dir/BUILD +run mkdir -p $rpm_base_dir/RPMS +run mkdir -p $rpm_base_dir/SRPMS + +for distribution in ${DISTRIBUTIONS}; do + case $distribution in + fedora) + distribution_label=Fedora + ;; + centos) + distribution_label=CentOS + ;; + esac + repo=${PACKAGE}.repo + run cat <<EOR > $repo +[groonga] +name=groonga for $distribution_label \$releasever - \$basearch +baseurl=http://groonga.sourceforge.net/$distribution/\$releasever/\$basearch/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-groonga +metadata_expire=7d +EOR + run tar cfz $rpm_base_dir/SOURCES/${PACKAGE}-repository.tar.gz \ + -C ${script_base_dir} ${repo} RPM-GPG-KEY-${PACKAGE} + run cp ${script_base_dir}/${PACKAGE}-repository.spec $rpm_base_dir/SPECS/ + + run rpmbuild -ba $rpm_base_dir/SPECS/${PACKAGE}-repository.spec + + top_dir=$script_base_dir/$distribution + + run mkdir -p $top_dir + run cp -p $rpm_base_dir/RPMS/noarch/${PACKAGE}-repository-* $top_dir + run cp -p $rpm_base_dir/SRPMS/${PACKAGE}-repository-* $top_dir + + run cp -p ${script_base_dir}/RPM-GPG-KEY-${PACKAGE} $top_dir +done Added: yum/build-rpm.sh (+61 -0) 100755 =================================================================== --- /dev/null +++ yum/build-rpm.sh 2010-09-02 05:52:29 +0000 (5f66837) @@ -0,0 +1,61 @@ +#!/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-${PACKAGE}.sh + +run() +{ + "$@" + if test $? -ne 0; then + echo "Failed $@" + exit 1 + fi +} + +distribution=$(cut -d ' ' -f 1 /etc/redhat-release | tr 'A-Z' 'a-z') +distribution_version=$(cut -d ' ' -f 3 /etc/redhat-release) +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 + +run yum update -y +run yum install -y rpm-build tar ${DEPENDED_PACKAGES} +run yum clean packages + +if ! id $USER_NAME >/dev/null 2>&1; then + run useradd -m $USER_NAME +fi + +cat <<EOF > $BUILD_SCRIPT +#!/bin/sh + +if [ ! -f ~/.rpmmacros ]; then + cat <<EOM > ~/.rpmmacros +%_topdir \$HOME/rpm +EOM +fi + +mkdir -p rpm/SOURCES +mkdir -p rpm/SPECS +mkdir -p rpm/BUILD +mkdir -p rpm/RPMS +mkdir -p rpm/SRPMS + +cp /tmp/${PACKAGE}-$VERSION.tar.gz rpm/SOURCES/ +cp /tmp/${PACKAGE}.spec rpm/SPECS/ + +chmod o+rx . rpm rpm/RPMS rpm/SRPMS + +rpmbuild -ba rpm/SPECS/${PACKAGE}.spec +EOF + +run chmod +x $BUILD_SCRIPT +run su - $USER_NAME $BUILD_SCRIPT Added: yum/gpg-public-key.sh (+5 -0) 100755 =================================================================== --- /dev/null +++ yum/gpg-public-key.sh 2010-09-02 05:52:29 +0000 (f21020f) @@ -0,0 +1,5 @@ +#!/bin/sh + +script_base_dir=`dirname $0` + +gpg -a --export `$script_base_dir/gpg-uid.sh` Added: yum/gpg-uid.sh (+3 -0) 100755 =================================================================== --- /dev/null +++ yum/gpg-uid.sh 2010-09-02 05:52:29 +0000 (6c90091) @@ -0,0 +1,3 @@ +#!/bin/sh + +gpg --list-secret-keys | grep uid | sed -e 's/^uid *//' | tail -1 Added: yum/groonga-depended-packages (+6 -0) 100644 =================================================================== --- /dev/null +++ yum/groonga-depended-packages 2010-09-02 05:52:29 +0000 (c31bfc2) @@ -0,0 +1,6 @@ +intltool +libtool +gcc +make +libedit-devel +mecab-devel Added: yum/groonga-repository.spec (+46 -0) 100644 =================================================================== --- /dev/null +++ yum/groonga-repository.spec 2010-09-02 05:52:29 +0000 (19f6d94) @@ -0,0 +1,46 @@ +Summary: groonga RPM repository configuration +Name: groonga-repository +Version: 1.0.0 +Release: 0 +License: LGPLv2 +URL: http://packages.groonga.org/ +Source: groonga-repository.tar.gz +Group: System Environment/Base +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) +BuildArchitectures: noarch + +%description +groonga RPM repository configuration. + +%prep +%setup -c + +%build + +%install +%{__rm} -rf %{buildroot} + +%{__install} -Dp -m0644 RPM-GPG-KEY-groonga %{buildroot}%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-groonga + +%{__install} -Dp -m0644 groonga.repo %{buildroot}%{_sysconfdir}/yum.repos.d/groonga.repo + +%clean +%{__rm} -rf %{buildroot} + +%post +rpm -q gpg-pubkey-1c837f31-4a2b9c3f &>/dev/null || \ + rpm --import %{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-groonga + +%files +%defattr(-, root, root, 0755) +%doc * +%pubkey RPM-GPG-KEY-groonga +%dir %{_sysconfdir}/yum.repos.d/ +%config(noreplace) %{_sysconfdir}/yum.repos.d/groonga.repo +%dir %{_sysconfdir}/pki/rpm-gpg/ +%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-groonga + +%changelog +* Thu Sep 02 2010 Kouhei Sutou <kou****@clear*****> +- (1.0.0-0) +- Initial package. Added: yum/sign-rpm.sh (+26 -0) 100755 =================================================================== --- /dev/null +++ yum/sign-rpm.sh 2010-09-02 05:52:29 +0000 (def9196) @@ -0,0 +1,26 @@ +#!/bin/sh + +script_base_dir=`dirname $0` + +if [ $# != 1 ]; then + echo "Usage: $0 DISTRIBUTIONS" + echo " e.g.: $0 'fedora centos'" + exit 1 +fi + +DISTRIBUTIONS=$1 + +run() +{ + "$@" + if test $? -ne 0; then + echo "Failed $@" + exit 1 + fi +} + +for distribution in ${DISTRIBUTIONS}; do + for rpm in $script_base_dir/${distribution}/*/*/*/*.rpm; do + run rpm -D "_gpg_name `$script_base_dir/gpg-uid.sh`" --resign $rpm + done; +done Added: yum/update-repository.sh (+29 -0) 100755 =================================================================== --- /dev/null +++ yum/update-repository.sh 2010-09-02 05:52:29 +0000 (0f3a175) @@ -0,0 +1,29 @@ +#!/bin/sh + +script_base_dir=`dirname $0` + +if [ $# != 1 ]; then + echo "Usage: $0 DISTRIBUTIONS" + echo " e.g.: $0 'fedora centos'" + exit 1 +fi + +DISTRIBUTIONS=$1 + +run() +{ + "$@" + if test $? -ne 0; then + echo "Failed $@" + exit 1 + fi +} + +for distribution in ${DISTRIBUTIONS}; do + for dir in $script_base_dir/${distribution}/*/*; do + run createrepo $dir + done; + + run $script_base_dir/gpg-public-key.sh > \ + $script_base_dir/${distribution}/RPM-GPG-KEY-groonga; +done