summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-21 21:59:35 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-22 16:34:32 +0100
commit78f8116cf07f9849c8034d1c3e10a00adb88aeb7 (patch)
tree0c86b7643037d70a98e76734830145a1e4ac1a96
parent105be007b4771dc108fb74ac589576a144b4e3af (diff)
downloadfedora-packager-78f8116cf07f9849c8034d1c3e10a00adb88aeb7.tar.gz
fedora-packager-78f8116cf07f9849c8034d1c3e10a00adb88aeb7.tar.xz
fedora-packager-78f8116cf07f9849c8034d1c3e10a00adb88aeb7.zip
local ops: Basic 'fedpkg local-init' code
'fedpkg local-init' initalizes a local git repo to use with (most) fedpkg commands.
-rwxr-xr-xsrc/fedpkg.py22
-rw-r--r--src/pyfedpkg/__init__.py26
2 files changed, 43 insertions, 5 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index a62755f..3f5dd59 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -828,6 +828,16 @@ def update(args):
os.unlink('clog')
+def local_init(args):
+ # $ spectool --gf libgaiagraphics.spec
+ # $ : "verify that all $(spectool --lf libgaiagraphics.spec) files are present"
+ # "if not, abort and have the user provide them"
+ # $ spectool --lf libgaiagraphics.spec | sed 's,.*/,,' | xargs md5sum > sources
+ # $ spectool --lf libgaiagraphics.spec | sed 's,.*/,,' | sed 's,^,/,' > .gitignore
+ # $ git add .gitignore libgaiagraphics.spec sources
+ pass
+
+
def verrel(args):
try:
mymodule = pyfedpkg.PackageModule(args.path)
@@ -1078,6 +1088,18 @@ packages will be built sequentially.
help = 'Use md5 checksums (for older rpm hosts)')
parser_local.set_defaults(command = local)
+ # Initialize local git repo for local usage
+ parser_init = subparsers.add_parser('local-init',
+ help = 'Local git repo init for local usage',
+ description="""Locally
+ initialize and set up a git
+ repo such that we can locally
+ run most of the other fedpkg
+ commands as if it was a clone
+ of a proper Fedora package's
+ git repo.""")
+ parser_init.set_defaults(command = local_init)
+
# Build in mock
parser_mockbuild = subparsers.add_parser('mockbuild',
help = 'Local test build using mock')
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index e04191a..d916454 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -999,8 +999,13 @@ class PackageModule:
localbranch = self.repo.active_branch.name
except TypeError, e:
raise FedpkgError('Repo in inconsistent state: %s' % e)
- merge = self.repo.git.config('--get', 'branch.%s.merge' % localbranch)
- return(merge.split('/')[2])
+ try:
+ merge = self.repo.git.config('--get', 'branch.%s.merge' % localbranch)
+ return(merge.split('/')[2])
+ except git.errors.GitCommandError, e:
+ if localbranch == 'master':
+ return 'master'
+ raise e # re-raise the GitCommandError
def _findmasterbranch(self):
"""Find the right "fedora" for master"""
@@ -1023,8 +1028,19 @@ class PackageModule:
# Sort the list
fedoras.sort()
- # Start with the last item, strip the f, add 1, return it.
- return(int(fedoras[-1].strip('f')) + 1)
+ if fedoras:
+ # Start with the last item, strip the f, add 1, return it.
+ return(int(fedoras[-1].strip('f')) + 1)
+ else:
+ # FIXME: How to determine this?
+ # $ koji list-targets \
+ # | awk '($1 ~ /^dist-f[0-9]+$/) { print $1; }' \
+ # | sed -n '$s/^dist-f//p'
+
+ # And caching that result using "git config --global
+ # fedpkg.cached.master-branch", with a max age of, say, 24
+ # hours?
+ return 15
def _getlocalarch(self):
"""Get the local arch as defined by rpm"""
@@ -1385,7 +1401,7 @@ class PackageModule:
'serverca': '~/.koji/serverca.crt',
'authtype': None
}
- # Process the configs in order, global, user, then any option passed
+ # Process the conigs in order, global, user, then any option passed
configs = ['/etc/koji.conf', os.path.expanduser('~/.koji/config')]
if kojiconfig:
configs.append(os.path.join(kojiconfig))