commit: ab47483a51e0f7de1d78a6ef9e3fc14da1e51881
parent ff4f97ab8f17fbf89b1b636a6cb830dd26460136
Author: fosslinux <fosslinux@aussies.space>
Date: Thu, 7 Dec 2023 21:21:03 +1100
Linters & CI updates
Diffstat:
21 files changed, 75 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
@@ -21,7 +21,7 @@ jobs:
- name: Install pylint
run: sudo pip3 install pylint
- name: pylint
- run: pylint rootfs.py sysa.py sysc.py lib/utils.py lib/sysgeneral.py lib/tmpdir.py --disable=duplicate-code
+ run: pylint rootfs.py lib/utils.py lib/generator.py lib/tmpdir.py --disable=duplicate-code
shellcheck:
name: Lint shell files
@@ -30,7 +30,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3
- name: shellcheck
- run: shellcheck sysa/run.sh sysa/run2.sh sysb/init sysb/run.sh sysc/init sysc/run.sh sysa/helpers.sh download-distfiles.sh
+ run: shellcheck steps/helpers.sh download-distfiles.sh
reuse:
name: Lint reuse information
diff --git a/.reuse/dep5 b/.reuse/dep5
@@ -9,6 +9,6 @@ Source: https://github.com/fosslinux/live-bootstrap
# Copyright: $YEAR $NAME <$CONTACT>
# License: ...
-Files: sys*/*/sources sysa/*/*.checksums sysa/SHA256SUMS.pkgs sysa/*/simple-patches/*
+Files: steps/*/sources steps/*/*.checksums steps/SHA256SUMS.pkgs steps/*/simple-patches/* steps/pre-network-sources
Copyright: none
License: MIT
diff --git a/lib/generator.py b/lib/generator.py
@@ -1,15 +1,16 @@
#!/usr/bin/env python3
+"""
+This file contains all code required to generate the boot image for live-bootstrap
+"""
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
# SPDX-FileCopyrightText: 2021-23 fosslinux <fosslinux@aussies.space>
-import glob
import hashlib
import os
import shutil
-import subprocess
import tarfile
import requests
@@ -30,6 +31,7 @@ class Generator():
self.repo_path = repo_path
self.tmpdir = tmpdir
self.tmp_dir = tmpdir.path
+ self.external_dir = os.path.join(self.tmp_dir, 'external')
def prepare(self, using_kernel=False, kernel_bootstrap=False):
"""
@@ -38,7 +40,6 @@ class Generator():
/ -- contains seed to allow steps to be built, containing custom
scripts and stage0-posix
"""
- self.external_dir = os.path.join(self.tmp_dir, 'external')
# We use ext3 here; ext4 actually has a variety of extensions that
# have been added with varying levels of recency
# Linux 4.9.10 does not support a bunch of them
@@ -151,7 +152,8 @@ class Generator():
"""Copy in distfiles"""
def copy_no_network_distfiles(out):
# Note that no network == no disk for kernel bootstrap mode
- with open(os.path.join(self.git_dir, 'steps', 'pre-network-sources'), 'r') as source_list:
+ pre_src_path = os.path.join(self.git_dir, 'steps', 'pre-network-sources')
+ with open(pre_src_path, 'r', encoding="utf-8") as source_list:
for file in source_list.readlines():
file = file.strip()
shutil.copy2(os.path.join(self.distfiles_dir, file),
diff --git a/lib/tmpdir.py b/lib/tmpdir.py
@@ -59,7 +59,8 @@ class Tmpdir:
mount("tmpfs", self.path, "tmpfs", f"size={size}")
self._type = TmpType.TMPFS
- def add_disk(self, name, size="16G", filesystem="ext4", tabletype="msdos", mkfs_args=[]):
+ # pylint: disable=too-many-arguments
+ def add_disk(self, name, size="16G", filesystem="ext4", tabletype="msdos", mkfs_args=None):
"""Add a disk"""
disk_path = os.path.join(self.path, f"{name}.img")
self._disks[name] = create_disk(disk_path, tabletype, filesystem, size, mkfs_args=mkfs_args)
diff --git a/lib/utils.py b/lib/utils.py
@@ -31,8 +31,10 @@ def run_as_root(*args, **kwargs):
return run("sudo", *args, **kwargs)
return run(*args, **kwargs)
-def create_disk(image, disk_type, fs_type, size, mkfs_args=[]):
+def create_disk(image, disk_type, fs_type, size, mkfs_args=None):
"""Create a disk image, with a filesystem on it"""
+ if mkfs_args is None:
+ mkfs_args = []
run('truncate', '-s', size, image)
# First find the device we will use, then actually use it
loop_dev = run_as_root('losetup', '-f', capture_output=True).stdout.decode().strip()
diff --git a/seed/preseeded.kaem b/seed/preseeded.kaem
@@ -1,4 +1,8 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
/script-generator /steps/manifest
/usr/bin/kaem --file /preseed-jump.kaem
diff --git a/seed/script-generator.c b/seed/script-generator.c
@@ -1,7 +1,7 @@
/*
* SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
*
- * SPDX-License-Idnetifier: GPL-3.0-or-later
+ * SPDX-License-Identifier: GPL-3.0-or-later
*/
#define MAX_TOKEN 64
diff --git a/steps/env b/steps/env
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
DISTFILES=/external/distfiles
PREFIX=/usr
BINDIR=${PREFIX}/bin
diff --git a/steps/helpers.sh b/steps/helpers.sh
@@ -289,7 +289,7 @@ default_src_unpack() {
# Then it copies our custom makefile and any other custom files from files directory.
default_src_prepare() {
if test -d "${patch_dir}"; then
- if ls "${patch_dir}"/*.patch 2>&1 >/dev/null; then
+ if ls "${patch_dir}"/*.patch >/dev/null 2>&1; then
for p in "${patch_dir}"/*.patch; do
echo "Applying patch: ${p}"
patch -Np0 < "${p}"
diff --git a/steps/improve/clean_ram.sh b/steps/improve/clean_ram.sh
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
# Save because linux deletes all distfiles to save space
cp "${DISTFILES}"/musl-1.2.4.tar.gz /tmp
cp "${DISTFILES}"/curl-7.88.1.tar.bz2 /tmp
diff --git a/steps/improve/finalize_fhs.sh b/steps/improve/finalize_fhs.sh
@@ -1,4 +1,9 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
# Add the rest of the FHS that we will use and is not created pre-boot
rm -rf /sbin /usr/sbin
for d in bin lib sbin; do
diff --git a/steps/improve/get_network.sh b/steps/improve/get_network.sh
@@ -1,4 +1,9 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
dhcpcd --waitip=4
# Ensure network accessible
timeout=120
diff --git a/steps/improve/musl_libdir.sh b/steps/improve/musl_libdir.sh
@@ -1,5 +1,9 @@
#!/bin/sh
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
sed -i "/^LIBDIR/d" /steps/env
LIBDIR=${PREFIX}/lib/i386-unknown-linux-musl
echo "LIBDIR=${LIBDIR}" >> /steps/env
diff --git a/steps/improve/null_time.sh b/steps/improve/null_time.sh
@@ -1,4 +1,8 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
# Set modified dates of all files to be 0 unix time.
# This function needs `touch` that supports --no-dereference
diff --git a/steps/improve/populate_device_nodes.sh b/steps/improve/populate_device_nodes.sh
@@ -1,4 +1,8 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
# http://www.linuxfromscratch.org/lfs/view/6.1/chapter06/devices.html
mkdir -p "/dev"
diff --git a/steps/improve/setup_repo.sh b/steps/improve/setup_repo.sh
@@ -1,2 +1,7 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
mkdir -p /external/repo
diff --git a/steps/improve/update_env.sh b/steps/improve/update_env.sh
@@ -1,5 +1,9 @@
#!/bin/sh
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
unset GUILE_LOAD_PATH
cat > /steps/env <<- EOF
diff --git a/steps/jump/fiwix.sh b/steps/jump/fiwix.sh
@@ -1,4 +1,8 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
set -ex
diff --git a/steps/jump/linux.sh b/steps/jump/linux.sh
@@ -1,4 +1,8 @@
#!/bin/bash
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
. /steps/bootstrap.cfg
diff --git a/steps/jump/move_disk.sh b/steps/jump/move_disk.sh
@@ -1,4 +1,8 @@
#!/bin/sh
+#
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
set -ex
diff --git a/steps/manifest b/steps/manifest
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
# This file follows a very simple, human readable and machine parseable syntax.
# Each line is in the format:
# <directive>: <arguments> <predicate>