summaryrefslogtreecommitdiff
path: root/include/init.sh
AgeCommit message (Collapse)Author
3 daysinit.sh: reduce the use of eval statementsLeah Rowe
also remove the unused _nogit variable Signed-off-by: Leah Rowe <leah@libreboot.org>
4 daysinit.sh: break up xbmk_set_envLeah Rowe
what this function does will differ wildly, depending on whether it's a child instance or a parent instance of xbmk. break up this function accordingly. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 daysinit.sh: remove comment in pybinLeah Rowe
the following checks on the path mitigates the lack of error handling in the findpath command that sets pypath. this was all thought of when i initially wrote this code. it's perfectly fine. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 daysxbmk: tidy up some if statementsLeah Rowe
this is an extension of the previous work to unroll most of the condensed code lines. Signed-off-by: Leah Rowe <leah@libreboot.org>
9 daysinit.sh: remove TODO noteLeah Rowe
on further inspection, the following check ensures that the python version number is 3. if anything went wrong, the possibility alluded to in the comment wouldn't actually matter in practise. Signed-off-by: Leah Rowe <leah@libreboot.org>
10 daysinit.sh: create TMPDIR *after* suid checkLeah Rowe
otherwise, it may get created as the root user, disabling further use of lbmk until manual user intervention. Signed-off-by: Leah Rowe <leah@libreboot.org>
10 daysinit.sh: remove symlink check on XBMK_CACHELeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
10 daysinit.sh: switch back to old TMPDIR checksLeah Rowe
the new check is still retained, to the extent that the lock file still contains the TMPDIR string, and it's checked whether this changed during execution. however, the current TMPDIR handling is over-engineered and prevents the re-use of project source caches when doing release builds; this means that the release builds happen much more slowly, especially for slow internet connections. this change *fixes* that bug. now release builds once again re-use the main cache/ directory. Signed-off-by: Leah Rowe <leah@libreboot.org>
10 daysmake notices a bit more readableLeah Rowe
add line breaks, so that the license and author are visually separated. this makes it easier to read. Signed-off-by: Leah Rowe <leah@libreboot.org>
10 daysxbmk: cleanup of recent code refactoringLeah Rowe
be a bit less pedantic about if else clauses. leave the big ones still with then on separate lines, where else is specified. also unroll a few condensed code lines where i missed a few. sloccount 2303 in lbmk. that's still only slightly bigger than libreboot 20260907 which was 2180, and still much smaller than libreboot 20230625 which was 3322. this is *without* the condensed codelines, so now the only thing that's reduced is the overall amount of logic present in the build system. and i should clarify that lbmk is presently much more powerful than both of those two versions (20160907/20230625). the 2016 one is useful for comparison historically, since that was the last major version of libreboot prior to the great second coming of leah in 2021; and the 2023 june release was basically the last one before the great audits of 2023 to 2025 began. not to brag (not much anyway), but all of this means that lbmk is an insanely efficient build system, considering all the features it has and what it does. i unrolled the condensed code style in lbmk, making the scripts a lot easier to read, because i received complainst about the condensed style previously used; nicholas chin and alper nebi yasak both told me that it sucked, and riku viitanen had hinted at that same fact several months prior. so hopefully now, lbmk is a bit nicer. those and other people often find it challenging to challenge me because for reason they assume i'll get upset and fly off the handle, but it's the opposite. i want constant criticism, so that i know to improve! Signed-off-by: Leah Rowe <leah@libreboot.org>
11 daysinit.sh: unroll condensed code linesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
13 daysinit.sh: make TMPDIR *after* calling xbmkpkgLeah Rowe
otherwise, running ./mk dependencies as root will create xbmkwd/ (temporary directories) as root, which will then prevent non-root instances of lbmk from being able to make temporary files. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-18Revert "xbmk: don't use backticks for command substitution"Leah Rowe
This reverts commit 4999a49de39667b3239fc2010d0e99c958b29417.
2025-09-13xbmk: much more verbose error messagesLeah Rowe
use the new functionality in err(), whereby a given function name and arguments can be provided, for debugging purposes. something similar was already done in a few places, and replaced with this unified functionality. this patch will make xbmk much easier to debug, under fault conditions. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-11xbmk: don't use backticks for command substitutionLeah Rowe
the newer way handles escaped characters better, and it can be nested more easily. it's also more readable. personally, i prefer the old way, because it's more minimalist, but it occurs to me that a lot of people nowadays don't know about backticks, but they do know of the modern way. to make the code more readable, i have modernised it. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-09init.sh: write-protect the lock file on startupLeah Rowe
you can still remove it with the -f flag on rm, but xbmk only does that on exit from the main parent instance, or after each build stage in release.sh because of this, the user could still manually override the lock file; this would cause running instances of lbmk to restart wrongly as parent instances. there's no way to fix any of this, but users don't normally put -f in their rm commands. however, this is also a preventative bug fix. if a bug is ever caused in the future, where the lock file is created erroneously, the write protection will prevent that, so long as *it* is still done. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-07init.sh/tree.sh: put PATH dirs in xbtmpLeah Rowe
e.g. gnupath, xbmkpath these currently go in XBMK_CACHE/, which is bad because they're meant to be temporary. XBMK_CACHE is for permanent files. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-07init.sh: bail if date is non-GNU (for now)Leah Rowe
We currently use GNU-only options in the date command, when initialising a Git repository. This isn't a problem in practise, on non-GNU implementations if not initialising a Git repository, because it's only used in that situation. In practise, only those systems with GNU coreutils and libc are used to compile releases, so this is OK for me at least. Future portability improvements will correct the issue, and then this error check can be removed. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-07lib/init.sh: sanitize the version stringLeah Rowe
the release functions in release.sh rely on the version string *not* being a path containing slashes. just a single string e.g. "foo", not e.g. "foo/bar" this is because several checks there make that assumption. in practise, we always ensure that tags and such do not contain these characters. however, someone else working on their own version of xbmk might not know of this design flaw, so let's try to correct it in code. we can add more filtering as designed, in the relevant function (xbmk_sanitize_version). Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-02xbmk: remove xbloc, re-use xbtmp insteadLeah Rowe
we no longer separate them. xbloc was the on-disk tmp directory, whereas xbtmp used to be in /tmp which we assumed to be tmpfs (it may not be, but often is on many workstation setups - and our documentation recommended doing this). as mentioned in the previous commit, benchmarking shows little speed difference using tmpfs /tmp versus on-disk /tmp, for our purposes at least. therefore, the handling of tmp files is being greatly simplified. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-09-02init.sh: put TMPDIR inside xbmkpwd, not /tmpLeah Rowe
This way, all operations will be done inside the xbmk work directory. This is being done, so that I can then reliably sandybox certain commands in future commits, for example the "rm" command. This will also allow me to unify the location of all temporary files, in future commits. I previously used the /tmp directory because it's tmpfs-based on many setups, and this is great for performance. However, in practise, I never noticed any difference in performance when benchmarking it (testing /tmp on-disk versus tmpfs). Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-31init.sh: tidy up xbmk_set_envLeah Rowe
this is a general function that sets variables, but there are many types of variables to be set. rather than have all the logic inside this function, handle it in subfunctions called by xbmk_set_env. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-31init.sh: tidy up xbmk_child_set_tmpLeah Rowe
the checks of xbmk cache/threads is unrelated. this has been moved back to the calling function. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-31init.sh: remove unnecessary lockfile checksLeah Rowe
we don't need these anymore, because we now know whether or not the lock file exists in these cases. this is because child/parent instance determination is now done based on the presence of that file, rather than how TMPDIR is set; and TMPDIR is now set accordingly, via more robust logic as in previous patching. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-31init.sh: move TMPDIR handling to own functionsLeah Rowe
this makes xbmk_set_env easier to read Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-31init.sh: prevent race condition with TMPDIRLeah Rowe
it is extremely unlikely to occur, but this patch reduces the likelihood even further. that unlikely occurance is: when creating a TMPDIR, it's possible that it was already created before. this is OK on child instances, where that is the intended behaviour (unified TMPDIR), but not for parent instances. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-08-31init.sh: MUCH safer TMPDIR handlingLeah Rowe
we previously checked whether xbmk was running a child instance, based on the initialisation of TMPDIR, but this relied on unreliable string substitutions, which could not be made inherently reliable. there were also no checks on whether the given TMPDIR, even if correct, was a directory or whether it was a symlink; there were also no checks on whether it changed. now with this change, child instances are detected by the presence of the lock file. the parent instance writes the generated TMPDIR location in that file, and this is checked again in the child instance, to ensure that the TMPDIR didn't change; it also errors out if the TMPDIR doesn't exist or if it is a symlink. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-26xbmk: rename xbmklocal/xbmktmp variablesLeah Rowe
shorten them Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-25init.sh: error out if .git/ is a symlinkLeah Rowe
the current behaviour is a relic from the older lbmk design, before recent auditing. the current logic would cause xbmk to continue execution, going into a child process with .git/ being a symlink. The .git/ directory should never be a symlink, because it is extremely error-prone. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-20Revert "vendor.sh: optimise find_me()"Leah Rowe
This reverts commit fb7aaa78bb080a473bdf0edf449bf08045e8366c. it caused a few issues. will re-do later the old code isn't really broken, just inefficient, because several files are scanned twice, but in practise the overhead isn't that great The error occurs sometimes, when bruteforcing me.bin: ERROR ./mk: Unhandled error for: mv /home/user/lbmk/tmp/me.bin /home/user/lbmk/cache/tmpdl/check This revert should fix the issue, for now.
2025-05-20vendor.sh: optimise find_me()Leah Rowe
i'm adding characters to 7ztest, which isn't being passed on through because everything runs in subshells; the next pass would default back to the original string, so a given file may be checked multiple times. fix this by mitigation; use the random string from mktemp as a suffix instead. in practice, this has not affected performance much, but it will nevertheless avoid unnecessary work by xbmk. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-19init.sh: looser XBMK_THREADS validationLeah Rowe
on child processes, we can simply correct it. we currently provide an error message, but this is silly. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-19init.sh: Hardcode XBMK_CACHE for integrityLeah Rowe
I never really intended for this to be configurable, but the cache directory is also used during release builds. There's too much that can go wrong, letting the user decide where their cache is. Simplify it by hardcoding. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: merge xbmk_lock() with xbmk_set_env()Leah Rowe
it's just two lines, and we want much more granular control of where the lock is enforced. it should be JUST after confirming that the instance is a parent. it is at this moment that we should bail if a lock file exists, because this signals that another instance of xbmk is running. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: move xbmk_set_versionLeah Rowe
it's called before set_pyver, so move it above that Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: set pyver from set_envLeah Rowe
it's related to this function, no point calling from main Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: merge xbmk_mkdirs with set_envLeah Rowe
it's just two lines, and they relate. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: check version/versiondate once readLeah Rowe
once again, we are being stricter in child instances. we must ensure that these variables are set by xbmk. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: error if version not readLeah Rowe
we no longer rely on the .git version being read by child instances, so we MUST ensure that it is being read. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: only update version files on parentLeah Rowe
don't update them on child instances, since it's a waste of time; the lock file prevents further execution, so we are just wasting time writing to disk. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: simplify unknown version creationLeah Rowe
we don't need to read or write a file at all, in that case. we only then need to generate one if running ./mk release. the scenario in which no .git and no version files exist is when someone grabs the build system from a snapshot generated by e.g. forgejo instances. it's ill advised, so we advise against it, but it is mitigated in code. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: only set xbmk version on parent instanceLeah Rowe
On child instances, we need only read. Apply the principle of least privilege. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: initialise variables AFTER pathLeah Rowe
That way, unnecessary work is avoided on child instances. Of course, the current check assumes that TMPDIR wasn't already set by a wily user before running lbmk, but then those sorts of users probably know what they're doing. If they don't know, they will soon find out. Therefore, I have added additional checks on child instances, preventing the build system from running if XBMK_CACHE is not set; if it isn't, then that could very easy lead to certain system files being overwritten. The user must never know what happens if XBMK_CACHE is unset. We simply will not allow it. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: merge create_pathdirs with set_pyverLeah Rowe
all this function does now is create the python symlink, based on work that was already performed in set_pyver Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: Set python version only on parentLeah Rowe
Do it after the creation of xbmkpath. This avoids performing an unnecessary check, since PATH will have already been corrected for child instances; Python will already be correct there. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: remove useless commandLeah Rowe
we mkdir -p xbmklocal, only to remkdir it immediately afterward, which is the intended behaviour; on parent instances, xbmklocal is to be re-created fresh. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: remove useless commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: xbmk_create_tmpdir to xbmk_mkdirsLeah Rowe
this function now simply creates directories that lbmk will use, rather than creating specific directories. Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: move gnupath creation to create_tmpdirLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-05-18init.sh: move PATH init to set_envLeah Rowe
we must only set this in the parent instance, not child instances. this prevents the variable from being over-populated with repeated entries. Signed-off-by: Leah Rowe <leah@libreboot.org>