summaryrefslogtreecommitdiff
path: root/include/git.sh
AgeCommit message (Collapse)Author
2024-06-22lib.sh: more unified config handlingLeah Rowe
replace it with logic that simply uses "." to load files directly. for this, "vcfg" is added as a variable in coreboot target.cfg files, referring to a directory in config/vendor/ containing a file named pkg.cfg, and this file then contains the same variables as the erstwhile config/vendor/sources config/git files are now directories, also containing pkg.cfg files each with the same variables as before, such as repository link and commit hash this change results in a noticeable reduction in code complexity within the build system. unified reading of config files: new function setcfg() added to lib.sh setcfg checks if a config exists. if a 2nd argument is passed, it is used as a return value for eval, otherwise a string calling err is passed. setcfg output is passed through eval, to set strings based on config; eval must be used, so that the variables are set within the same scope, otherwise they'd be set within setcfg which could lead to some whacky results. there's still a bit more more to do, but this single change results in a substantial reduction in code complexity. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20git.sh: revert modification to for loopLeah Rowe
i tried to be clever with this one, but it just made the script exit with an error. revert back to the old check (check whether one of either repo or repo backup is set) Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20minor code cleanup in the build systemLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20git.sh: general code cleanup in fetch_submodule()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20git.sh: reduced indentation on repo/file checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-20git.sh: simplified repo/backup checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-14unified checks for variable initialisationLeah Rowe
new function chkvars() does the job Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09minor code cleanup in the build systemLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09git.sh: hide e() output on for loopLeah Rowe
this for loop is a hack to make sure that all the sources get nuked (using nuke.list files). hide the messages so that they do not appear when running just any command in the trees script. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09git.sh: download xtree *before*, not afterLeah Rowe
downloading it after means that if an error occurs when downloading the xtree project, the main project will still be there and nothing will mandate the downloading of the xtree project. whereas, if we grab the xtree project first, then the main project won't get saved to src/ this makes the build system a bit more resilient under fault conditions, but otherwise doesn't change behaviour. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09git.sh: fix deletion path in nuke()Leah Rowe
i accidentally forgot to include src/ in the prefix Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09git.sh: further simplify nuke()Leah Rowe
it's a very compact nuke Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09git.sh: simplify link_crossgcc()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-09git.sh: simplify nuke()Leah Rowe
do not over-engineer such a trivial thing. seriously. all we're doing is nuking some files. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-08git.sh: support downloading *files* as submodulesLeah Rowe
when we download coreboot, we currently don't have a way to download crossgcc tarballs, so we rely on coreboot to do it, which means running the coreboot build system to do it; which means we don't get them in release archives, unless we add very hacky logic (which did exist and was removed). the problem with coreboot's build system is that it does not define backup links for each given tarball, instead relying on gnu.org exclusively, which seems OK at first because the gnu.org links actually return an HTTP 302 response leading to a random mirror, HOWEVER: the gnu.org 302 redirect often fails, and the download fails, causing an error. a mitigation for this has been to patch the coreboot build system to download directly from a single mirror that is reliable (in our case mirrorservice.org). while this mitigation mostly works, it's not redundant; the kent mirror is occasionally down too, and again we still have the problem of not being able to cleanly provide crossgcc tarballs inside release archives. do it in config/submodules, like so: module.list shall say the relative path of a given file, once downloaded, relative to the given source tree. module.cfg shall be re-used, in the same way as for git submodules, but: subfile="url" subfile_bkup="backup url" do this, instead of: subrepo="url" subrepo_bkup="backup url" example entries in module.list: util/crossgcc/tarballs/binutils-2.41.tar.xz util/crossgcc/tarballs/gcc-13.2.0.tar.xz util/crossgcc/tarballs/gmp-6.3.0.tar.xz util/crossgcc/tarballs/mpc-1.3.1.tar.gz util/crossgcc/tarballs/mpfr-4.2.1.tar.xz util/crossgcc/tarballs/nasm-2.16.01.tar.bz2 util/crossgcc/tarballs/R06_28_23.tar.gz the "subrev" variable (in module.cfg) has been renamed to "subhash", so that this makes sense, and that name is common to both subfile/subrepo. the download logic from the vendor scripts has been re-used for this purpose, and it verifies files using sha512sum. therefore: when specifying subrepo(git submodule), subhash will still be a sha1 checksum, but: when specifying subfile(file, e.g. tarball), subhash will be a sha512 checksum the logic for both (subrepo and subfile) is unified, and has this rule: subrepo* and subfile* must never *both* be declared. the actual configuration of coreboot crossgcc tarballs will be done in a follow-up commit. this commit simply modifies the code to accomodate this. over time, this feature could be used for many other files within source trees, and could perhaps be expanded to allow extracting source tarballs in leiu of git repositories, but the latter is not yet required and thus not implemented. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-08git.sh: remove unnecessary line breakLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: fix submodule pathLeah Rowe
i accidentally cloned to tmpdir rather than tmpgit oops! Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: simplify prep_submodules()Leah Rowe
copying the module list into tmpdir/ no longer makes sense, because it was only done before when we supported either running the list from "git submodule update", or module.list. since we only support handling of module.list, we can greatly simplify this function. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: unified handling of git clone/reset/amLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: simplify submodule handlingLeah Rowe
there were stragglers remaining, from when we used to actually run "git submodule update", but this was removed. clean up the submodule functions and merge them together. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: provide feedback for repository downloadsLeah Rowe
otherwise, it's not clear to the operator what's happening i'm normally against such verbose feedback, because it's bloat, but this minimal amount of feedback will make the build system more pleasant to use, especially during testing. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: download "depend" projects *before*Leah Rowe
don't do it after, because that means the main project is saved under src/ before we know whether the subrepo was downloaded. the "depend" variable (in config/git/) is no longer used for projects that go in subdirectories of a parent; now, we use config/submodules/ for this type of dependency. download the "depend" projects (as per config/git/) first. this way, if they fail, the main one will fail, but if they succeed and main fails, you can just run the main download again and it won't fail. this fixes a bug where, depending on how you download a set of projects and depending on the order which you do so, a given project can become un-downloadable on current design, because git will complain that a directory already exists. this fix is done not only in code (by this commit), but by prior configuration changes. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: reduced indentation in fetch_submoduleLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: reduced indentation in prep_submodulesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-07git.sh: *never* run git submodule updateLeah Rowe
only use config/submodules/ which the build system then uses to run git clones manually, replicating the submodules feature. we must never use a project's own gitmodules feature, because we can't easily control it. better to let it break first, and then figure out what modules to add manually, so that we have only what we need for each project. it's done this way, because git's own submodules feature doesn't have very good error checking in general, nor does it have good redundancy. with the current design, we can declare backup repositories for each submodule. we replicate it precisely. for example: 3rdparty/vboot this is a coreboot submodule, and we handle that in the coreboot trees. however, our current design also allows you to do this even if the upstream repository does not contain a .gitmodules file Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-06git.sh: use singletree() to decide submodulesLeah Rowe
now it no longer hardcodes a check for whether the project name is coreboot. this maintains the same behaviour but will now work for other multi-tree projects; in practise, the other multi-tree projects did not use .gitmodules files anyway, but some of them used config/submodules/ in our build system. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-02make GRUB multi-tree and re-add xhci patchesLeah Rowe
Re-add xHCI only on haswell and broadwell machines, where they are needed. Otherwise, keep the same GRUB code. The xHCI patches were removed because they caused issues on Sandybridge-based Dell Latitude laptops. See: https://codeberg.org/libreboot/lbmk/issues/216 The issue was not reported elsewhere, including on the Haswell/Broadwell hardware where they are needed, but the build system could only build one version of GRUB. The older machines do not need xHCI patches, because they either do not have xHCI patches, or work (in GRUB) because they're in EHCI mode when running the payload. So, the problem is that we need the xHCI patches for GRUB on Haswell/Broadwell hardware, but the patches break Sandybridge hardware, and we only had the one build of GRUB. To mitigate this problem, the build system now supports building multiple revisions of GRUB, with different patches, and each given coreboot target can say which GRUB tree to use by setting this in target.cfg: grubtree="xhci" In the above example, the "xhci" tree would be used. Some generic GRUB config has been moved to config/data/grub/ and config/grub/ now looks like config/coreboot/ - also, the grub.cfg file (named "payload" in each tree) is copied to the GRUB source tree as ".config", then added to GRUB's memdisk in the same way, as grub.cfg. Several other design changes had to be made because of this: * grub.cfg in memdisk no longer automatically jumps to one in CBFS, but now shows a menuentry for it if available * Certain commands in script/trees are disabled for GRUB, such as *config make commands. * gnulib is now defined in config/submodule/grub/, instead of config/git/grub - and this mitigates an existing bug where downloading gnulib first would make grub no longer possible to download in lbmk. The coreboot option CONFIG_FINALIZE_USB_ROUTE_XHCI has been re-enabled on: Dell OptiPlex 9020 MT, Dell OptiPlex 9020 SFF, Lenovo ThinkPad T440p and Lenovo ThinkPad W541 - now USB should work again in GRUB. The GRUB payload has been re-enabled on HP EliteBook 820 G2. This change will enable per-board GRUB optimisation in the future. For example, we hardcode what partitions and LVMs GRUB scans because * is slow on ICH7-based machines, due to GRUB's design. On other machines, * is reasonably fast, for automatically enumerating the list of devices for boot. Use of * (and other wildcards) could enable our GRUB payload to automatically boot more distros, with minimal fuss. This can be done at a later date, in subsequent revisions. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-30git.sh: do not remove .submodulesLeah Rowe
the reason for it is because sometimes the coreboot build system auto-downloads submodules which we don't want. however, we now pass UPDATED_SUBMODULES=1 in make, which disables this behaviour in coreboot's build system. therefore, remove this unnecessary logic. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-30import nuke() from cbmk cdce8ba70bLeah Rowe
cbmk revision: cdce8ba70b863ea3fe0ad7a4d7b27d0c5ca30421 as of date 30 May 2024 Canoeboot provides deblobbing, fully, on all sources, so as to provide a GNU FSDG compliant coreboot distro. Libreboot used to do this but now uses a more pragmatic Binary Blob Reduction Policy, allowing better hardware support in general. See: https://libreboot.org/news/policy.html Well! We sometimes still need to delete files in Libreboot, but for other reasons. For example, the poorly licensed strlcat.c file that we delete from U-Boot, in both projects. I currently hardcode such deletions in lbmk. After this revision, I will start using "nuke.list" files as in cbmk. Simply patching the sources to exclude such files, in this context, is not OK because then we are still including them but as diffs. This is why the nuke() function exists. Import Canoeboot's nuke technology. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-26general code cleanup in the build systemLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-24git.sh: break if a submodule clone succeedsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-24git.sh: allow finer control of git submodulesLeah Rowe
in each submodule configuration directory, a module.cfg file can now be provided. in it, the user can specify two repository links (main and backup) and a revision, like so: subrepo="repo link goes here" subrepo_bkup="backup repo link goes here" subrev="git revision id goes here" additionally: in the *main* project directory for the submodules, a module.list file can be provided. example entries: 3rdparty/vboot 3rdparty/libgfxinit if the module.list file is provided, only those submodules will be downloaded. this can be combined with the module.cfg files, if you wish, but it's optional. you can mix and match. example locations: multi-tree project: config/submodule/coreboot/default/module.list config/submodule/coreboot/default/vboot/module.cfg single-tree project: config/submodule/flashprog/module.list config/submodule/flashprog/foo/module.cfg *no* configuration files have been provided, in this commit, which means that the current behaviour is maintained. follow-up commits will absolutely configure the submodules. this is being done to reduce the number of modules downloaded, because we don't use most of the coreboot submodules that are downloaded, thus wasting bandwidth and the releases are also much bigger than necessary. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: move repo copying to a new functionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: move link_crossgcc to end of fileLeah Rowe
link_crossgcc is called after git_am_patches, so put it after ward Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: move xgcc linking to a new functionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: skip submodules if .gitmodules missingLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: merge patch_submodules in prep_submodulesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: split submodule handling to new functionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: remove errant line breakLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: remove another meaningless checkLeah Rowe
again, the directory in question is simply used in a for loop using asterisk (git_am_patches) and the for loop simply won't iterate if either the directory doesn't exist or it contains no items. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: shorter variable namesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: remove meaningless checkLeah Rowe
in the function that immediately follows, it starts two for loops that check every item in that directory, using the asterisk wildcard. if the directory does not exist, then the for loop will simply break on first pass. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-22git.sh: remove variable not meaningfully usedLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-21git.sh: fix invalid command in git_prep()Leah Rowe
"./update project trees" is a leftover from the old build system design, prior to audits. this particular call is for when xtree is defined, which means that a given tree must rely on the given coreboot tree defined by xtree. the "xtree" tree is downloaded, so that its crossgcc builds can be re-used to save time when building targets across many trees. this is because trees often use identical crossgcc builds. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-20git.sh: allow patching submodulesLeah Rowe
for single-tree project (e.g. flashprog): config/submodule/PROJECT/MODNAME/patches for multi-tree project (e.g. coreboot): config/submodule/PROJECT/TREE/MODNAME/patches MODNAME is e.g.: 3rdparty/vboot directory in coreboot: would become vboot (the submodule codepath is filtered to up to the final slash) another example: submodire src dir 3rdparty/foo/bar MODNAME would be "bar" Add whatever patches you like to a given submodule. An example patch is included in this commit. Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19git.sh: don't delete .git if src/project/projectLeah Rowe
otherwise, "./update release" will epicly fail Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-19git.sh: remove fetch_from_upstream()Leah Rowe
the function is very small and only called once, from fetch_project_trees() merge it into fetch_project_trees() Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-18git.sh: Remove .git if XBMK_RELEASE=yLeah Rowe
The build system already deletes .git in all source directories for each given release, but does so at the very end; it still does, but now it is deleted one by one per project, to save space during very large builds (release sizes vary wildly, depending on how many trees exist for coreboot basically). If you're building entirely in tmpfs (as I do), this could be a problem if you have lots of .git/ directories. This change reduces disk usage, or in the above example, memory usage when running the build system from tmpfs. This complements another recent change, where ROM images are compressed per target during release builds, rather than all at the very end of the process. It is part of a series of optimisations, to reduce the memory and disk usage of the build system, and to reduce I/O wastage in general. This change will not be the last of such changes! Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-11git.sh: remove errant commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27safer, simpler error handling in lbmkLeah Rowe
in shell scripts, a function named the same as a program included in the $PATH will override that program. for example, you could make a function called ls() and this would override the standand "ls". in lbmk, a part of it was first trying to run the "fail" command, deferring to "err", because some scripts call fail() which does some minor cleanup before calling err. in most cases, fail() is not defined, and it's possible that the user could have a program called "fail" in their $PATH, the behaviour of which we could not determine, and it could have disastrous effects. lbmk error handling has been re-engineered in such a way that the err function is defined in a variable, which defaults to err_ which calls err_, so defined under include/err.sh. in functions that require cleanup prior to error handling, a fail() function is still defined, and err is overridden, thus: err="fail" this change has made xx_() obsolete, so now only x_ is used. the x_ function is a wrapper that can be used to run a command and exit with non-zero status (from lbmk) if the command fails. the xx_ command did the same thing, but called fail() which would have called err(); now everything is $err example: rm -f "$filename" || err "could not delete file" this would now be: rm -f "$filename" || $err "could not delete file" overriding of err= must be done *after* including err.sh. for example: err="fail" . "include/err.sh" ^ this is wrong. instead, one must do: . "include/err.sh" err="fail" this is because err is set as a global variable under err.sh the new error handling is much cleaner, and safer. it also reduces the chance of mistakes such as: calling err when you meant to call fail. this is because the standard way is now to call $err, so you set err="fail" at the top of the script and all is well. Signed-off-by: Leah Rowe <leah@libreboot.org>