Created a download folder to speed up rebuilds.

This commit is contained in:
Emiliano Vavassori 2022-03-20 01:34:37 +01:00
parent a059e27a20
commit 39ad25ab2f
1 changed files with 12 additions and 4 deletions

View File

@ -7,11 +7,12 @@ import tempfile, os, sys, glob, subprocess, shutil
class Build(object):
LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ]
def __init__(self, query, arch, url):
def __init__(self, query, arch, url, downloaddir = '/var/tmp/downloads'):
"""Build all versions that can be found in the indicated repo."""
self.__query__ = query
self.__arch__ = arch
self.__url__ = url
self.__downloaddir__ = downloaddir
# Creating a tempfile
self.__builddir__ = tempfile.mkdtemp()
@ -36,8 +37,14 @@ class Build(object):
self.__appname__ = main_arr[0]
self.__version__ = main_arr[1]
os.chdir(self.__builddir__)
os.makedirs(self.__downloaddir__, exist_ok = True)
os.chdir(self.__downloaddir__)
for archive in self.__tarballs__:
# If the archive is already there, do not do anything.
if os.path.exists(os.path.join(self.__downloaddir__, archive)):
print("Archive %s is already there! Sweet")
continue
# Download the archive
try:
urllib.request.urlretrieve(self.__url__ + archive, archive)
@ -100,13 +107,14 @@ class Build(object):
# Unpacking the tarballs
for archive in buildtarballs:
subprocess.run("tar xzf ../%s" % archive, shell=True)
subprocess.run("tar xzf {folder}/{archive}".format(folder = self.__downloaddir__, archive = archive), shell=True)
os.chdir(self.appimagedir)
# At this point, let's decompress the deb packages
subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True)
# Changing desktop file
subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True)
subprocess.run("sed -i -e ", shell=True)
subprocess.run("find . -name '*startcenter.png' -path '*hicolor*48x48*' -exec cp {} . \;", shell=True)
@ -139,7 +147,7 @@ class Build(object):
os.chdir(self.appnamedir)
for deb in glob.glob(self.appnamedir + '/*.deb'):
os.remove(deb)
shutil.rmtree(self.appimagedir)
subprocess.run("find . -type d -maxdepth 1 -exec rm -rf {} \+", shell=True)
os.makedirs(self.appimagedir)
def checksums(self):