Remove the notion of "sys*"

- This idea originates from very early in the project and was, at the
  time, a very easy way to categorise things.
- Now, it doesn't really make much sense - it is fairly arbitary, often
  occuring when there is a change in kernel, but not from builder-hex0
  to fiwix, and sysb is in reality completely unnecessary.
- In short, the sys* stuff is a bit of a mess that makes the project
  more difficult to understand.
- This puts everything down into one folder and has a manifest file that
  is used to generate the build scripts on the fly rather than using
  coded scripts.
- This is created in the "seed" stage.

stage0-posix -- (calls) --> seed -- (generates) --> main steps

Alongside this change there are a variety of other smaller fixups to the
general structure of the live-bootstrap rootfs.

- Creating a rootfs has become much simpler and is defined as code in
  go.sh. The new structure, for an about-to-be booted system, is

/
-- /steps (direct copy of steps/)
-- /distfiles (direct copy of distfiles/)
-- all files from seed/*
-- all files from seed/stage0-posix/*

- There is no longer such a thing as /usr/include/musl, this didn't
  really make any sense, as musl is the final libc used. Rather, to
  separate musl and mes, we have /usr/include/mes, which is much easier
  to work with.
- This also makes mes easier to blow away later.
- A few things that weren't properly in packages have been changed;
  checksum-transcriber, simple-patch, kexec-fiwix have all been given
  fully qualified package names.
- Highly breaking change, scripts now exist in their package directory
  but NOT WITH THE packagename.sh. Rather, they use pass1.sh, pass2.sh,
  etc. This avoids manual definition of passes.
  - Ditto with patches; default directory is patches, but then any patch
    series specific to a pass are named patches-passX.
This commit is contained in:
fosslinux 2023-11-07 10:51:23 +11:00
parent 0907cfd073
commit 6ed2e09f3a
546 changed files with 700 additions and 1299 deletions

View file

@ -0,0 +1,26 @@
SPDX-FileCopyrightText: 2023 Emily Trau <emily@downunderctf.com>
SPDX-License-Identifier: GPL-2.0-or-later
strcoll() does not exist in mes libc, change it to strcmp.
--- src/expr.c
+++ src/expr.c
@@ -332,7 +332,7 @@ nextarg (char *str)
return 0;
else
{
- int r = strcoll (*args, str) == 0;
+ int r = strcmp (*args, str) == 0;
args += r;
return r;
}
@@ -668,7 +668,7 @@ eval2 (void)
r = eval3 ();
tostring (l);
tostring (r);
- lval = strcoll (l->u.s, r->u.s);
+ lval = strcmp (l->u.s, r->u.s);
rval = 0;
if (toarith (l) && toarith (r))
{

View file

@ -0,0 +1,18 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: GPL-2.0-or-later
strcoll() does not exist in mes libc, change it to strcmp.
--- src/ls.c
+++ src/ls.c
@@ -2597,7 +2597,7 @@ xstrcoll (char const *a, char const *b)
{
int diff;
errno = 0;
- diff = strcoll (a, b);
+ diff = strcmp (a, b);
if (errno)
{
error (0, errno, _("cannot compare file names %s and %s"),

View file

@ -0,0 +1,44 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: GPL-2.0-or-later
mbstate_t is a struct that is required. However, it is not defined by mes libc.
This implementation was taken from glibc 2.32.
--- lib/quotearg.c 2002-11-23 07:08:10.000000000 +0000
+++ lib/quotearg.c 2021-01-17 19:41:59.461095532 +0000
@@ -21,6 +21,7 @@
# include <config.h>
#endif
+#include "mbstate_t.h"
#include "quotearg.h"
#include "xalloc.h"
--- lib/mbstate_t.h 1970-01-01 01:00:00.000000000 +0100
+++ lib/mbstate_t.h 2021-01-17 19:42:21.341658668 +0000
@@ -0,0 +1,23 @@
+#ifndef ____mbstate_t_defined
+#define ____mbstate_t_defined 1
+
+/* Integral type unchanged by default argument promotions that can
+ hold any value corresponding to members of the extended character
+ set, as well as at least one value that does not correspond to any
+ member of the extended character set. */
+#ifndef __WINT_TYPE__
+# define __WINT_TYPE__ unsigned int
+#endif
+
+/* Conversion state information. */
+typedef struct
+{
+ int __count;
+ union
+ {
+ __WINT_TYPE__ __wch;
+ char __wchb[4];
+ } __value; /* Value so far. */
+} mbstate_t;
+
+#endif

View file

@ -0,0 +1,20 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: GPL-2.0-or-later
modechange.h uses functions defined in sys/stat.h, so we need to move it to
after sys/stat.h include.
--- lib/modechange.c 2001-12-09 22:54:19.000000000 +0000
+++ lib/modechange.c 2021-01-17 18:34:22.016427148 +0000
@@ -28,8 +28,8 @@
# include <config.h>
#endif
-#include "modechange.h"
#include <sys/stat.h>
+#include "modechange.h"
#include "xstrtol.h"
#if STDC_HEADERS

View file

