Compare commits
4 Commits
0bea7a81bc
...
b087e85ec5
Author | SHA1 | Date | |
---|---|---|---|
b087e85ec5 | |||
3a9f13594c | |||
1f83db6105 | |||
8b5c87f801 |
@ -10,7 +10,6 @@ import re
|
|||||||
import shlex
|
import shlex
|
||||||
import tempfile
|
import tempfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import hashlib
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import loaih
|
import loaih
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ class Build(loaih.RemoteBuild):
|
|||||||
self.portable = False
|
self.portable = False
|
||||||
self.updatable = True
|
self.updatable = True
|
||||||
self.sign = True
|
self.sign = True
|
||||||
self.remoterepo = False
|
self.repo_type = 'local'
|
||||||
self.remote_host = ''
|
self.remote_host = ''
|
||||||
self.remote_path = ''
|
self.remote_path = ''
|
||||||
self.storage_path = '/mnt/appimage'
|
self.storage_path = '/mnt/appimage'
|
||||||
@ -83,6 +82,15 @@ class Build(loaih.RemoteBuild):
|
|||||||
|
|
||||||
print("--- Calculate Phase ---")
|
print("--- Calculate 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'
|
||||||
|
print("Repo is remote.")
|
||||||
|
else:
|
||||||
|
self.repo_type = 'local'
|
||||||
|
print("Repo is local.")
|
||||||
|
|
||||||
# AppName
|
# AppName
|
||||||
if self.query in { 'prerelease', 'daily' }:
|
if self.query in { 'prerelease', 'daily' }:
|
||||||
self.appname = 'LibreOfficeDev'
|
self.appname = 'LibreOfficeDev'
|
||||||
@ -126,11 +134,22 @@ class Build(loaih.RemoteBuild):
|
|||||||
if self.portable:
|
if self.portable:
|
||||||
self.relative_path.append('portable')
|
self.relative_path.append('portable')
|
||||||
|
|
||||||
fullpath_arr = self.storage_path.split('/')
|
# Fullpath might be intended two ways:
|
||||||
# Joining relative path only if it is not null
|
if self.repo_type == 'remote':
|
||||||
if len(self.relative_path) > 0:
|
# Repository is remote
|
||||||
fullpath_arr.extend(self.relative_path)
|
# we build full_path as it is absolute to the root of the
|
||||||
self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr))
|
# 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:
|
||||||
|
fullpath_arr.extend(self.relative_path)
|
||||||
|
self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr))
|
||||||
|
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
@ -142,26 +161,17 @@ class Build(loaih.RemoteBuild):
|
|||||||
self.calculate()
|
self.calculate()
|
||||||
|
|
||||||
for arch in self.arch:
|
for arch in self.arch:
|
||||||
|
print(f"Searching for {self.appimagefilename[arch]}")
|
||||||
# First, check if by metadata the repo is remote or not.
|
# First, check if by metadata the repo is remote or not.
|
||||||
if self.remoterepo or 'http' in self.storage_path:
|
if self.repo_type == 'remote':
|
||||||
self.remoterepo = True
|
|
||||||
# Remote storage. I have to query a remote site to know if it
|
# Remote storage. I have to query a remote site to know if it
|
||||||
# was already built.
|
# was already built.
|
||||||
name = self.appimagefilename[arch]
|
name = self.appimagefilename[arch]
|
||||||
if len(self.relative_path) == 0:
|
url = self.storage_path.rstrip('/') + self.full_path + '/'
|
||||||
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)
|
|
||||||
matching = []
|
matching = []
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(path) as url:
|
with urllib.request.urlopen(url) as response:
|
||||||
matching = etree.HTML(url.read()).xpath(
|
matching = etree.HTML(response.read()).xpath(
|
||||||
f"//a[contains(@href, '{name}')]/@href"
|
f"//a[contains(@href, '{name}')]/@href"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -175,7 +185,6 @@ class Build(loaih.RemoteBuild):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# Repo is local
|
# Repo is local
|
||||||
print(f"Searching for {self.appimagefilename[arch]}")
|
|
||||||
command = f"find {self.full_path} -name {self.appimagefilename[arch]}"
|
command = f"find {self.full_path} -name {self.appimagefilename[arch]}"
|
||||||
res = subprocess.run(shlex.split(command),
|
res = subprocess.run(shlex.split(command),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
@ -189,11 +198,10 @@ class Build(loaih.RemoteBuild):
|
|||||||
|
|
||||||
if res.stdout and len(res.stdout.strip("\n")) > 0:
|
if res.stdout and len(res.stdout.strip("\n")) > 0:
|
||||||
# All good, the command was executed fine.
|
# All good, the command was executed fine.
|
||||||
print(f"Build for {self.version} found.")
|
|
||||||
self.built[arch] = True
|
self.built[arch] = True
|
||||||
|
|
||||||
if self.built[arch]:
|
if self.built[arch]:
|
||||||
print(f"The requested AppImage already exists on storage for {arch}. I'll skip downloading, building and moving the results.")
|
print(f"Found requested AppImage: {self.appimagefilename[arch]}.")
|
||||||
|
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
@ -205,7 +213,7 @@ class Build(loaih.RemoteBuild):
|
|||||||
for arch in self.arch:
|
for arch in self.arch:
|
||||||
# Checking if a valid path has been provided
|
# Checking if a valid path has been provided
|
||||||
if self.url[arch] == '-':
|
if self.url[arch] == '-':
|
||||||
print(f"No build has been provided for the requested AppImage for {arch}. Continue with other options.")
|
print(f"Cannot build for arch {arch}. Continuing with other arches.")
|
||||||
# Faking already built it so to skip other checks.
|
# Faking already built it so to skip other checks.
|
||||||
self.built[arch] = True
|
self.built[arch] = True
|
||||||
continue
|
continue
|
||||||
@ -436,17 +444,10 @@ class Build(loaih.RemoteBuild):
|
|||||||
|
|
||||||
os.chdir(self.appnamedir)
|
os.chdir(self.appnamedir)
|
||||||
# Two cases here: local and remote storage_path.
|
# Two cases here: local and remote storage_path.
|
||||||
if self.remoterepo:
|
if self.repo_type == 'remote':
|
||||||
# Remote first.
|
# Remote first.
|
||||||
# Build destination directory
|
# Build destination directory
|
||||||
if len(self.relative_path) == 0:
|
remotepath = self.remote_path.rstrip('/') + self.full_path
|
||||||
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)
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
r"rsync -rlIvz --munge-links *.AppImage* " +
|
r"rsync -rlIvz --munge-links *.AppImage* " +
|
||||||
|
Reference in New Issue
Block a user