summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-04-12 21:08:38 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-04-12 21:08:38 +0200
commite9d5f6cb61fb9ef997213b64b8086574f591f3a5 (patch)
treef9826a4a937864f1a77107b072ec98c41d5ba249
parentd8cb5c7007ddd9f8801d2267edba3486347e7266 (diff)
downloadrockbox-e9d5f6cb61fb9ef997213b64b8086574f591f3a5.tar.gz
rockbox-e9d5f6cb61fb9ef997213b64b8086574f591f3a5.zip
gitscraper: support compressing the sources as 7z.
The Rockbox source code uses 7z for its archive for size reasons. Add support for compressing as 7z (by calling the 7z command line utility) so it can be used for generating Rockbox source archives. Change-Id: I26097ff61ff183e5ddc07b2c4473f90dc0700178
-rwxr-xr-xutils/common/gitscraper.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/utils/common/gitscraper.py b/utils/common/gitscraper.py
index cfa017aed0..a6b6cf39a6 100755
--- a/utils/common/gitscraper.py
+++ b/utils/common/gitscraper.py
@@ -159,7 +159,8 @@ def scrape_files(repo, treehash, filelist, dest=""):
159 return dest 159 return dest
160 160
161 161
162def archive_files(repo, treehash, filelist, basename, tmpfolder=""): 162def archive_files(repo, treehash, filelist, basename, tmpfolder="",
163 archive="tbz"):
163 '''Archive list of files into tarball. 164 '''Archive list of files into tarball.
164 @param repo Path to repository root. 165 @param repo Path to repository root.
165 @param treehash Hash identifying the tree. 166 @param treehash Hash identifying the tree.
@@ -169,15 +170,35 @@ def archive_files(repo, treehash, filelist, basename, tmpfolder=""):
169 basename inside of the archive as well (i.e. no tarbomb). 170 basename inside of the archive as well (i.e. no tarbomb).
170 @param tmpfolder Folder to put intermediate files in. If no folder is given 171 @param tmpfolder Folder to put intermediate files in. If no folder is given
171 a temporary one will get used. 172 a temporary one will get used.
173 @param archive Type of archive to create. Supported values are "tbz" and
174 "7z". The latter requires the 7z binary available in the
175 system's path.
172 @return Output filename. 176 @return Output filename.
173 ''' 177 '''
174 print "Archiving files from repository"
175 178
176 workfolder = scrape_files(repo, treehash, filelist, tmpfolder) 179 if tmpfolder == "":
177 outfile = basename + ".tar.bz2" 180 temp_remove = True
178 tf = tarfile.open(outfile, "w:bz2") 181 tmpfolder = tempfile.mkdtemp()
179 tf.add(workfolder, basename) 182 else:
180 tf.close() 183 temp_remove = False
184 workfolder = scrape_files(repo, treehash, filelist,
185 os.path.join(tmpfolder, basename))
186 if basename is "":
187 return ""
188 print "Archiving files from repository"
189 if archive == "7z":
190 outfile = basename + ".7z"
191 output = subprocess.Popen(["7z", "a",
192 os.path.join(os.getcwd(), basename + ".7z"), basename],
193 cwd=tmpfolder, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
194 output.communicate()
195 else:
196 outfile = basename + ".tar.bz2"
197 tf = tarfile.open(outfile, "w:bz2")
198 tf.add(workfolder, basename)
199 tf.close()
181 if tmpfolder != workfolder: 200 if tmpfolder != workfolder:
182 shutil.rmtree(workfolder) 201 shutil.rmtree(workfolder)
202 if temp_remove:
203 shutil.rmtree(tmpfolder)
183 return outfile 204 return outfile