commit: 21f4174dc39263342e96ede6b6dacd4eb105928e
parent 3e4f823ffb3a814f8a050f02ae85e53466b650a2
Author: Andrius Štikonas <andrius@stikonas.eu>
Date: Tue, 17 May 2022 01:01:48 +0100
Fix packaging issues
* Bzip2 was manually installed directly into filesystem, so bzip2 package was empty.
Fixed by installing it to destdir. bzip2 moves out its binary before installing
its own package.
* sha256sum from stage0-posix was not checking any checksums because it does not
accept piped input. Fixed by using temporary file.
* grep was broken for a short time (but with fixed bzip2 package this caused failures)
due to touch creating grep file of zero size (egrep symlink was touched).
Fixed by implementing touch -h
Resolves #156, resolves #166, resolves #167
Diffstat:
12 files changed, 138 insertions(+), 31 deletions(-)
diff --git a/sysa/SHA256SUMS.pkgs b/sysa/SHA256SUMS.pkgs
@@ -73,9 +73,9 @@ becc8ea1f24c531c35b520ce8bac9e8bf6e30e362fe77bf7833aed9d28af0ae6 bison-3.4.1_2.
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 bison-3.4.2_0.links
ee3e0367cecd84ebbb929c629413e069efa46806f82807abcee2fe79b21525de bison-3.4.2_0.tar.bz2
07fee627dcf30aaa9beab40ffeacc3bec7afe3488d2fbc7e8a72ae782a85869a bzip2-1.0.8_0.links
-f4fad25a0e7a451ed906b76846efd6d2699a65b40795b29553addc35bf9a75c8 bzip2-1.0.8_0.tar.bz2
+993f499932a91edd6046e66ba05a1ffada6b57633e1b197486aeab23590afa3a bzip2-1.0.8_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 coreutils-5.0_0.links
-da0336a795d1549155c5d84a05f9faa23d41acc2a25c1abfda25b468acf9429a coreutils-5.0_0.tar.bz2
+25d8e4ea70259cc212bebdbc4beefc01eaf3ad76f4613cee5321a0f83dd4c5a4 coreutils-5.0_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 coreutils-6.10_0.links
776ef3e13870fba6fc9cec64eaf40fb658abecc99c65724968013f8f8a177802 coreutils-6.10_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 coreutils-8.32_0.links
@@ -175,7 +175,7 @@ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 tcc-0.9.27_2.l
e2014b844b1a79cda9142a38af0404efd242ae02f77aa286c968e4ad6ad87265 tcc-0.9.27_2.tar.bz2
96dc08f4d01eddc04af107ffd313617af3fc455af38a82b850c4aca08cbd7e84 texinfo-6.7_0.x86.xbps
970cc84444fecc225becb0db24671a186888a8a8d37daf3f40d827a907181a12 util-linux-2.19.1_0.links
-b909ae48764f3c7515346485d746c75fb38deb76723fa4a61701756304ed2c17 util-linux-2.19.1_0.tar.bz2
+c974856b8cae6b25e5e88b82def6eda233ce865fed53fe9e5f719ff8d0d2df4c util-linux-2.19.1_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 xbps-0.59.1_0.links
3f044d2aaa838c9df153d662f8e259c2393774d3d3a5e71e26b5d867dbb08107 xbps-0.59.1_0.tar.bz2
ac8c7b186195ad29d86c2d1608b0c4ba37eeb12daff8f155d69d568239cae237 xz-5.0.5_0.links
diff --git a/sysa/bzip2-1.0.8/bzip2-1.0.8.sh b/sysa/bzip2-1.0.8/bzip2-1.0.8.sh
@@ -13,9 +13,7 @@ src_compile() {
}
src_install() {
- # Manually install bzip2 (cannot replace binary while running)
- install -D bzip2 "${PREFIX}/bin/bzip2"
- mkdir -p "${DESTDIR}${PREFIX}/bin"
+ install -D bzip2 "${DESTDIR}${PREFIX}/bin/bzip2"
ln -sf "${PREFIX}/bin/bzip2" "${DESTDIR}${PREFIX}/bin/bunzip2"
ln -sf "${PREFIX}/bin/bzip2" "${DESTDIR}${PREFIX}/bin/bzcat"
}
diff --git a/sysa/coreutils-5.0/checksums b/sysa/coreutils-5.0/checksums
@@ -44,7 +44,7 @@ c4dfcec63607cf44a4f64a2673892a38c6b5a7aa9821d12c9abe9cf63126ee39 /usr/bin/tr
0c7288eb7dfc707723ef9653be06f49b3b458e22b53f8172733870f612fb0135 /usr/bin/wc
a92eb5a6e8413bf580718c0fddaac7821a68a8e7918a930c4cb36a2c666d3720 /usr/bin/whoami
2b6fc3790a81835001001c5b1e0d7f368720288da55241eef9485888db86edb3 /usr/bin/test
-b770b43dc01c8403c5c0c9522e4f2bb851dfaaf8d7a1c45e6ae449f45ee5171a /usr/bin/touch
+042efa219eb798c0308259566fe12b161c8349b9d50fe9e02bb74993a07bf91a /usr/bin/touch
19dc29f6b439546fc113286d09bf5ba6c83663e03037225a6884f66790f5820f /usr/bin/true
813d000327b025a0eb17d7a1dd1a2608b78dfa383c6a175ec36d39a28f4e2889 /usr/bin/yes
9fe71e506ad02f545b55fba003f6fdf91adb28471fc3081fd49100073e51e018 /usr/bin/ls
diff --git a/sysa/coreutils-5.0/coreutils-5.0.kaem b/sysa/coreutils-5.0/coreutils-5.0.kaem
@@ -28,6 +28,7 @@ patch -Np0 -i ../../patches/modechange.patch
patch -Np0 -i ../../patches/mbstate.patch
patch -Np0 -i ../../patches/ls-strcmp.patch
patch -Np0 -i ../../patches/touch-getdate.patch
+patch -Np0 -i ../../patches/touch-dereference.patch
# Build and install
make -f Makefile PREFIX=${prefix}
diff --git a/sysa/coreutils-5.0/coreutils-5.0.sh b/sysa/coreutils-5.0/coreutils-5.0.sh
@@ -5,13 +5,13 @@
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
+ default
+
cp lib/fnmatch_.h lib/fnmatch.h
cp lib/ftw_.h lib/ftw.h
cp lib/search_.h lib/search.h
touch config.h
- patch -Np0 -i ../../patches/touch-getdate.patch
-
# Bison pre-generated file
rm lib/getdate.c
diff --git a/sysa/coreutils-5.0/patches-musl/touch-dereference.patch b/sysa/coreutils-5.0/patches-musl/touch-dereference.patch
@@ -0,0 +1 @@
+../patches/touch-dereference.patch
+\ No newline at end of file
diff --git a/sysa/coreutils-5.0/patches-musl/touch-getdate.patch b/sysa/coreutils-5.0/patches-musl/touch-getdate.patch
@@ -0,0 +1 @@
+../patches/touch-getdate.patch
+\ No newline at end of file
diff --git a/sysa/coreutils-5.0/patches/touch-dereference.patch b/sysa/coreutils-5.0/patches/touch-dereference.patch
@@ -0,0 +1,97 @@
+SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
+SPDX-FileCopyrightText: 2009 Eric Blake <ebb9@byu.net>
+
+SPDX-License-Identifier: GPL-2.0-or-later
+
+touch: add -h to change symlink timestamps, where supported
+
+diff -r -U3 coreutils-5.0.orig/src/touch.c coreutils-5.0/src/touch.c
+--- src/touch.c 2002-12-20 20:09:22.000000000 +0000
++++ src/touch.c 2022-05-16 20:31:37.801988595 +0100
+@@ -77,6 +77,9 @@
+ /* (-r) If nonzero, use times from a reference file. */
+ static int use_ref;
+
++/* (-h) If true, change the times of an existing symlink, if possible. */
++static int no_dereference;
++
+ /* (-t) If nonzero, date supplied on command line in POSIX format. */
+ static int posix_date;
+
+@@ -110,6 +113,7 @@
+ {"date", required_argument, 0, 'd'},
+ {"file", required_argument, 0, 'r'}, /* FIXME: phase out --file */
+ {"reference", required_argument, 0, 'r'},
++ {"no-dereference", no_argument, NULL, 'h'},
+ {GETOPT_HELP_OPTION_DECL},
+ {GETOPT_VERSION_OPTION_DECL},
+ {0, 0, 0, 0}
+@@ -138,7 +142,7 @@
+ int fd = -1;
+ int open_errno = 0;
+
+- if (! no_create)
++ if (! (no_create || no_dereference))
+ {
+ /* Try to open FILE, creating it if necessary. */
+ fd = open (file, O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY,
+@@ -158,7 +162,7 @@
+ the other one. If we have the file descriptor already, use fstat.
+ Otherwise, either we're in no-create mode (and hence didn't call open)
+ or FILE is inaccessible or a directory, so we have to use stat. */
+- if (fd != -1 ? fstat (fd, &sbuf) : stat (file, &sbuf))
++ if (fd != -1 ? fstat (fd, &sbuf) : (no_dereference ? lstat (file, &sbuf) : stat (file, &sbuf)))
+ {
+ if (open_errno)
+ error (0, open_errno, _("creating %s"), quote (file));
+@@ -223,7 +227,7 @@
+ }
+ else
+ {
+- if (no_create && errno == ENOENT)
++ if ((no_create || no_dereference) && errno == ENOENT)
+ return 0;
+ error (0, errno, _("setting times of %s"), quote (file));
+ }
+@@ -254,6 +258,9 @@
+ -c, --no-create do not create any files\n\
+ -d, --date=STRING parse STRING and use it instead of current time\n\
+ -f (ignored)\n\
++ -h, --no-dereference affect each symbolic link instead of any referenced\n\
++ file (useful only on systems that can change the\n\
++ timestamps of a symlink)\n\
+ -m change only the modification time\n\
+ "), stdout);
+ fputs (_("\
+@@ -289,7 +296,7 @@
+
+ change_times = no_create = use_ref = posix_date = flexible_date = 0;
+
+- while ((c = getopt_long (argc, argv, "acd:fmr:t:", longopts, NULL)) != -1)
++ while ((c = getopt_long (argc, argv, "acd:fhmr:t:", longopts, NULL)) != -1)
+ {
+ switch (c)
+ {
+@@ -315,6 +322,10 @@
+ case 'f':
+ break;
+
++ case 'h':
++ no_dereference = true;
++ break;
++
+ case 'm':
+ change_times |= CH_MTIME;
+ break;
+@@ -358,7 +369,10 @@
+
+ if (use_ref)
+ {
+- if (stat (ref_file, &ref_stats))
++ /* Don't use (no_dereference ? lstat : stat) (args), since stat
++ might be an object-like macro. */
++ if (no_dereference ? lstat (ref_file, &ref_stats)
++ : stat (ref_file, &ref_stats))
+ error (EXIT_FAILURE, errno,
+ _("failed to get attributes of %s"), quote (ref_file));
+ date_set++;
diff --git a/sysa/helpers.sh b/sysa/helpers.sh
@@ -60,16 +60,9 @@ get_files() {
# Reset all timestamps to unix time 0
reset_timestamp() {
- args=
- # touch -h is not avaliable until after grep is built.
- if command -v grep >/dev/null 2>&1; then
- if touch --help | grep ' \-h' >/dev/null; then
- args="-h"
- fi
- fi
if command -v find >/dev/null 2>&1; then
# find does not error out on exec error
- find . -print0 | xargs -0 touch ${args} -t 197001010000.00
+ find . -print0 | xargs -0 touch -h -t 197001010000.00
else
# A rudimentary find implementation that does the trick
fs=
@@ -80,7 +73,7 @@ reset_timestamp() {
fs="${fs} $(echo .[0-z]*)"
fi
for f in ${fs}; do
- touch ${args} -t 197001010000.00 "${f}"
+ touch -h -t 197001010000.00 "${f}"
if [ -d "${f}" ]; then
cd "${f}"
reset_timestamp
@@ -92,8 +85,8 @@ reset_timestamp() {
# Fake grep
_grep() {
- text="${1}"
- fname="${2}"
+ local text="${1}"
+ local fname="${2}"
if command -v grep >/dev/null 2>&1; then
grep "${text}" "${fname}"
else
@@ -308,7 +301,11 @@ src_pkg() {
src_checksum() {
if ! [ "$UPDATE_CHECKSUMS" = True ] ; then
echo "${pkg}: checksumming created package."
- _grep "${pkg}_${revision}" "${SOURCES}/SHA256SUMS.pkgs" | sha256sum -c
+ # We avoid using pipes as that is not supported by initial sha256sum from mescc-tools-extra
+ local checksum_file=/tmp/checksum
+ _grep "${pkg}_${revision}" "${SOURCES}/SHA256SUMS.pkgs" > "${checksum_file}"
+ sha256sum -c "${checksum_file}"
+ rm "${checksum_file}"
fi
}
@@ -329,8 +326,18 @@ src_apply_tar() {
rm -f "/${file}" >/dev/null 2>&1 || true
done < /tmp/filelist.txt
fi
- bzip2 -dc "/usr/src/repo/${pkg}_${revision}.tar.bz2" | \
+
+ # Bzip2 does not like to be overwritten
+ if [[ "${pkg}" == bzip2-* ]]; then
+ mkdir -p /tmp
+ mv "${PREFIX}/bin/bzip2" "/tmp/bzip2"
+ BZIP2_PREFIX="/tmp/"
+ fi
+ "${BZIP2_PREFIX}bzip2" -dc "/usr/src/repo/${pkg}_${revision}.tar.bz2" | \
tar -C / -xpf -
+ unset BZIP2_PREFIX
+ rm -f "/tmp/bzip2"
+
# shellcheck disable=SC2162
# ^ read -r unsupported in old bash
while read line; do
diff --git a/sysa/run.sh b/sysa/run.sh
@@ -135,7 +135,7 @@ build grep-2.4
build diffutils-2.7
# Rebuild coreutils using musl
-build coreutils-5.0 coreutils-5.0.sh
+build coreutils-5.0 coreutils-5.0.sh patches-musl
# Build only date, mktemp and sha256sum
build coreutils-6.10
diff --git a/sysc/init b/sysc/init
@@ -9,6 +9,12 @@ set -e
# shellcheck source=sysa/helpers.sh
. helpers.sh
+export PATH=/usr/bin:/usr/sbin
+export PREFIX=/usr
+export SOURCES=/usr/src
+export DESTDIR=/tmp/destdir
+export DISTFILES=/distfiles
+
echo
echo "Installing packages into sysc"
diff --git a/sysc/run.sh b/sysc/run.sh
@@ -11,12 +11,6 @@ set -e
# shellcheck source=sysa/helpers.sh
. helpers.sh
-export PATH=/usr/bin:/usr/sbin
-export PREFIX=/usr
-export SOURCES=/usr/src
-export DESTDIR=/tmp/destdir
-export DISTFILES=/distfiles
-
create_fhs() {
# Add the rest of the FHS that we will use and is not created pre-boot
rm -rf /sbin /usr/sbin
@@ -24,7 +18,7 @@ create_fhs() {
for d in bin lib sbin; do
ln -s "usr/${d}" "/${d}"
done
- mkdir /etc /proc /run /sys /tmp /var
+ mkdir -p /etc /proc /run /sys /tmp /var
mount -t proc proc /proc
mount -t sysfs sysfs /sys
# Make /tmp a ramdisk (speeds up configure etc significantly)
@@ -37,4 +31,4 @@ create_fhs
build bash-5.1
-exec env -i PATH=${PATH} PREFIX=${PREFIX} SOURCES=${SOURCES} DESTDIR=${DESTDIR} DISTFILES=${DISTFILES} bash run2.sh
+exec env -i PATH="${PATH}" PREFIX="${PREFIX}" SOURCES="${SOURCES}" DESTDIR="${DESTDIR}" DISTFILES="${DISTFILES}" bash run2.sh