Build now check installation
This commit is contained in:
parent
7f8b318b9a
commit
a19f564121
55
build.py
55
build.py
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
@ -36,29 +37,43 @@ def md5sum(url):
|
|||
return hash_md5.hexdigest()
|
||||
|
||||
|
||||
class DebianBuilder:
|
||||
template = "PKGBUILD.debian.j2"
|
||||
def check_result(result, exit_on_error=True):
|
||||
if result.returncode != 0:
|
||||
print(huepy.bad("Error"))
|
||||
print(huepy.bad(result.stderr))
|
||||
|
||||
if exit_on_error:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class Builder:
|
||||
def update_package_definition(self, package):
|
||||
if "i686" in package["arch"]:
|
||||
source_i686 = package["sources"]["i686"]["url"].format(**package)
|
||||
package["sources"]["i686"]["url"] = source_i686
|
||||
package["sources"]["i686"]["md5sum"] = md5sum(source_i686)
|
||||
|
||||
if "x86_64" in package["arch"]:
|
||||
source_x86_64 = package["sources"]["x86_64"]["url"].format(**package)
|
||||
package["sources"]["x86_64"]["url"] = source_x86_64
|
||||
package["sources"]["x86_64"]["md5sum"] = md5sum(source_x86_64)
|
||||
|
||||
|
||||
class PythonVirtualenvBuilder:
|
||||
class DebianBuilder(Builder):
|
||||
template = "PKGBUILD.debian.j2"
|
||||
|
||||
|
||||
class PythonVirtualenvBuilder(Builder):
|
||||
template = "PKGBUILD.python-virtualenv.j2"
|
||||
|
||||
def update_package_definition(self, package):
|
||||
# We don't need this.
|
||||
pass
|
||||
|
||||
|
||||
BUILDERS = {"debian": DebianBuilder, "python-virtualenv": PythonVirtualenvBuilder}
|
||||
BUILDERS = {
|
||||
"debian": DebianBuilder,
|
||||
"python-virtualenv": PythonVirtualenvBuilder,
|
||||
}
|
||||
|
||||
print(huepy.run(f"Using {package['builder']['type']} builder"))
|
||||
builder = BUILDERS[package["builder"]["type"]]()
|
||||
|
@ -90,5 +105,33 @@ if result.returncode != 0:
|
|||
print(huepy.bad("Error writing .SRCINFO file"))
|
||||
print(result.stderr)
|
||||
print(result.stdout)
|
||||
else:
|
||||
print(huepy.good("Build finished"))
|
||||
|
||||
print(huepy.good("Build finished"))
|
||||
subprocess.run("sudo pacman -Syy", shell=True, capture_output=False)
|
||||
print(huepy.info("Testing: makepkg"))
|
||||
check_result(
|
||||
subprocess.run("makepkg --noconfirm -Acs", shell=True, cwd=build_path, capture_output=False)
|
||||
)
|
||||
print(huepy.info("Testing: pacman -S --noconfirm"))
|
||||
check_result(
|
||||
subprocess.run(
|
||||
"sudo pacman -U --noconfirm *.pkg.tar.zst",
|
||||
shell=True,
|
||||
cwd=build_path,
|
||||
capture_output=False,
|
||||
)
|
||||
)
|
||||
if "test" in package:
|
||||
subprocess.run("ls /usr/local/bin", shell=True)
|
||||
print(huepy.info(f"Testing: {package['test']['command']}"))
|
||||
check_result(
|
||||
subprocess.run(
|
||||
f"{package['test']['command']}",
|
||||
shell=True,
|
||||
cwd=build_path,
|
||||
capture_output=False,
|
||||
)
|
||||
)
|
||||
|
||||
print(huepy.good("Test successful"))
|
||||
|
|
Loading…
Reference in New Issue