From fd227c528d803af7b20e98dada9a27f48a1d5c41 Mon Sep 17 00:00:00 2001 From: Miron Cuperman Date: Fri, 27 Nov 2009 18:32:22 -0800 Subject: [PATCH] fix lib path issue, add slash to gem source --- .gitignore | 1 + bin/gitian | 17 +++++------------ gem/gitian.gemspec | 2 +- gem/lib/commands/gitian.rb | 1 + lib/gitian-package-build | 4 ++-- lib/gitian-package-new | 4 ++-- lib/gitian-release-build | 9 +++++---- lib/gitian-release-upload | 4 ++-- lib/gitian_shell_complete.py | 14 -------------- lib/gitian_shell_complete.pyc | Bin 892 -> 0 bytes lib/gitian_util.py | 30 ++++++++++++++++++++++++++++++ 11 files changed, 49 insertions(+), 37 deletions(-) delete mode 100644 lib/gitian_shell_complete.py delete mode 100644 lib/gitian_shell_complete.pyc create mode 100644 lib/gitian_util.py diff --git a/.gitignore b/.gitignore index 4389985..8394f1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *-stamp *.substvars *.log +*.pyc diff --git a/bin/gitian b/bin/gitian index 25acda2..1fabc43 100755 --- a/bin/gitian +++ b/bin/gitian @@ -3,24 +3,17 @@ import subprocess import sys import os +sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), "../lib")) +from gitian_util import * -def find_command(command): +def check_command(command): if commands.get(command) is None: print>>sys.stderr, "usage: %s CMD\ntry: %s help"%(prog, prog) exit(1) - command = "gitian-" + command - for dir in [os.path.join(progdir, "../lib"), "/usr/lib/gitian"]: - if os.access(os.path.join(dir, command), os.F_OK): - found_dir = dir - break - if found_dir is None: - print>>sys.stderr, "installation problem - could not find subcommand" - exit(1) - return os.path.join(found_dir, command) + return find_command(command) -args = sys.argv +args = sys.argv[:] prog = args.pop(0) -progdir = os.path.dirname(prog) if len(args) < 1: print>>sys.stderr, "usage: %s CMD\n\ntry:\n %s help\nor:\n %s help CMD"%(prog, prog, prog) diff --git a/gem/gitian.gemspec b/gem/gitian.gemspec index dc882e1..7d9f646 100644 --- a/gem/gitian.gemspec +++ b/gem/gitian.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version= s.authors = ["Miron Cuperman"] - s.date = %q{2009-11-26} + s.date = %q{2009-11-27} s.description = %q{Add gitian sub-commands to the gem command} s.email = %q{info.deb@nginz.org} s.files = [ diff --git a/gem/lib/commands/gitian.rb b/gem/lib/commands/gitian.rb index 4534028..c5b492c 100644 --- a/gem/lib/commands/gitian.rb +++ b/gem/lib/commands/gitian.rb @@ -42,6 +42,7 @@ def gitian(insecure, release) url = get_one_optional_argument || URL url = url + release + url += "/" if url[-1,1] != "/" sources = Gem.sources sources.reject! { |s| s == url || s == oldurl } diff --git a/lib/gitian-package-build b/lib/gitian-package-build index c5f8312..41b36f3 100755 --- a/lib/gitian-package-build +++ b/lib/gitian-package-build @@ -8,14 +8,14 @@ import git import yaml import fnmatch import shutil -import gitian_shell_complete +from gitian_util import * from optparse import OptionParser #from gettext import gettext as _ if __name__ == "__main__": parser = OptionParser() parser.prog = "gitian package-build" - gitian_shell_complete.apply(parser) + optparser_extend(parser) parser.add_option ("-d", "--dest", dest="dest", help="Destination directory (default ROOT/dist)") diff --git a/lib/gitian-package-new b/lib/gitian-package-new index 94bff57..ad87c24 100755 --- a/lib/gitian-package-new +++ b/lib/gitian-package-new @@ -4,7 +4,7 @@ import os import sys -import gitian_shell_complete +from gitian_util import * from optparse import OptionParser USAGE = """Usage: gitian package-new NAME REPOS-URL REPOS-COMMIT @@ -13,7 +13,7 @@ USAGE = """Usage: gitian package-new NAME REPOS-URL REPOS-COMMIT if __name__ == "__main__": parser = OptionParser() parser.prog = "gitian package-build" - gitian_shell_complete.apply(parser) + optparser_extend(parser) (options, args) = parser.parse_args() if len(args) != 3: diff --git a/lib/gitian-release-build b/lib/gitian-release-build index cad8016..86d3677 100755 --- a/lib/gitian-release-build +++ b/lib/gitian-release-build @@ -8,14 +8,14 @@ import yaml import fnmatch import glob import shutil -import gitian_shell_complete +from gitian_util import * from optparse import OptionParser #from gettext import gettext as _ if __name__ == "__main__": parser = OptionParser() parser.prog = "gitian release-build" - gitian_shell_complete.apply(parser) + optparser_extend(parser) parser.add_option ("-c", "--clean", default=False, action="store_true", dest="clean", help="Clean dist directory first") @@ -38,7 +38,8 @@ if __name__ == "__main__": if options.dryrun: print dsc continue - res = os.system("gitian-package-build --dest %s %s"% ('stage', dsc)) + res = os.system(find_command("package-build") + " --dest %s %s"% + ('stage', dsc)) if res != 0: print >> sys.stderr, "build failed for %s"% (dsc) sys.exit(1) @@ -48,7 +49,7 @@ if __name__ == "__main__": for gem_file in glob.glob('stage/rubygems/gems/*.gem'): new_file = os.path.join('dist/rubygems/gems', os.path.basename(gem_file)) - os.system('gitian-gem-signer "%s" "%s"'%(gem_file, new_file)) + os.system(find_command("gem-signer") + ' "%s" "%s"'%(gem_file, new_file)) if (os.access('dist/rubygems', os.F_OK)): res = os.system("gem generate_index --directory dist/rubygems") diff --git a/lib/gitian-release-upload b/lib/gitian-release-upload index 8d97ce8..ff4bb29 100755 --- a/lib/gitian-release-upload +++ b/lib/gitian-release-upload @@ -9,14 +9,14 @@ import commands import re import tempfile import shutil -import gitian_shell_complete +from gitian_util import * from optparse import OptionParser #from gettext import gettext as _ if __name__ == "__main__": parser = OptionParser() parser.prog = "gitian release-upload" - gitian_shell_complete.apply(parser) + optparser_extend(parser) parser.add_option ("-u", "--url", dest="url", help="Target rsync URL, or previously used URL if omitted") diff --git a/lib/gitian_shell_complete.py b/lib/gitian_shell_complete.py deleted file mode 100644 index ac8cdd2..0000000 --- a/lib/gitian_shell_complete.py +++ /dev/null @@ -1,14 +0,0 @@ -from optparse import SUPPRESS_HELP - -def shell_complete(option, opt, value, parser): - for option in parser.option_list: - for flag in str(option).split('/'): - if option.help != SUPPRESS_HELP: - print "(-)%s[%s]"%(flag, option.help) - exit(0) - -def apply(parser): - parser.add_option ("", "--shell-complete", action="callback", - callback=shell_complete, - help=SUPPRESS_HELP - ) diff --git a/lib/gitian_shell_complete.pyc b/lib/gitian_shell_complete.pyc deleted file mode 100644 index f9a819ea264aa57188a126e2c3f5e59c686ca833..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 892 zcmb_a(N5bi6g^JbGP*H!59{OJKtWoTA3)P2KtlpmRja8IQx&C2pa!=Iv5P<|PwbEO zCHs~Az;><+n)XhVdu(6(-g|tmfBoL+{@m}K=6L!-j$deYk5KSexCV^Exq>PJ`~c1a z6rrDlC|VdtZ64Ks_(h5{w?i0z8xBXu<8gX&d^XHm^vEHxLzZZC%F16FyGM=rp zDas}>diLZ>Eh(5ZuNJi_UHPfLcW;^Cf3N2*Zm2Fgs!!{w4=NW0#6$z%1!=J;>$}X} zQZ)9HKgBBAZ~-2JaHFBzaNr2AJwhD&lJPSUf5|Kt{oE_==b16HEWaL!evuGzT|!nA z=|-o~8!o++{>_YJ_a#-4x>;SDdr54CJ=A;EQ3L-PJVz4oZSgENeBSZcKNc_4AkpJs SQ57pweir$yyq#XKz4aF|5502$ diff --git a/lib/gitian_util.py b/lib/gitian_util.py new file mode 100644 index 0000000..b781646 --- /dev/null +++ b/lib/gitian_util.py @@ -0,0 +1,30 @@ +import sys +import os +from optparse import SUPPRESS_HELP + +def shell_complete(option, opt, value, parser): + for option in parser.option_list: + for flag in str(option).split('/'): + if option.help != SUPPRESS_HELP: + print "(-)%s[%s]"%(flag, option.help) + exit(0) + +def optparser_extend(parser): + parser.add_option ("", "--shell-complete", action="callback", + callback=shell_complete, + help=SUPPRESS_HELP + ) + +def find_command(command): + command = "gitian-" + command + progdir = os.path.dirname(sys.argv[0]) + found_dir = None + for dir in [os.path.join(progdir, "../lib"), "/usr/lib/gitian"]: + if os.access(os.path.join(dir, command), os.F_OK): + found_dir = dir + break + if found_dir is None: + print>>sys.stderr, "installation problem - could not find subcommand %s"%(command) + exit(1) + return os.path.join(found_dir, command) +