Skip to content

Commit

Permalink
fix lib path issue, add slash to gem source
Browse files Browse the repository at this point in the history
  • Loading branch information
Miron Cuperman committed Nov 28, 2009
1 parent a068cff commit fd227c5
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*-stamp
*.substvars
*.log
*.pyc
17 changes: 5 additions & 12 deletions bin/gitian
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gem/gitian.gemspec
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions gem/lib/commands/gitian.rb
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions lib/gitian-package-build
Expand Up @@ -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)")
Expand Down
4 changes: 2 additions & 2 deletions lib/gitian-package-new
Expand Up @@ -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
Expand All @@ -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:
Expand Down
9 changes: 5 additions & 4 deletions lib/gitian-release-build
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions lib/gitian-release-upload
Expand Up @@ -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")
Expand Down
14 changes: 0 additions & 14 deletions lib/gitian_shell_complete.py

This file was deleted.

Binary file removed lib/gitian_shell_complete.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions 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)

0 comments on commit fd227c5

Please sign in to comment.