Kouhei Sutou
null+****@clear*****
Mon Apr 28 15:02:49 JST 2014
Kouhei Sutou 2014-04-28 15:02:49 +0900 (Mon, 28 Apr 2014) New Revision: 4b0c907df5cdf590c5dbf63ecae072c41388b23d https://github.com/groonga/groonga/commit/4b0c907df5cdf590c5dbf63ecae072c41388b23d Message: Add a make target to upload packages to Launchpad Added files: packages/ubuntu/Makefile.am packages/ubuntu/upload.rb Modified files: .gitignore configure.ac packages/Makefile.am Modified: .gitignore (+2 -0) =================================================================== --- .gitignore 2014-04-25 14:25:43 +0900 (e9e8e64) +++ .gitignore 2014-04-28 15:02:49 +0900 (78f1a2d) @@ -112,6 +112,8 @@ cmake_install.cmake /packages/apt/groonga-keyring-*/ /packages/apt/groonga-keyring-*.tar.gz /packages/apt/tmp/ +/packages/ubuntu/tmp/ +/packages/ubuntu/*.tar.gz /configure.lineno /packages/rpm/*/*.spec /packages/yum/groonga.repo Modified: configure.ac (+9 -0) =================================================================== --- configure.ac 2014-04-25 14:25:43 +0900 (b7bc89c) +++ configure.ac 2014-04-28 15:02:49 +0900 (5880373) @@ -238,6 +238,7 @@ AC_CONFIG_FILES([ examples/dictionary/jmdict/Makefile packages/Makefile packages/apt/Makefile + packages/ubuntu/Makefile packages/rpm/Makefile packages/rpm/centos/Makefile packages/rpm/fedora/Makefile @@ -1371,6 +1372,13 @@ AC_ARG_WITH(rsync-path, [RSYNC_PATH="packages �� packages.groonga.org:public"]) AC_SUBST(RSYNC_PATH) +AC_ARG_WITH(launchpad-uploader-pgp-key, + [AS_HELP_STRING([--with-launchpad-uploader-pgp-key=KEY], + [specify PGP key UID to upload Groonga packages to Launchpad.])], + [LAUNCHPAD_UPLOADER_PGP_KEY="$withval"], + [LAUNCHPAD_UPLOADER_PGP_KEY=""]) +AC_SUBST(LAUNCHPAD_UPLOADER_PGP_KEY) + GPG_UID=m4_include(gpg_uid) AC_SUBST(GPG_UID) @@ -1480,6 +1488,7 @@ echo echo "For packages:" echo " rsync path: ${RSYNC_PATH}" +echo " Launchpad PGP key: ${LAUNCHPAD_UPLOADER_PGP_KEY}" echo " GPG UID: ${GPG_UID}" echo Modified: packages/Makefile.am (+1 -0) =================================================================== --- packages/Makefile.am 2014-04-25 14:25:43 +0900 (f61c5e7) +++ packages/Makefile.am 2014-04-28 15:02:49 +0900 (5ba46fd) @@ -1,5 +1,6 @@ SUBDIRS = \ apt \ + ubuntu \ rpm \ yum \ source \ Added: packages/ubuntu/Makefile.am (+24 -0) 100644 =================================================================== --- /dev/null +++ packages/ubuntu/Makefile.am 2014-04-28 15:02:49 +0900 (62986d1) @@ -0,0 +1,24 @@ +CODE_NAMES = precise,saucy,trusty +SOURCE = ../$(PACKAGE)-$(VERSION).tar.gz + +all: + +ensure-launchpad-configuration: + @if test -z "$(LAUNCHPAD_UPLOADER_PGP_KEY)"; then \ + echo "--with-launchpad-uploader-pgp-key configure option must be specified."; \ + false; \ + fi + +upload: source ensure-launchpad-configuration + ./upload.rb \ + --package '$(PACKAGE)' \ + --version '$(VERSION)' \ + --source-archive '$(SOURCE)' \ + --code-names '$(CODE_NAMES)' \ + --debian-directory '$(srcdir)/../debian/' \ + --pgp-sign-key '$(LAUNCHPAD_UPLOADER_PGP_KEY)' + +source: $(SOURCE) + +$(SOURCE): + ln -s $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz $(SOURCE) Added: packages/ubuntu/upload.rb (+135 -0) 100755 =================================================================== --- /dev/null +++ packages/ubuntu/upload.rb 2014-04-28 15:02:49 +0900 (15d18c8) @@ -0,0 +1,135 @@ +#!/usr/bin/env ruby +# +# Copyright(C) 2014 Kouhei Sutou <kou �� clear-code.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "optparse" +require "fileutils" +require "pathname" + +class Uploader + def initialize + @dput_configuration_name = "groonga-ppa" + end + + def run + ensure_dput_configuration + + parse_command_line! + + @code_names.each do |code_name| + upload(code_name) + end + end + + private + def ensure_dput_configuration + dput_cf_path = Pathname.new("~/.dput.cf").expand_path + if dput_cf_path.exist? + dput_cf_content = dput_cf_path.read + else + dput_cf_content = "" + end + dput_cf_content.each_line do |line| + return if line.chomp == "[#{@dput_configuration_name}]" + end + + dput_cf_path.open("w") do |dput_cf| + dput_cf.puts(dput_cf_content) + dput_cf.puts(<<-CONFIGURATION) +[#{@dput_configuration_name}] +fqdn = ppa.launchpad.net +method = ftp +incoming = ~groonga/ppa/ubuntu/ +login = anonymous +allow_unsigned_uploads = 0 + CONFIGURATION + end + end + + def parse_command_line! + + parser = OptionParser.new + parser.on("--package=NAME", + "The package name") do |name| + @package = name + end + parser.on("--version=VERSION", + "The version") do |version| + @version = version + end + parser.on("--source-archive=ARCHIVE", + "The source archive") do |source_archive| + @source_archive = Pathname.new(source_archive).expand_path + end + parser.on("--code-names=CODE_NAME1,CODE_NAME2,CODE_NAME3,...", Array, + "The target code names") do |code_names| + @code_names = code_names + end + parser.on("--debian-directory=DIRECTORY", + "The debian/ directory") do |debian_directory| + @debian_directory = Pathname.new(debian_directory).expand_path + end + parser.on("--pgp-sign-key=KEY", + "The PGP key to sign .changes and .dsc") do |pgp_sign_key| + @pgp_sign_key = pgp_sign_key + end + + parser.parse! + end + + def upload(code_name) + in_temporary_directory do + FileUtils.cp(@source_archive.to_s, + "#{@package}_#{@version}.orig.tar.gz") + run_command("tar", "xf", @source_archive.to_s) + directory_name = "#{@package}-#{@version}" + Dir.chdir(directory_name) do + FileUtils.cp_r(@debian_directory.to_s, "debian") + deb_version = "#{current_deb_version.succ}~#{code_name}1" + run_command("dch", + "--distribution", code_name, + "--newversion", deb_version, + "Build for #{code_name}.") + run_command("debuild", "-S", "-pgpg2", "-k#{@pgp_sign_key}") + run_command("dput", @dput_configuration_name, + "../#{@package}_#{deb_version}_source.changes") + end + end + end + + def current_deb_version + /\((.+)\)/ =~ File.read("debian/changelog").lines.first + $1 + end + + def in_temporary_directory + name = "tmp" + FileUtils.rm_rf(name) + FileUtils.mkdir_p(name) + Dir.chdir(name) do + yield + end + end + + def run_command(*command_line) + unless system(*command_line) + raise "failed to run command: #{command_line.join(' ')}" + end + end +end + +uploader = Uploader.new +uploader.run -------------- next part -------------- HTML����������������������������...Download