Skip to content

Commit 3e2663b

Browse files
authored
Merge pull request #419 from fosslinux/live-system-nochange
Live system nochange
2 parents 64ec796 + 438e018 commit 3e2663b

File tree

30 files changed

+294
-152
lines changed

30 files changed

+294
-152
lines changed

rootfs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def check_types():
159159
else:
160160
args.swap = 0
161161

162+
# Set constant umask
163+
os.umask(0o022)
164+
162165
# bootstrap.cfg
163166
try:
164167
os.remove(os.path.join('steps', 'bootstrap.cfg'))

seed/script-generator.c

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#define MAX_TOKEN 64
88
#define MAX_STRING 2048
99

10+
#include <bootstrappable.h>
1011
#include <stdio.h>
1112
#include <stdlib.h>
1213
#include <string.h>
13-
#include <bootstrappable.h>
1414

1515
struct Token {
1616
char *val;
@@ -22,7 +22,7 @@ typedef struct Token Token;
2222
#define TYPE_IMPROVE 2
2323
#define TYPE_DEFINE 3
2424
#define TYPE_JUMP 4
25-
#define TYPE_MAINT 5
25+
#define TYPE_UNINSTALL 5
2626

2727
struct Directive {
2828
Token *tok;
@@ -212,12 +212,12 @@ Token *fill(Token *tok, Directive *directive, int type) {
212212

213213
Token *logic(Token *tok, char **val) {
214214
/* logic = "("
215-
* (name |
216-
* (name "==" value) |
217-
* (name "!=" value) |
218-
* (logic "||" logic) |
219-
* (logic "&&" logic))
220-
* ")"
215+
* (name |
216+
* (name "==" value) |
217+
* (name "!=" value) |
218+
* (logic "||" logic) |
219+
* (logic "&&" logic))
220+
* ")"
221221
*/
222222

223223
char *lhs = tok->val;
@@ -237,15 +237,15 @@ Token *logic(Token *tok, char **val) {
237237
lhs = "False";
238238
}
239239
} else if (strcmp(tok->val, "!=") == 0) {
240-
/* Case for inequality. */
241-
rhs = tok->next->val;
242-
tok = tok->next->next;
243-
if (strcmp(get_var(lhs), rhs) == 0) {
244-
lhs = "False";
245-
} else {
246-
lhs = "True";
247-
}
248-
} else {
240+
/* Case for inequality. */
241+
rhs = tok->next->val;
242+
tok = tok->next->next;
243+
if (strcmp(get_var(lhs), rhs) == 0) {
244+
lhs = "False";
245+
} else {
246+
lhs = "True";
247+
}
248+
} else {
249249
fputs("Expected == or != after ", stderr);
250250
fputs(lhs, stderr);
251251
fputs(" in logic\n", stderr);
@@ -360,19 +360,31 @@ Token *define(Token *tok, Directive *directive) {
360360
}
361361

362362
int interpret(Directive *directive) {
363-
/* directive = (build | improve | define | jump | maint) predicate? */
363+
/* directive = (build | improve | define | jump | uninstall) predicate? */
364364
Token *tok = directive->tok;
365365
if (strcmp(tok->val, "build:") == 0) {
366366
tok = fill(tok->next, directive, TYPE_BUILD);
367367
} else if (strcmp(tok->val, "improve:") == 0) {
368368
tok = fill(tok->next, directive, TYPE_IMPROVE);
369369
} else if (strcmp(tok->val, "jump:") == 0) {
370370
tok = fill(tok->next, directive, TYPE_JUMP);
371-
} else if (strcmp(tok->val, "maint:") == 0) {
372-
tok = fill(tok->next, directive, TYPE_MAINT);
373371
} else if (strcmp(tok->val, "define:") == 0) {
374372
tok = define(tok->next, directive);
375373
return 1; /* There is no codegen for a define. */
374+
} else if (strcmp(tok->val, "uninstall:") == 0) {
375+
tok = fill(tok->next, directive, TYPE_UNINSTALL);
376+
while (tok != NULL) {
377+
if (strcmp(tok->val, "(") == 0) {
378+
break;
379+
}
380+
if (strlen(directive->arg) + strlen(tok->val) + 1 > MAX_STRING) {
381+
fputs("somehow you have managed to have too many uninstall arguments.\n", stderr);
382+
exit(1);
383+
}
384+
directive->arg = strcat(directive->arg, " ");
385+
directive->arg = strcat(directive->arg, tok->val);
386+
tok = tok->next;
387+
}
376388
}
377389

378390
if (tok != NULL) {
@@ -620,8 +632,10 @@ void generate(Directive *directives) {
620632
fclose(out);
621633
out = start_script(counter, bash_build);
622634
counter += 1;
623-
} else if (directive->type == TYPE_MAINT) {
624-
output_call_script(out, "maint", directive->arg, bash_build, 1);
635+
} else if (directive->type == TYPE_UNINSTALL) {
636+
fputs("uninstall ", out);
637+
fputs(directive->arg, out);
638+
fputs("\n", out);
625639
}
626640
}
627641
fclose(out);

steps/SHA256SUMS.pkgs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,20 @@ c490016e49bbf77e7f63071f7aa60e8290a0c67f017846def1c3f65bd10d5712 openssl-1.1.1l
8787
71864d042cdc564b65eab21360902c714e9b43f80a19689c5600589529b267e7 patch-2.7.6_0.tar.bz2
8888
5ae7fe43d62d1064c123d9813017015e5e8d5107d0e70f0199576141416ff81d perl-5.000_0.tar.bz2
8989
4994c55e3832649600f190079bd4779c463478a092b167098b1d00eff3358fbe perl-5.003_0.tar.bz2
90-
74d64a8af080022432fa94dba449090419d25b103d247710dc0b6102a4ad86a6 perl-5.10.1_0.tar.bz2
91-
fdccd3ba27a44d2149f159040414a04b39bfc72673ba36f50051b61199cc425c perl-5.32.1_0.tar.bz2
92-
101a791b6843b997ec10d5ce6dc32af2637f687772674eb6f1cdc1c8ff836a03 perl-5.6.2_0.tar.bz2
9390
ae6c84e55c2d9bcd7b80bf780ae6921fe890608123c9ba904e1b7d90759ade3d perl5.004-05_0.tar.bz2
9491
8cedd2240bbbd5bca65a1362998ed73884756aa7ff5208226d3fa22c68868052 perl5.005-03_0.tar.bz2
92+
74d64a8af080022432fa94dba449090419d25b103d247710dc0b6102a4ad86a6 perl-5.10.1_0.tar.bz2
93+
71ad3cadba5801cb19d4520825d4b3606713807b1eaa5eb3c49b3149bc2675ad perl-5.32.1_0.tar.bz2
94+
101a791b6843b997ec10d5ce6dc32af2637f687772674eb6f1cdc1c8ff836a03 perl-5.6.2_0.tar.bz2
9595
1b9d4260edf7b2241d10e4c4ad17d0f90047bd4bf42f2487a7133902529e9dfe pkg-config-0.29.2_0.tar.bz2
96-
1e882c3206f9d1de2a9be8b5c6ae4cc65e80a4de607bd521058577bf4169c0e9 python-2.0.1_0.tar.bz2
97-
aba9710341db75b78c7bc1eb4ef45b9496e23f7a356128af6c2b116ee0f3f31a python-2.0.1_1.tar.bz2
98-
d497c9b614194b941620bb5c5111fc72eca8cafd7d4f476eacb24fb7f909b614 python-2.3.7_0.tar.bz2
99-
8a977205933431c2a4207f647cb683b570dfdb0146e21abf5fab3f8426e1356b python-2.3.7_1.tar.bz2
100-
34e5083ed3e72da5aa5950acebf9e95464089d693e3d6a047a2b69b6103f5ca9 python-2.5.6_0.tar.bz2
96+
2f7198009e4d021d52ee4ce86241b4936fb88349c20cc8b6c286261368878c3c python-2.0.1_0.tar.bz2
97+
b5d86ddc98cfbc684b03f1c84c786caaad810d5e4c7be38089f324eb3c276ad9 python-2.0.1_1.tar.bz2
98+
396577cdd0cc61d76420a1771c64156e49e8f9d00430c82feb88ad933b341632 python-2.3.7_0.tar.bz2
99+
2499cb7f10f292c3506fbf1b6a876195179ec98edfe7b8c357140137a1449492 python-2.3.7_1.tar.bz2
100+
2dd06364e281da421a16251fa2258df201efd180461718f5a000012c4b2bdfe5 python-2.5.6_0.tar.bz2
101+
52ffb1ea6f2b893a6fd26f930c8ff63f78ddcc31ac3ec9c2ddade555205aa1ef python-3.11.1_0.tar.bz2
101102
3508248f299b73c50e3607c4c294d40face05170476a5026b0821aed69025863 python-3.1.5_0.tar.bz2
102103
12b1ffc7ec98ba8f807160b93ba69a694d5395567c3bcac1e49e8f8d1d50de43 python-3.1.5_1.tar.bz2
103-
52ffb1ea6f2b893a6fd26f930c8ff63f78ddcc31ac3ec9c2ddade555205aa1ef python-3.11.1_0.tar.bz2
104104
60b93253a2078f849f81e7e1ed6233e30702f03b1893640eee95671d814f5514 python-3.3.7_0.tar.bz2
105105
da7c8ec579dd225c0d8bee63d95aeeb27ac2d5a60d4eefe298508cbf86bf506c python-3.4.10_0.tar.bz2
106106
0be505f63205b4bc1b1421896c610468ad1a2194bbc4c9abf58f61685c2023d1 python-3.8.16_0.tar.bz2

steps/bash-2.05b/pass1.kaem

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ make
4747

4848
# Install
4949
install bash ${PREFIX}/bin/
50-
mkdir /bin/
51-
ln -s ${PREFIX}/bin/bash /bin/bash
52-
ln -s ${PREFIX}/bin/bash /bin/sh
53-
ln -s ${PREFIX}/bin/bash ${PREFIX}/bin/sh
50+
install bash ${PREFIX}/bin/sh
5451

5552
cd ../..
5653

steps/bash-5.2.15/pass1.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,5 @@ src_compile() {
5353

5454
src_install() {
5555
install -D bash "${DESTDIR}${PREFIX}/bin/bash"
56-
# Work around weird symlink bug
5756
install bash "${DESTDIR}${PREFIX}/bin/sh"
58-
59-
# Needs special handling b/c is currently running - tar doesn't like this
60-
rm -f "${PREFIX}/bin/bash" "${PREFIX}/bin/sh"
6157
}

steps/coreutils-5.0/pass2.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,3 @@ src_prepare() {
2222

2323
cp "${mk_dir}/pass2.mk" Makefile
2424
}
25-
26-
src_install() {
27-
default
28-
29-
# perl later requires /bin/pwd
30-
ln -s "${PREFIX}/bin/pwd" /bin/pwd
31-
}

steps/flex-2.5.11/pass1.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,3 @@ src_prepare() {
1414
src_compile() {
1515
make -j1 PREFIX="${PREFIX}"
1616
}
17-
18-
src_install() {
19-
if test -d /lex; then
20-
# Remove lex, later make install will symlink lex to flex
21-
rm -rf /lex
22-
rm -f "${PREFIX}/bin/lex"
23-
rm -f "${PREFIX}/lib/mes/libl.a"
24-
fi
25-
26-
default
27-
}

steps/flex-2.6.4/pass1.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ src_install() {
2020
cd src
2121
default
2222
cd ..
23-
24-
# Remove yacc, we won't need it any longer
25-
rm "${PREFIX}/bin/yacc"
2623
}

steps/helpers.sh

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#
88
# SPDX-License-Identifier: GPL-3.0-or-later
99

10+
# Set constant umask
11+
umask 022
12+
1013
# Get a list of files
1114
get_files() {
1215
echo "."
@@ -79,9 +82,11 @@ _grep() {
7982

8083
get_revision() {
8184
local pkg=$1
85+
local oldpwd="${PWD}"
8286
cd "/external/repo"
8387
# Get revision (n time this package has been built)
8488
revision=$( (ls -1 "${pkg}"* 2>/dev/null || true) | wc -l | sed 's/ *//g')
89+
cd "${oldpwd}"
8590
}
8691

8792
# Installs binary packages from an earlier run
@@ -93,11 +98,6 @@ bin_preseed() {
9398
if [ "${UPDATE_CHECKSUMS}" = "True" ] || src_checksum "${pkg}" $((revision)); then
9499
echo "${pkg}: installing prebuilt package."
95100
mv "${pkg}_${revision}"* /external/repo || return 1
96-
if [[ "${pkg}" == bash-* ]]; then
97-
# tar does not like overwriting running bash
98-
# shellcheck disable=SC2153
99-
rm -f "${PREFIX}/bin/bash" "${PREFIX}/bin/sh"
100-
fi
101101
cd "/external/repo"
102102
rm -f /tmp/filelist.txt
103103
src_apply "${pkg}" $((revision))
@@ -108,6 +108,65 @@ bin_preseed() {
108108
return 1
109109
}
110110

111+
# Removes either an existing package or file
112+
uninstall() {
113+
local in_fs in_pkg symlinks
114+
while [ $# -gt 0 ]; do
115+
removing="$1"
116+
case "${removing}" in
117+
/*)
118+
# Removing a file
119+
echo "removing file: ${removing}."
120+
rm -f "${removing}"
121+
;;
122+
*)
123+
echo "${removing}: uninstalling."
124+
local oldpwd="${PWD}"
125+
mkdir -p "/tmp/removing"
126+
cd "/tmp/removing"
127+
get_revision "${removing}"
128+
local filename="/external/repo/${removing}_$((revision-1)).tar.bz2"
129+
# Initial bzip2 built against meslibc has broken pipes
130+
bzip2 -dc "${filename}" | tar -xf -
131+
# reverse to have files before directories
132+
if command -v find >/dev/null 2>&1; then
133+
find . | sort -r > ../filelist
134+
else
135+
get_files . | tac > ../filelist
136+
fi
137+
# shellcheck disable=SC2162
138+
while read file; do
139+
if [ -d "${file}" ]; then
140+
if [ -z "$(ls -A "/${file}")" ]; then
141+
rmdir "/${file}"
142+
fi
143+
else
144+
# in some cases we might be uninstalling a file that has already been overwritten
145+
# in this case we don't want to remove it
146+
in_fs="$(sha256sum "${file}" 2>/dev/null | cut -d' ' -f1)"
147+
in_pkg="$(sha256sum "/${file}" 2>/dev/null | cut -d' ' -f1)"
148+
if [ "${in_fs}" = "${in_pkg}" ]; then
149+
rm -f "/${file}"
150+
fi
151+
if [ -h "${file}" ]; then
152+
symlinks="${symlinks} ${file}"
153+
fi
154+
fi
155+
done < ../filelist
156+
rm -f ../filelist
157+
for link in ${symlinks}; do
158+
if [ ! -e "/${link}" ]; then
159+
rm -f "/${link}"
160+
fi
161+
done
162+
cd "${oldpwd}"
163+
rm -rf "/tmp/removing"
164+
;;
165+
esac
166+
shift
167+
done
168+
}
169+
111170
# Common build steps
112171
# Build function provides a few common stages with default implementation
113172
# that can be overridden on per package basis in the build script.
@@ -169,6 +228,7 @@ build() {
169228
call $build_stage
170229

171230
echo "${pkg}: install to fakeroot."
231+
mkdir -p "${DESTDIR}"
172232
build_stage=src_install
173233
call $build_stage
174234

@@ -185,7 +245,6 @@ build() {
185245
echo "${pkg}: cleaning up."
186246
rm -rf "${SRCDIR}/${pkg}/build"
187247
rm -rf "${DESTDIR}"
188-
mkdir -p "${DESTDIR}"
189248

190249
echo "${pkg}: installing package."
191250
src_apply "${pkg}" "${revision}"
@@ -236,6 +295,7 @@ extract_file() {
236295
*)
237296
case "${f}" in
238297
*.tar* | *.tgz)
298+
# shellcheck disable=SC2153
239299
if test -e "${PREFIX}/libexec/rmt"; then
240300
# Again, we want to split out into words.
241301
# shellcheck disable=SC2086
@@ -410,6 +470,11 @@ src_apply() {
410470
TAR_PREFIX="/tmp/"
411471
fi
412472

473+
# Bash does not like to be overwritten
474+
if [[ "${pkg}" == bash-* ]]; then
475+
rm "${PREFIX}/bin/bash"
476+
fi
477+
413478
# Overwriting files is mega busted, so do it manually
414479
# shellcheck disable=SC2162
415480
if [ -e /tmp/filelist.txt ]; then

steps/improve/clean_sources.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-FileCopyrightText: 2023 Eduardo Sánchez Muñoz <[email protected]>
2+
# SPDX-FileCopyrightText: 2024 fosslinux <[email protected]>
23
#
34
# SPDX-License-Identifier: GPL-3.0-or-later
45

@@ -37,6 +38,11 @@ for source in "${DISTFILES}/"*; do
3738
rm "${source}"
3839
done
3940

41+
if [ -e "/external/repo-preseeded/linux-4.9.10_0.tar.bz2" ]; then
42+
# This is done in src_extract out of necessity usually -- I can't think of a better solution :(
43+
rm -f "${DISTFILES}/linux-4.9.10.tar.gz"
44+
fi
45+
4046
unset get_source_filename
4147
unset pkgs pkg line
4248
unset keep_sources keep_source

0 commit comments

Comments
 (0)