summaryrefslogtreecommitdiff
path: root/script/build
AgeCommit message (Collapse)Author
2023-10-02do not handle errors on mktemp in shell scriptsLeah Rowe
errors are not defined for mktemp, and the /tmp file system should be assumed reliable. if /tmp is *unreliable*, then this is not something that lbmk either can or should fix; the user clearly has bigger problems. manpages for mktemp do not define errors. it is assumed to be completely reliable. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01Greatly simplify error handling in shell scriptsLeah Rowe
Instead of having detailed error messages, run most commands through a function that calls err() under fault conditions. Where detail is still required, err() is still called manually. Where it isn't, the error message is simply whatever command was executed to cause the error. This results in a massive sloccount reduction for lbmk; specifically, 178 sloc reduction, or a 8.1% reduction. The total sloccount is now 2022, for shell scripts. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01build/boot/roms: optimise main() for code sizeLeah Rowe
handle everything in the getopts loop Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01build/boot/roms_helper: shorten variable namesLeah Rowe
also: further reduce the number of arguments passed, to certain functions as and when feasible, in cases where those are global variables that never change. the cbfstool argument in mkUbootRom wasn't even used. that function was only using the global variable, which again is only set once. i also shortened a few messages, removed a few errant line breaks and reduced sloccount by exactly 1 in main() by re-arranging how the shift command is used. it's mainly about shortening variable names, to then reduce the number of line breaks, but it's a surgical code size reduction in build/boot/roms. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-01build/boot/roms: dont do init/displaymode argumentLeah Rowe
These are only ever initialised globally, and set once. Other instances where they are set are only in cases where they are passed as argument, at the start of a function, so they are being *needlessly* re-set. Set them only once and use them globally. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms_helper: simplify rom file handlingLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms_helper: general code cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30general code formatting cleanup in shell scriptsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30simplify initialising variables in shell scriptsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: only do 1 custom kbd/payload/modeLeah Rowe
-k, -p and -d let you set keymap, payload and displaymode respectively, but the handling for this is buggy when passing multiple arguments. Support only one argument, for simplicity. This is how people use them anyway, and it makes lbmk less buggy. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: move usage() to include/boot.shLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/*: unified main() functionLeah Rowe
The *same* main() function is now used on both scripts. However, merging both scripts together would be less efficient on sloccount, and would be error-prone. The purpose of having roms_helper is that the variables get re-initialised the same way each time, for each board, automatically. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: split up handle_targets()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: check all targets before buildingLeah Rowe
If one of them doesn't exist, error out. Previously, a build would start but then it would error out later on. This implements the mentality: fail early, fail hard Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: merge handle_targets/build_targetLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: only run confirm_targets onceLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: rename buildrom to build_targetLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: split up main()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: simplify buildrom() handlingLeah Rowe
Only one for loop is required. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: support "all" if argument passedLeah Rowe
e.g. -k ukqwerty previously, this would not work: ./build boot roms -k ukqwerty all only this would work: ./build boot roms all this patch fixes the bug. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-30build/boot/roms: move help() to bottom of fileLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-27move build/command/options to include/option.shLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-27build/release/roms: simplify strip_rom_image()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25build/grub/*: move common strings to variablesLeah Rowe
also general cleanup of these scripts Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25build/grub/payload: split up main()Leah Rowe
also: the grub-mkstandalone command didn't have a || at the end, even though it did specify an err call. This has been corrected, so that the command now defers to err() under fault conditions. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25Update email address for Leah Rowe copyrightsLeah Rowe
also, some of them were out of date; years now updated. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-25Use SPDX license headers on all scriptsLeah Rowe
This results in much cleaner copyright and license declarations. SPDX headers are legally recognised and make auditing easier. Also, remove descriptions of each script, from each script. Libreboot documentation at docs/maintain/ describes them. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-16merge serprog scriptsRiku Viitanen
13 sloc reduction Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-12rel/src: fix multi-line commandLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-12serprog: list available boardsRiku Viitanen
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-11fix typo serprog -> vserprogRiku Viitanen
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-11make libopencm3 correctlyRiku Viitanen
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-11make clean libopencm3Riku Viitanen
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-11download and copy serprog related srcRiku Viitanen
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-11clean up pico-serprog for releaseRiku Viitanen
moved cmake files into a separate build directory. this can just be deleted for the source release. might as well use cmake for the actual build too. that makes repeated builds faster for some reason. Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-10make clean stm32-vserprog for releaseRiku Viitanen
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-10build/release/src: be more thorough deleting .gitLeah Rowe
a few were missed. nuke all of it from orbit. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-10build/release/src: delete elf/ in srcdirLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-10build/release/src: remove cbutils/ in srcdirLeah Rowe
the builds were being created within that srcdir, because build/release/src runs lbmk commands within it, and one of them is building (re-building) it. there's no point addressing this, other than rm -Rf Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-10build/release/src: remove errant codeLeah Rowe
the main lbmk script already creates these files, and these files are then copied by build/release/src so we don't need to re-create them here Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-10build/release/roms: use -T0 on serprog tarballsLeah Rowe
xz supports using multiple threads so use multiple threads Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-10build/boot/roms stragglers: properly handle errorsLeah Rowe
there were a few missing err calls i actually went through all of lbmk and found no instances where err calls were missing except in build/boot/roms_helper Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-10build/release/src: re-create symlinks, don't copyLeah Rowe
if you copy a symlink, you create a whole new file with the contents of what that symlink points to. what we need to do instead is re-create the symlinks. this is relevant for all symlinks to the main lbmk script, from the main directory of lbmk.git. this avoids there being multiple copies of the main lbmk script, in release archives. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-09scripts: use printf, not echo, where appropriateLeah Rowe
printf has more universal behaviour, across various implementations of sh, so it's better to use this. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-09scripts: better handling of printf: stdout/stderrLeah Rowe
in some cases, messages that should be considered errors or warnings, were being written to the standard output, rather than written as error messages. also: one or two printf statements should specifically avoid printing errors (to any file); in these cases, stdout has been redirected to /dev/null Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-09build/release/roms: remove errant line breakLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-09use sha512sum to check downloads, not sha1sumLeah Rowe
sha-1 has known collision issues, which may not be readily exploitable yet (in our context), but we should ideally use a more secure method for checking file integrity. therefore, use sha-2 (sha512sum) for checking files. this is slower than sha-1, but checksum verification is only a minor part of what lbmk does, so the overall effect on build times is quite negligible. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-09-09Merge pull request 'Add stm32-vserprog' (#129) from Riku_V/lbmk:stm32 into ↵Leah Rowe
master Reviewed-on: https://codeberg.org/libreboot/lbmk/pulls/129
2023-09-09Add stm32-vserprogRiku Viitanen
Tested on a Nucleo-F042K6. That has an onboard stlink: `st-flash --format ihex write bin/serprog_stm32/serprog_nucleo-f042k6.hex` The usb port used for flashing is separate, its is exposed on the pin header instead. Check boards/nucleo-f042k6.h for usb pinout. Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
2023-09-09build/boot/rom: only insert scan.cfg if neededLeah Rowe
where it is set to "both" (grub_scan_disk), inserting scan.cfg is superfluous, because grub.cfg defaults to both anyway, unless otherwise specified by scan.cfg, and only if that file exists within cbfs. thus, save a bit of build time (only a slight saving) Signed-off-by: Leah Rowe <leah@libreboot.org>