commit: cf4ce56603e8bc869352273763e0f206216ff51d
parent fefb33a87055e06cdc38cbd0c11ae39b2c14a298
Author: Melg Eight <public.melg8@gmail.com>
Date: Tue, 18 May 2021 14:37:34 +0300
Add config file and force timestamp conditional option
Diffstat:
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/rootfs.py b/rootfs.py
@@ -9,6 +9,7 @@ you can run bootstap inside chroot.
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021 Bastian Bittorf <bb@npl.de>
+# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
import argparse
import glob
@@ -33,6 +34,9 @@ def main():
parser.add_argument("-p", "--preserve", help="Do not unmount temporary dir",
action="store_true")
parser.add_argument("-t", "--tmpdir", help="Temporary directory")
+ parser.add_argument("--force_timestamps",
+ help="Force all files timestamps to be 0 unix time",
+ action="store_true")
# QEMU arguments
parser.add_argument("-q", "--qemu-cmd", help="QEMU command",
@@ -52,7 +56,8 @@ def main():
if args.arch != "x86":
raise ValueError("Only x86 is supported at the moment.")
- system_a = SysA(arch=args.arch, preserve_tmp=args.preserve, tmpdir=args.tmpdir)
+ system_a = SysA(arch=args.arch, preserve_tmp=args.preserve, tmpdir=args.tmpdir,
+ force_timestamps=args.force_timestamps)
initramfs_path = os.path.join(system_a.tmp_dir, "initramfs")
if not args.chroot:
diff --git a/sysa.py b/sysa.py
@@ -18,7 +18,7 @@ class SysA:
"""
Class responsible for preparing sources for System A.
"""
- def __init__(self, arch, preserve_tmp, tmpdir):
+ def __init__(self, arch, preserve_tmp, tmpdir, force_timestamps):
self.git_dir = os.path.dirname(os.path.join(__file__))
self.arch = arch
self.preserve_tmp = preserve_tmp
@@ -29,6 +29,7 @@ class SysA:
self.tmp_dir = tmpdir
self.sysa_dir = os.path.join(self.git_dir, 'sysa')
self.after_dir = os.path.join(self.tmp_dir, 'after')
+ self.force_timestamps = force_timestamps
self.prepare()
@@ -187,6 +188,7 @@ class SysA:
"""
self.create_after_dirs()
+ self.create_configuration_file()
self.mescc_tools_checksum()
self.deploy_extra_files()
self.mescc_tools_extra()
@@ -194,6 +196,15 @@ class SysA:
self.tcc_0_9_26()
self.get_packages()
+ def create_configuration_file(self):
+ """
+ Creates bootstrap.cfg file which would contain options used to
+ customize bootstrap.
+ """
+ config_path = os.path.join(self.after_dir, "bootstrap.cfg")
+ with open(config_path, "w") as config:
+ config.write("FORCE_TIMESTAMPS=" + str(self.force_timestamps))
+
def create_after_dirs(self):
"""
Create some empty directories for early bootstrap
diff --git a/sysa/helpers.sh b/sysa/helpers.sh
@@ -3,6 +3,7 @@
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
# SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
+# SPDX-FileCopyrightText: 2021 Melg Eight <public.melg8@gmail.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
@@ -149,3 +150,11 @@ call() {
default() {
"default_${build_stage}"
}
+
+# Set all files modified dates to be 0 unix time.
+# Should be called at the end of bootstrapping process.
+# This function needs `touch` that supports --no-dereference
+# (at least coreutils 8.1).
+canonicalise_all_files_timestamp() {
+ find / -exec touch --no-dereference -t 197001010000.00 {} +
+}
diff --git a/sysa/run2.sh b/sysa/run2.sh
@@ -11,6 +11,8 @@ set -e
. helpers.sh
+. bootstrap.cfg
+
build xz-5.0.5
build automake-1.11.2
@@ -31,6 +33,11 @@ build mpfr-4.1.0
build mpc-1.2.1
+if [ "$FORCE_TIMESTAMPS" = True ] ; then
+ echo 'Forcing all files timestamps to be 0 unix time.'
+ canonicalise_all_files_timestamp
+fi
+
echo "Bootstrapping completed."
exec env - PATH=/after/bin PS1="\w # " bash -i