Skip to content

Commit

Permalink
build: cleanup KDIR_TMP after each build
Browse files Browse the repository at this point in the history
Clean the KDIR_TMP folder after each build since it stores every image
ever created.

Also run isort and black.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Sep 10, 2022
1 parent 05e8ec2 commit e5965b2
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 4 deletions.
26 changes: 24 additions & 2 deletions asu/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
import requests
from rq import get_current_job

from .common import (fingerprint_pubkey_usign, get_file_hash,
get_packages_hash, verify_usign)
from .common import (
fingerprint_pubkey_usign,
get_file_hash,
get_packages_hash,
verify_usign,
)

log = logging.getLogger("rq.worker")
log.setLevel(logging.DEBUG)
Expand Down Expand Up @@ -338,6 +342,24 @@ def download_file(filename: str, dest: str = None):
if "is too big" in image_build.stderr:
report_error("Selected packages exceed device storage")

kernel_build_dir_run = subprocess.run(
["make", "val.KERNEL_BUILD_DIR"],
text=True,
cwd=cache_workdir,
capture_output=True,
)

if kernel_build_dir_run.returncode:
report_error("Couldn't determine KERNEL_BUILD_DIR")

kernel_build_dir_tmp = Path(kernel_build_dir_run.stdout.strip()) / "tmp"

if kernel_build_dir_tmp.exists():
log.info("Removing KDIR_TMP at %s", kernel_build_dir_tmp)
rmtree(kernel_build_dir_tmp)
else:
log.warning("KDIR_TMP missing at %s", kernel_build_dir_tmp)

json_file = Path(req["store_path"] / bin_dir / "profiles.json")

if not json_file.is_file():
Expand Down
21 changes: 21 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,24 @@ def test_api_build_package_to_replace(client, upstream):
)
assert response.status == "200 OK"
assert response.json.get("request_hash") == "8dd81d51057d322b46aa3739ccf4a8a6"


def test_api_build_cleanup(app, upstream):
client = app.test_client()
response = client.post(
"/api/v1/build",
json=dict(
version="TESTVERSION",
target="testtarget/testsubtarget",
profile="testprofile",
packages=["test1", "test2"],
filesystem="ext4",
),
)
assert response.status == "200 OK"
assert not (
app.config["CACHE_PATH"]
/ "cache/TESTVERSION/testtarget/testsubtarget"
/ "pseudo_kernel_build_dir/tmp/"
/ "fake_trash"
).exists()
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ manifest:

info:
@cat ./openwrt-testtarget-testsubtarget-testprofile.info

val.KERNEL_BUILD_DIR:
@echo "$$(pwd)/pseudo_kernel_build_dir/"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f7a57262cde30d84db51d6db5b1eee16f5c0525e67f01dcbe10a9693e3c88fde *openwrt-imagebuilder-testtarget-testsubtarget.Linux-x86_64.tar.xz
4e645577d934129a65d0f79cf55d90e1199f5ab90ab27803cefae8badc868599 *openwrt-imagebuilder-testtarget-testsubtarget.Linux-x86_64.tar.xz
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
untrusted comment: verify with testkey.pub
RWRqylWEtrAZQ/BrgCkjQaOak7bVi7CWfwKbK/rKK39w4e0l7jL+D23xAZZXS3Qb/x6jwulK3lbuCU61etNGaLE2KxWfk1hY4QM=
RWRqylWEtrAZQwwqVGXn0U/Q3nnrboIdIVK2aW7Q8JMN3pmCzHa8o5MppWUqMhxh/h2Dc/3WUjVtWgvfDGrR0tJJ/Wauy9r7QwM=

0 comments on commit e5965b2

Please sign in to comment.