@ -0,0 +1,37 @@
SPDX-FileCopyrightText: 2023 Emily Trau <emily@downunderctf.com>
SPDX-License-Identifier: GPL-2.0-or-later
strcoll() does not exist in mes libc, change it to strcmp.
hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
--- lib/memcoll.c
+++ lib/memcoll.c
@@ -47,7 +47,7 @@ memcoll (char *s1, size_t s1len, char *s2, size_t s2len)
s1[s1len++] = '\0';
s2[s2len++] = '\0';
- while (! (errno = 0, (diff = strcoll (s1, s2)) || errno))
+ while (! (errno = 0, (diff = strcmp (s1, s2)) || errno))
{
/* strcoll found no difference, but perhaps it was fooled by NUL
characters in the data. Work around this problem by advancing
--- src/sort.c
+++ src/sort.c
@@ -91,13 +91,13 @@ double strtod ();
#define NEGATION_SIGN '-'
#define NUMERIC_ZERO '0'
+/* Nonzero if the corresponding locales are hard. */
+static int hard_LC_COLLATE;
#if HAVE_SETLOCALE
static char decimal_point;
static int th_sep; /* if CHAR_MAX + 1, then there is no thousands separator */
-/* Nonzero if the corresponding locales are hard. */
-static int hard_LC_COLLATE;
# if HAVE_NL_LANGINFO
static int hard_LC_TIME;
# endif

View file

@ -0,0 +1,27 @@
SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-2.0-or-later
uint64_t is not supported in tcc 0.9.27
--- lib/tempname.c 2002-12-01 10:40:32.000000000 +0000
+++ lib/tempname.c 2022-06-22 20:57:37.449423973 +0100
@@ -231,8 +231,8 @@
{
int len;
char *XXXXXX;
- static uint64_t value;
- uint64_t random_time_bits;
+ static unsigned long long value;
+ unsigned long long random_time_bits;
unsigned int count;
int fd = -1;
int save_errno = errno;
@@ -278,7 +278,7 @@
for (count = 0; count < attempts; value += 7777, ++count)
{
- uint64_t v = value;
+ unsigned long long v = value;
/* Fill in the random bits. */
XXXXXX[0] = letters[v % 62];

View file

@ -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++;

View file

@ -0,0 +1,19 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-2.0-or-later
getdate.c is pre-compiled from getdate.y
At this point we don't have bison yet and in any case getdate.y does not
compile when generated with modern bison.
--- src/touch.c.orig 2021-03-13 18:16:05.344355958 +0000
+++ src/touch.c 2021-03-13 18:16:26.204891355 +0000
@@ -306,7 +306,7 @@
case 'd':
flexible_date++;
- newtime = get_date (optarg, NULL);
+ newtime = 0;
if (newtime == (time_t) -1)
error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (optarg));
date_set++;

View file

@ -0,0 +1,68 @@
SPDX-FileCopyrightText: 2005 Paul Eggert <eggert@cs.ucla.edu>
SPDX-FileCopyrightText: 2023 Emily Trau <emily@downunderctf.com>
SPDX-License-Identifier: GPL-2.0-or-later
uniq: don't assume fopen cannot return stdin or stdout.
Backport of https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=786ebb2ceca72f69aa2de701671fb41f53cb1489
--- src/uniq.c
+++ src/uniq.c
@@ -30,6 +30,7 @@
#include "error.h"
#include "hard-locale.h"
#include "posixver.h"
+#include "stdio-safer.h"
#include "xmemcoll.h"
#include "xstrtol.h"
#include "memcasecmp.h"
@@ -267,20 +268,26 @@ check_file (const char *infile, const char *outfile)
FILE *ostream;
struct linebuffer lb1, lb2;
struct linebuffer *thisline, *prevline;
+ bool is_stdin = STREQ (infile, "-");
+ bool is_stdout = STREQ (outfile, "-");
- if (STREQ (infile, "-"))
+ if (is_stdin)
istream = stdin;
else
- istream = fopen (infile, "r");
- if (istream == NULL)
- error (EXIT_FAILURE, errno, "%s", infile);
+ {
+ istream = fopen_safer (infile, "r");
+ if (! istream)
+ error (EXIT_FAILURE, errno, "%s", infile);
+ }
- if (STREQ (outfile, "-"))
+ if (is_stdout)
ostream = stdout;
else
- ostream = fopen (outfile, "w");
- if (ostream == NULL)
- error (EXIT_FAILURE, errno, "%s", outfile);
+ {
+ ostream = fopen_safer (outfile, "w");
+ if (! ostream)
+ error (EXIT_FAILURE, errno, "%s", outfile);
+ }
thisline = &lb1;
prevline = &lb2;
@@ -377,12 +384,12 @@ check_file (const char *infile, const char *outfile)
}
closefiles:
- if (ferror (istream) || fclose (istream) == EOF)
+ if (!is_stdin && (ferror (istream) || fclose (istream) != 0))
error (EXIT_FAILURE, errno, _("error reading %s"), infile);
/* Close ostream only if it's not stdout -- the latter is closed
via the atexit-invoked close_stdout. */
- if (ostream != stdout && (ferror (ostream) || fclose (ostream) == EOF))
+ if (!is_stdout && (ferror (ostream) || fclose (ostream) != 0))
error (EXIT_FAILURE, errno, _("error writing %s"), outfile);
free (lb1.buffer);