Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit c5df41b

Browse files
committed
planex-patchqueue: archive patchqueue repositories directly, rather than extracting patches
Signed-off-by: Euan Harris <euan.harris@citrix.com>
1 parent a2a7b33 commit c5df41b

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

planex/cmd/clone.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,21 @@ def main(argv=None):
6868
credentials=args.credentials)
6969

7070
else:
71-
if pin.base:
71+
print "Cloning %s" % pin.url
72+
util.makedirs(os.path.dirname(checkoutdir))
73+
clone(pin.url, checkoutdir, pin.commitish)
74+
75+
if pin.base is not None:
7276
base_reponame = os.path.basename(pin.base).rsplit(".git")[0]
7377
base_checkoutdir = os.path.join(args.repos, base_reponame)
7478
print "Cloning %s" % pin.base
7579
util.makedirs(os.path.dirname(base_checkoutdir))
7680
clone(pin.base, base_checkoutdir, pin.base_commitish)
7781

78-
print "Cloning %s" % pin.url
79-
reponame = os.path.basename(pin.url).rsplit(".git")[0]
80-
checkoutdir = os.path.join(args.repos, reponame)
81-
clone(pin.url, checkoutdir, pin.commitish)
82-
8382
# Symlink the patchqueue
8483
patch_path = os.path.join(base_checkoutdir, ".git/patches")
85-
util.makedirs(patch_path)
86-
8784
link_path = os.path.relpath(checkoutdir, patch_path)
88-
85+
util.makedirs(patch_path)
8986
os.symlink(os.path.join(link_path, pin.patchqueue),
9087
os.path.join(patch_path, pin.base_commitish))
9188

@@ -94,14 +91,10 @@ def main(argv=None):
9491
fileh = open(status, 'w')
9592
fileh.close()
9693

94+
# Push patchqueue
9795
subprocess.check_call(['guilt', 'push', '--all'],
9896
cwd=base_checkoutdir)
9997

100-
else:
101-
print "Cloning %s" % pin.url
102-
util.makedirs(os.path.dirname(checkoutdir))
103-
clone(pin.url, checkoutdir, pin.commitish)
104-
10598

10699
if __name__ == "__main__":
107100
main()

planex/cmd/patchqueue.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import argparse
77
import os
88
import shutil
9+
import sys
910
import tempfile
1011
from urlparse import urlparse
1112

@@ -61,20 +62,18 @@ def assemble_extra_sources(tmpdir, link, sources, patches):
6162
Assemble the non-patchqueue sources in the working directory.
6263
"""
6364
if link.specfile is not None:
64-
source_path = os.path.join(link.url, ".git/patches", link.specfile)
65+
source_path = os.path.join(link.url, link.specfile)
6566
copy_to_tmpdir(tmpdir, source_path, link.specfile)
6667

6768
if link.sources is not None:
6869
for source in sources:
69-
source_path = os.path.join(link.url, ".git/patches",
70-
link.sources, source)
70+
source_path = os.path.join(link.url, link.sources, source)
7171
dest_path = os.path.join(link.sources, source)
7272
copy_to_tmpdir(tmpdir, source_path, dest_path)
7373

7474
if link.patches is not None:
7575
for patch in patches:
76-
source_path = os.path.join(link.url, ".git/patches",
77-
link.patches, patch)
76+
source_path = os.path.join(link.url, link.patches, patch)
7877
dest_path = os.path.join(tmpdir, link.patches, patch)
7978
copy_to_tmpdir(tmpdir, source_path, dest_path)
8079

@@ -99,12 +98,17 @@ def main(argv=None):
9998
reponame = os.path.basename(url.path).rsplit(".git")[0]
10099
repo = os.path.join(args.repos, reponame)
101100

101+
if repo.endswith(".pg"):
102+
util.makedirs(os.path.dirname(args.tarball))
103+
git.archive(repo, end_tag, args.tarball)
104+
sys.exit(0)
105+
102106
# Start tag is based on the version specified in the spec file,
103107
# but the tag name may be slightly different (v1.2.3 rather than 1.2.3)
104108
# If the link file does not list a spec file, assume that there is one in
105109
# the usual place
106110
if link.specfile is not None:
107-
spec_path = os.path.join(link.url, ".git/patches", link.specfile)
111+
spec_path = os.path.join(repo, link.specfile)
108112
else:
109113
basename = os.path.splitext(os.path.basename(args.link))[0]
110114
spec_path = os.path.join("SPECS", "%s.spec" % basename)

planex/git.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,18 @@ def describe(repo, treeish="HEAD"):
5858
return description[matchlen:].replace('-', '+')
5959

6060

61-
def archive(repo, commit_hash, prefix, target_dir):
61+
def archive(repo, commit_hash, output, prefix=None):
6262
"""
6363
Archive a git repo at a given commit with a specified version prefix.
64-
Returns the path to a tar.gz to be used as a source for building an RPM.
64+
Returns the path to an archive to be used as a source for building an RPM.
6565
"""
6666
dotgitdir = dotgitdir_of_path(repo)
6767

68-
prefix = "%s-%s" % (os.path.basename(repo), prefix)
69-
path = os.path.join(target_dir, "%s.tar" % prefix)
70-
71-
run(["git", "--git-dir=%s" % dotgitdir, "archive", commit_hash,
72-
"--prefix=%s/" % prefix, "-o", path])
73-
run(["gzip", "--no-name", "-f", path])
74-
75-
return path + ".gz"
68+
cmd = ["git", "--git-dir=%s" % dotgitdir, "archive", commit_hash,
69+
"-o", output]
70+
if prefix is not None:
71+
cmd += ["--prefix=%s-%s/" % (os.path.basename(repo), prefix)]
72+
run(cmd)
7673

7774

7875
def tags(repo):

0 commit comments

Comments
 (0)