Skip to content

Commit

Permalink
Linters & CI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fosslinux committed Dec 7, 2023
1 parent dd9eb6d commit cdcc783
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Source: https://github.com/fosslinux/live-bootstrap
# Copyright: $YEAR $NAME <$CONTACT>
# License: ...

Files: sys*/*/sources sysa/checksum-transcriber.*.SHA256SUM 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
10 changes: 6 additions & 4 deletions lib/generator.py
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <[email protected]>
# SPDX-FileCopyrightText: 2021 Melg Eight <[email protected]>
# SPDX-FileCopyrightText: 2021-23 fosslinux <[email protected]>

import glob
import hashlib
import os
import shutil
import subprocess
import tarfile
import requests

Expand All @@ -30,6 +31,7 @@ def __init__(self, tmpdir, arch, external_sources,
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):
"""
Expand All @@ -38,7 +40,6 @@ def prepare(self, using_kernel=False, kernel_bootstrap=False):
/ -- 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
Expand Down Expand Up @@ -151,7 +152,8 @@ def distfiles(self):
"""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),
Expand Down
3 changes: 2 additions & 1 deletion lib/tmpdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def tmpfs(self, size="8G"):
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)
Expand Down
4 changes: 3 additions & 1 deletion lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions seed/preseeded.kaem
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

/script-generator /steps/manifest
/usr/bin/kaem --file /preseed-jump.kaem
2 changes: 1 addition & 1 deletion seed/script-generator.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
*
* SPDX-License-Idnetifier: GPL-3.0-or-later
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#define MAX_TOKEN 64
Expand Down
4 changes: 4 additions & 0 deletions steps/env
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

DISTFILES=/external/distfiles
PREFIX=/usr
BINDIR=${PREFIX}/bin
Expand Down
2 changes: 1 addition & 1 deletion steps/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 4 additions & 0 deletions steps/improve/clean_ram.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions steps/improve/finalize_fhs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# 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
Expand Down
5 changes: 5 additions & 0 deletions steps/improve/get_network.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
dhcpcd --waitip=4
# Ensure network accessible
timeout=120
Expand Down
4 changes: 4 additions & 0 deletions steps/improve/musl_libdir.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh

# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# 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
4 changes: 4 additions & 0 deletions steps/improve/null_time.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# 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
Expand Down
4 changes: 4 additions & 0 deletions steps/improve/populate_device_nodes.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# http://www.linuxfromscratch.org/lfs/view/6.1/chapter06/devices.html
mkdir -p "/dev"
Expand Down
5 changes: 5 additions & 0 deletions steps/improve/setup_repo.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
mkdir -p /external/repo
5 changes: 5 additions & 0 deletions steps/improve/update_env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

cat > /steps/env <<- EOF
export PATH=${PREFIX}/bin
PREFIX=${PREFIX}
Expand Down
4 changes: 4 additions & 0 deletions steps/jump/fiwix.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

set -ex

Expand Down
4 changes: 4 additions & 0 deletions steps/jump/linux.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

. /steps/bootstrap.cfg

Expand Down
4 changes: 4 additions & 0 deletions steps/jump/move_disk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
#
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

set -ex

Expand Down
4 changes: 4 additions & 0 deletions steps/manifest
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2023 fosslinux <[email protected]>
#
# 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>
Expand Down

0 comments on commit cdcc783

Please sign in to comment.