Correzioni su full path.

This commit is contained in:
Emiliano Vavassori 2023-01-07 22:52:11 +01:00
parent 0bea7a81bc
commit 8b5c87f801
1 changed files with 30 additions and 29 deletions

View File

@ -47,7 +47,7 @@ class Build(loaih.RemoteBuild):
self.portable = False
self.updatable = True
self.sign = True
self.remoterepo = False
self.repo_type = 'local'
self.remote_host = ''
self.remote_path = ''
self.storage_path = '/mnt/appimage'
@ -126,6 +126,17 @@ class Build(loaih.RemoteBuild):
if self.portable:
self.relative_path.append('portable')
# Fullpath might be intended two ways:
if self.repo_type == 'remote':
# Repository is remote
# we build full_path as it is absolute to the root of the
# storage_path.
self.full_path = '/'
if len(self.relative_path) >= 1:
self.full_path += str.join('/', self.relative_path)
else:
# Repository is local
# If it is remote or if it is local
fullpath_arr = self.storage_path.split('/')
# Joining relative path only if it is not null
if len(self.relative_path) > 0:
@ -138,30 +149,27 @@ class Build(loaih.RemoteBuild):
print("--- Check Phase ---")
# let's check here if we are on a remote repo or local.
if self.storage_path.startswith("http"):
# Final repository is remote
self.repo_type = 'remote'
else:
self.repo_type = 'local'
if len(self.appimagefilename) != 2:
self.calculate()
for arch in self.arch:
# First, check if by metadata the repo is remote or not.
if self.remoterepo or 'http' in self.storage_path:
self.remoterepo = True
if self.repo_type == 'remote':
# Remote storage. I have to query a remote site to know if it
# was already built.
name = self.appimagefilename[arch]
if len(self.relative_path) == 0:
path_arr = [ self.storage_path, '' ]
elif len(self.relative_path) == 1:
path_arr = [ self.storage_path, self.relative_path[0], '' ]
else:
path_arr = self.relative_path
path_arr.insert(0, self.storage_path)
path = str.join('/', path_arr)
url = self.storage_path.rstrip('/') + self.full_path + '/' + name
matching = []
try:
with urllib.request.urlopen(path) as url:
matching = etree.HTML(url.read()).xpath(
with urllib.request.urlopen(url) as response:
matching = etree.HTML(response.read()).xpath(
f"//a[contains(@href, '{name}')]/@href"
)
@ -436,17 +444,10 @@ class Build(loaih.RemoteBuild):
os.chdir(self.appnamedir)
# Two cases here: local and remote storage_path.
if self.remoterepo:
if self.repo_type == 'remote':
# Remote first.
# Build destination directory
if len(self.relative_path) == 0:
remotepath = str.join('/', [ self.remote_path, '' ])
elif len(self.relative_path) == 1:
remotepath = str.join('/', [ self.remote_path, self.relative_path[0], '' ])
else:
path_arr = self.relative_path
path_arr.insert(0, self.remote_path)
remotepath = str.join('/', path_arr)
remotepath = self.remote_path.rstrip('/') + self.full_path
try:
subprocess.run(
r"rsync -rlIvz --munge-links *.AppImage* " +