Commit Graph

1335 Commits

Author SHA1 Message Date
Lyndon Brown a542d52141 rename binary_loopback_cfg to binary_grub_cfg
when loopback support was introduced, it initially duplicated the code
for generating a grub2 config, before the duplicated code was removed from
the grub-pc script, effectively thus moving grub config generation to the
loopback feature script.

grub-efi support was added after this.

this results in a misleading filename, since the `binary_loopback_cfg`
script is essential for use of grub-pc|grub-efi, and actually only has a
single line of code on top that's needed for adding actual loopback
support on top. (when grub-pc and grub-efi are not used, the entire script
is still needed for loopback support to work).

so here we rename it to make better sense, and correct/clarify bits of
documentation.

Gbp-Dch: Short
2020-05-04 22:15:09 +01:00
Lyndon Brown 3a523c3fc1 binary_iso: properly handle multiple bootloaders
with LB_BOOTLOADER_BIOS and LB_BOOTLOADER_EFI introduced, we can simplify
and correct things here.

previously it was possible for more than one of each type to be added.

Gbp-Dch: Short
2020-05-04 21:48:03 +01:00
Lyndon Brown d7883ec32b config: improve BIOS/EFI bootloader selection handling
the design choice from when EFI support was introduced was to change
`--bootloader` to `--bootloaders`, with users specifying their selection
of BIOS and EFI bootloaders together. at this time there were not even any
decent validation checks being performed, and invalid combinations could
cause some chaos.

since then proper validation was put in place, including checking that
only a single instance of each of BIOS and EFI bootloaders exists in the
selection.

here we tweak things such that we stick with the same option, but we split
the selection up such that we store the BIOS and EFI selections separately
within the saved config file, and offer it up to scripts to help simplify
those scripts.

we must however retain support for splitting from the combined option,
both because we still use it in the combined option, and for backwards
compatibility with older saved configs.

Gbp-Dch: Short
2020-05-04 21:40:13 +01:00
Lyndon Brown 3f840aeeba fully validate BIOS/EFI bootloader combinations
thus far, config bootloader validation only did the basic check that each
bootloader specified was a known and supported bootloader, it did not check
combinations.

it now checks combinations, and strips out the previous "bootloader role"
stuff.

the no-bootloaders warning is duplicated, covering two slightly different
situations (empty string, and whitespace string). this is anticipated to
be just temporary, with this just being the first step in better handling
bootloader selections.

Gbp-Dch: Short
2020-05-04 21:40:13 +01:00
Lyndon Brown f3a818da9a binary_hdd: remove incorrect local scope
the "FIXME" function wrapper is just to temporarily disable the code.

Gbp-Dch: Ignore
2020-05-04 21:40:08 +01:00
Lyndon Brown 976be9f44b indentation fix
Gbp-Dch: Ignore
2020-05-04 17:40:23 +01:00
Lyndon Brown 7ad96bd644 fix redundant and incorrect source selections
"grub" presumably was what is now called "grub-legacy"

removed both because there is already a proper piece of code adding
bootloader packages.

Gbp-Dch: Ignore
2020-05-04 17:38:53 +01:00
Lyndon Brown cb2d9a0fe4 fix another overlooked "grub" -> "grub-legacy" instance
Gbp-Dch: Ignore
2020-05-04 17:37:14 +01:00
Lyndon Brown 943c8fb5fe extend config validation to all build components
while `lb build` ran the config validation check, spotting invalid configs
and stopping with an error, the major build stages if executed directly did
not, nor did the component stages.

here we move execution of the validation function into the common init
function, with an exported variable used to indicate that validation has
been performed. thus validation is performed no matter what part of the
build system you execute, but only once.

Gbp-Dch: Short
2020-05-04 13:26:19 +01:00
Lyndon Brown 7acd1f488f get rid of a couple of useless variables
Gbp-Dch: Ignore
2020-05-04 13:21:12 +01:00
Lyndon Brown 76459a39cd clean: tweak init
`Init_config_data` is more suited to build scripts than here. note that
it's not used in `config` either. this deliberately does not pass along
arguments to it because `Arguments()` can only handle the basic common
options, not the `clean` set. this is somewhat confusing and causes a
pointless execution of `getopt`. furthermore the function is expanding
slightly further beyond it's original scope, with yet more change coming
that's unsuitable for `clean`, so it makes sense to avoid using the
function here just for the couple of function calls needed.

validation of the config is disabled, as it is not performed currently.
it is not clear if it should be enabled or not for `clean`. it may be
useful to not validate, if we wish to be able to provide users with an
option to be able to delete the config.

Gbp-Dch: Ignore
2020-05-04 13:14:57 +01:00
Lyndon Brown 9bc35759aa config: fix stale live-build version in iso-preparer
using `$VERSION` as part of the default `$LB_ISO_PREPARER` means that when
you simply run `lb config` once, this variable is stored as a part of the
string, and replaced on use, but if you run `lb config` twice, it gets
replaced with a fixed version, that is then used in all subsequent builds.

let's replace with a placeholder (`@LB_VERSION@`) that can be used both in
the default, or in user strings, and will be replaced on use only.

this means that subsequent builds will always reflect the actual version
of live-build used.

Gbp-Dch: Ignore
2020-05-03 23:20:39 +01:00
Lyndon Brown 26a89a45e5 disk_info: obey new UTC timestamp control 2020-05-03 23:20:39 +01:00
Lyndon Brown ebf4b04b7f source_disk: de-duplicate date construction
Gbp-Dch: Ignore
2020-05-03 23:20:39 +01:00
Lyndon Brown 558942eccb syslinux: obey new UTC timestamp control 2020-05-03 23:20:39 +01:00
Lyndon Brown 6cf3321d84 config: provide UTC timestamp control
`DATE_UTC_OPTION` is set in `Prepare_config()` for use by scripts, even
though only a few scripts will actually use it, since it allows those
scripts to be cleaner. we may want to possibly extend this as a
`DATE_OPTIONS` variable perhaps as part of enabling proper reproduciblity.

Gbp-Dch: Short
2020-05-03 22:19:43 +01:00
Lyndon Brown 23f02ec7ee syslinux: support timezone date component
since date is not obtained as UTC, timezone is an important detail of
understanding the given time, which users may want to make use of.

Gbp-Dch: Short
2020-05-03 20:31:45 +01:00
Lyndon Brown dc64d8235d syslinux: fix date construction accuracy issue
don't construct each part from a fresh "now", which can result in
inaccuracies in the overall date due to "now" drifting over the individual
date calls. instead feed the full date that was obtained back into it when
extracting the component parts.

Gbp-Dch: Ignore
2020-05-03 20:31:43 +01:00
Lyndon Brown 7ad69658b2 config: fix storage of --jffs2-eraseblock value
broken since it's introduction in 9ffb223d70

Gbp-Dch: Short
2020-05-03 15:08:28 +01:00
Lyndon Brown 918fe8ce25 config: small output alignment fix
Gbp-Dch: Ignore
2020-05-03 12:39:42 +01:00
Lyndon Brown 7276d0213f fix usage/help/man bugs
- the definition of $PROGRAM as used in $USAGE strings defined in each
   script has been broken for a long time, being simply "lb" when it needs
   to be "lb COMMAND".
 - `config` changed $PROGRAM to "lb config" thus its output was correct in
   this regard unlike everything else, but with the switch to a more
   "intelligent" `Man()` function recently, it means that instead of
   `man lb config`, what was actually run was `man lb config config`,
   which displayed the manpage, then on exiting with `q`, it showed some
   sort of index line todo with a "config" search (no exact manpage
   match?), for which you had to enter `ctrl+c` to get rid of.

this revises things to fix the issues, minimising change by changing
$PROGRAM to "lb COMMAND", with the frontend overriding this.

Gbp-Dch: Ignore
2020-05-03 01:38:17 +01:00
Lyndon Brown 96c7977732 archives: output actual error for bad pass param
Gbp-Dch: Ignore
2020-05-03 01:31:47 +01:00
Lyndon Brown 43b4f9cdf6 adjust action arg consumption order
did not properly consider all usage cases properly in deciding placement.

this captured `--usage` in `$PROGRAM --usage` as the action for instance.

Gbp-Dch: Ignore
2020-05-03 01:31:47 +01:00
Lyndon Brown 640a25f78d clean: output error on invalid argument 2020-05-02 18:44:12 +01:00
Lyndon Brown 22d8ac15db options: de-duplicate common option handling 2020-05-02 18:18:49 +01:00
Lyndon Brown 55e17b1e25 config: refactor basic package list construction
Gbp-Dch: Ignore
2020-05-02 17:07:32 +01:00
Lyndon Brown b2b2602429 clean: expand debugging
Gbp-Dch: Ignore
2020-05-02 17:07:29 +01:00
Lyndon Brown f20b5b4d0d clean: fix missing 'noauto' param for substage execution
these should be bypassing the possibility of running the auto script
surely, just like how this is done for `--all`, otherwise you pass through
the auto file twice.

Gbp-Dch: Ignore
2020-05-02 14:59:19 +01:00
Lyndon Brown 2d4b2c9e76 clean: improve arg handling
- detect lack of options using actual arg count rather than first arg
   being an empty string.
 - fix string splitting issues by looping properly on "${@}"
 - tidier

Gbp-Dch: Ignore
2020-05-02 14:59:12 +01:00
Lyndon Brown 2d7ff4934d improve stagefiles encapsulation
- added and used Stagefiles_dir()
 - added and used Stagefile_exists()

pretty self explanatory.

Gbp-Dch: Short
2020-05-02 14:49:45 +01:00
Lyndon Brown b20979334c caching: output error on invalid action param
for bootstrap, the check is moved to the case statement for greater
robustness, and for consistency with other scripts.

Gbp-Dch: Ignore
2020-05-02 14:04:12 +01:00
Lyndon Brown da1fab1161 output error for incorrect action in chroot prep scripts
...alongside printing usage (which is perhaps unnecessary), so that it is
actually clear to users that a problem occurred, and what.

and capture it before option processing of remaining args.

Gbp-Dch: Ignore
2020-05-02 13:46:41 +01:00
Lyndon Brown 5f318c5a44 tidy up Echo_breakage()
- it's only used by the debootstrap script after alternatives were dropped
   long ago, so let's move it, avoiding it being loaded for everything
   else.
 - there's no need to pass printing another message through it.
 - there's little point in making the sid distinction if you happen to
   decide to build sid, it's a given that it's less stable than stable.

really, is there any need for this at all?

Gbp-Dch: Ignore
2020-05-02 13:06:17 +01:00
Lyndon Brown d7d0798e46 debootstrap: remove useless obtaining debootstrap verbose help strings
Gbp-Dch: Ignore
2020-05-02 12:54:22 +01:00
Lyndon Brown f78001144b move and rename Common_config_files()
for better encapsulation, and for consistency with other config file
handling functions in the new location.

Gbp-Dch: Ignore
2020-05-02 02:38:26 +01:00
Lyndon Brown 6ebac9cc5b grub2: fix duplicate live entries
in tweaking a previous commit to remove some excessive change before
submission, i mistakenly identified the part of the sed replacement
restored here as being unnecessary to its functionality, but in fact it is.
without it the placeholder is not actually removed.

the lack of removal of the placeholder meant that you ended up with
duplicate copies of the live menu entries.

Gbp-Dch: Ignore
2020-05-01 22:02:31 +01:00
Lyndon Brown 578dbee516 bootloaders: change 'Advanced options' to 'Utilities'
more fitting now that we've moved the advanced installer entries
out to a different submenu, leaving just memtest (and HDT on
syslinux).

the advanced.cfg file is also renamed to utilities.cfg in the syslinux
case, but in a backwards compatible way of moving the user advanced.cfg
file over the new one, if the user provides a file with the old name.
alternatively we could just leave the old name in place, but that would be
a little odd.

Gbp-Dch: Short
2020-05-01 12:38:04 +02:00
johnraff 0e5d0483e5 Replace 'which' with 'command -v' to test for the existance of an executable
This is considered to be more robust.

Two instances remain:

scripts/build/chroot_archives, line 257:
if [ "${LB_APT}" = "aptitude" ] && [ ! $(Chroot chroot "which aptitude") ]
The command is run inside a chroot where the environment might be special,
and would need further testing.

manpages/Makefile, line 42:
@if [ ! -x "$$(which po4a 2>/dev/null)" ]; \
I am insufficiently familiar with makefile syntax to edit this.
2020-05-01 09:59:11 +00:00
Lyndon Brown fd18d46e0e grub2|loopback: avoid perl for live entry creation, use temp file
instead of cramming the live entries into a string via a layer of functions
for terminating entries with newlines, which we then have to run through
perl to tweak the newlines for correct use with sed... let's write the
entries to a temp file, then use that file in the sed replacement.

the helper functions injecting newlines to the end of entries as they were
built into a long string have obviously become unnecessary and so were
removed. one function was renamed for reasons of consistency and clarity.

the file is initially deleted before use for reasons of wanting to bullet
proof the codebase to work properly under conditions of recovering from
failure/cancellation, `--force` re-running and such.

this removes the last use of perl.

Gbp-Dch: Short
2020-05-01 09:40:40 +00:00
Lyndon Brown 72321c2b9b config: optimise --ignore-system-defaults
Gbp-Dch: Ignore
2020-04-30 19:37:51 +01:00
Lyndon Brown b4156e146f workaround checkbashisms mistake
it reported: "possible bashism in scripts/build/binary_loopback_cfg line 284 (should be '.', not 'source')"

which is clearly a misidentification.

Gbp-Dch: Ignore
2020-04-30 11:57:47 +01:00
Lyndon Brown 9d5665c627 syslinux: fix errors re-running under `--force`
robustification is required to not just `--force` but recovery from failure
or user cancellation.

Gbp-Dch: Short
2020-04-30 07:52:37 +01:00
Lyndon Brown 96ade65e65 grub2: fix lost pre-prepared files detail
partly lost in some adjustments that were made to the submitted work,
which was focused on restoring the 'start installer' entry.

there is no need for dynamic setting of these two `source` imports in the
default file, in fact user modifications should also use the fixed import
commands in future.

note that the old placeholders however remain replaced, which inject
precisely this string, for backwards compatibility.

Gbp-Dch: Ignore
2020-04-30 07:10:08 +01:00
Lyndon Brown 647dcb7aed bootstrap_cache: fix failure condition
during testing i encountered an unexpected error resulting from the
following condition:
 - bootstrap was cached
 - cache of bootstrap packages was empty (from playing with `lb clean`)
 - installer was not none|live

everything works fine up until the main installer script, which comes to
an abrupt halt with an error due to the missing cached bootstrap packages
that it wants to copy.

this situation is easy to unintentionally create, as i managed to do.

here we catch the failure condition, correcting for it.

this is done by checking for the missing cached packages when restoring
the bootstrap from the cache, and skipping this if the packages were
missing, thus forcing the bootstrap to be rebuilt. the packages should
then be found within the cache, allowing the installer stage to complete
successfully.

of course the bootstrap stage will only cache the packages if caching is
enabled, but if caching is disabled and installer enabled, the config
validation will catch that, reporting that problem.

Gbp-Dch: Short
2020-04-30 06:20:52 +01:00
Lyndon Brown a8a6addaf5 loopback: tidy formatting
Gbp-Dch: Ignore
2020-04-29 20:08:39 +01:00
Lyndon Brown 80d9c93de9 selinux: fix output consistency
install mode was silent when selinux was not enabled, whilst remove mode
always output a "Begin unmounting..." message. this makes both modes silent
when selinux is not enabled.

this also happens to fix an unintended side effect of
d79c96232b whereby a warning subsequently
was always emitted in remove mode when selinux was not in use, which was
not ideal.

Gbp-Dch: Short
2020-04-29 13:17:50 +00:00
Lyndon Brown 29ab2459c8 a couple tiny doc fixes
Gbp-Dch: Ignore
2020-04-29 10:27:16 +01:00
Lyndon Brown 6a5d42d569 fix auto file handling regression
b4598b234c mistakenly stopped passing along
options to auto files.

Gbp-Dch: Ignore
2020-04-28 15:12:35 +01:00
Raphaël Hertzog 624e79eb8f Do not overwrite splash.png if the user has provided it
The unconditional SVG to PNG conversion could overwrite a splash.png
provided by the user. Ensure we don't overwrite such a file. But we
still remove the SVG file as syslinux is not able to make use of it.
2020-04-25 10:49:35 +02:00
Raphaël Hertzog 103daf9f7c Make librsvg2-bin dependency unconditional for syslinux
We do provide a splash.svg by default so the check will always return
true unless the user has forked live-build... thus the check is
pointless.
2020-04-25 10:46:26 +02:00
jnqnfe 24c2b3e119 syslinux: deduplicate common files
there are several files of which identical duplicate copies are held in:
 - share/bootloaders/extlinux
 - share/bootloaders/pxelinux
 - share/bootloaders/isolinux
 - share/bootloaders/syslinux

it is a pain to maintain this from a development standpoint, having to
copy modified config files into the other directories each time changes
are made and mistakes have been made before due to this.

this creates a new folder share/bootloaders/syslinux_common and moves them
to this new directory.

it also expands the binary_syslinux stage to use it, with it now
constructing the installed set of bootloader files as follows:
 1. copy {LB_DIR}/bootloaders/syslinux_common
 2. copy {LB_DIR}/bootloaders/{syslinux|isolinux|extlinux|pxelinux} on top
 3. copy config/bootloaders/syslinux_common on top
 4. copy config/bootloaders/{syslinux|isolinux|extlinux|pxelinux} on top

note, to explain part of the binary_syslinux change, instead of just
copying the correct bootloader folder full of the files, we now make the
target bootloader specific directory, then copy the contents of source
directories into it.

Gbp-Dch: Short
2020-04-24 18:50:37 +01:00
Raphaël Hertzog c6428f44e3 Use correct variable name to detect removal step
Due to this mistake, the helpers were not called in reverse order
during the removal step. This lead to things like "apt update" failing
because a broken /etc/resolv.conf has been restored before the call
to "chroot_archives remove".

Gbp-Dch: Ignore
2020-04-24 17:09:10 +02:00
Raphaël Hertzog e7df05cd29 Replace "Help" calls with "Man" and get rid of Help 2020-04-24 16:39:10 +02:00
Raphaël Hertzog 104fa20399 Revert "frontend: properly handle option processing"
This reverts commit 6b7c8ed4bf as it's
breaking multi-value space-separated parameters.
2020-04-24 15:37:13 +02:00
Lyndon Brown 58e0efedc9 config: tidy directory construction and empty directory cleaning 2020-04-24 14:01:47 +01:00
Lyndon Brown 879a9c54ff config: tidy config files 2020-04-24 14:01:41 +01:00
Lyndon Brown 10bbb095a8 chroot_resolve: fix broken network connectivity
introduced by an issue with the implementation of
91d446d93e

the introduced of that commit caused builds to fail doing `apt-get update`
or downloading packages and such.

this tweak fixes the problem.

Gbp-Dch: Ignore
2020-04-23 19:53:31 +00:00
Lyndon Brown d79c96232b stagefiles: guard unnecessary chroot removal
just as most scripts are skipped if their stagefile exists (indicating
that they have already been run to completion), including chroot
preparation scripts in install mode, this implements the same guard for
chroot prep remove mode, such that they exit early if their stagefile
does not exist, indicating that the modification has already been removed.
(also override-able by --force in the same way).

this basically just uses a tweaked copy of Check_stagefile().

Gbp-Dch: Short
2020-04-23 18:26:15 +01:00
Lyndon Brown 500f205073 config: s/LIVE_IMAGE_TYPE/LB_IMAGE_TYPE/
no backwards compatibility hack for reading the old var from existing
saved config used because this was previously stored in the alternate
format config/build file.

Gbp-Dch: Short
2020-04-23 16:54:31 +00:00
Lyndon Brown 83d9145257 config: s/LIVE_IMAGE_NAME/LB_IMAGE_NAME/
no backwards compatibility hack for reading the old var from existing
saved config used because this was previously stored in the alternate
format config/build file.

Gbp-Dch: Short
2020-04-23 16:54:31 +00:00
Lyndon Brown 41738b1932 config: s/LIVE_CONFIGURATION_VERSION/LB_CONFIGURATION_VERSION/ 2020-04-23 16:54:31 +00:00
Lyndon Brown cb44c128e0 config: address fixme
these options are not internal, they are user controllable

Gbp-Dch: Short
2020-04-23 16:54:31 +00:00
Lyndon Brown 05b9d4c9ea config: remove obsolete variable 2020-04-23 16:54:31 +00:00
Lyndon Brown c441c39efe config: revert partial format conversion
back in v4.0~a6-1 a transition process was started to move the live-build
config to a new format. the new format was INI style, and required
parsing functions to read/write values, compared to the existing format
which was just shell script code setting variables.

this partial transition is the explanation for the existence of the
`New_configuration()` function, and understanding this is important to
understanding the purpose of it - it is not in fact intended for creating
a new configuration, it is just related to the new config format
transition.

the positives of the new format were that it was somewhat cleaner looking,
while the negative was the terrible relative efficiency.

the file `config/build` was created to hold options in this new format.

the transition was only ever completed for a handful of config options:
 - architecture
 - archive areas and parent archive areas
 - live image name
 - live image type

a 'configuration version' attribute was also saved, which is not used by
anything.

the bootstrap-mirror and parent-bootstrap-mirror attributes are pointlessly
stored in it seemingly resulting from work done in v4.0~a17-1. (they are
also stored in another config file from which the value is actually used).

it in fact seems to have been a source of confusion for Raphaël in
authoring 44b9b0a650, since the new
`[parent]-distribution-{chroot|binary}` options it introduced were stored
both in `config/bootstrap` and in `config/build`, while only used from the
former. i expect, understandably, that he thought that `config/build` was
just an information file.

Gbp-Dch: Short
2020-04-23 16:54:31 +00:00
Lyndon Brown bf63762721 move grub-pc specific code to actual grub-pc script
the grub-pc image creation code has no business being in binary_iso, it
should be in binary_grub-pc.

it should be noted that the binary_iso script did not even have the
necessary package check for grub-mkimage, while binary_grub-pc did have
it, pointlessly.

Gbp-Dch: Short
2020-04-23 15:59:39 +00:00
Lyndon Brown 49794f118f syslinux: use linux/initrd placeholders
enabling improved flexibility for any possible future
path changes.

Gbp-Dch: Ignore
2020-04-23 15:51:57 +00:00
Lyndon Brown 6051ce1697 config: create config/bootloaders directory
to help users know that this is where they can put custom bootloader
configs, just as other directories are created for them.

Gbp-Dch: Short
2020-04-23 16:18:47 +01:00
Raphaël Hertzog e2243dbacb binary_syslinux: rely on $LIVE_BUILD_VERSION instead of lb --version 2020-04-23 17:10:25 +02:00
Lyndon Brown fb41c19009 tidy version reported in `lb config --dump`
live-build might be run from a local folder rather than the system
installation, so the dpkg version number should not override the version
picked up from VERSION

if we care about the possibility of the installed package version
potentially differing from the version of the git checkout, or
whatever, then this should be printed alongside it, as now done.

Gbp-Dch: Ignore

[Raphaël Hertzog: tweak to apply on top of my changes]
2020-04-23 17:05:38 +02:00
Raphaël Hertzog 4c75f80e67 Use descriptive parameter names for Usage() 2020-04-23 16:38:59 +02:00
Lyndon Brown b3bba232ac usage: take exit code as param
thus it can correctly indicate success/fail status instead of always
indicating failure. when a user asks for usage with -u|--usage then we
should exit in success mode rather than failure as when usage in printed
in response to incorrect usage.

Gbp-Dch: Short
2020-04-23 16:32:26 +02:00
Lyndon Brown 6b7c8ed4bf frontend: properly handle option processing
this means that the usage goes from:
 lb {-h|--help|-u|--usage|-v|--version}
 lb COMMAND [OPTIONS]

to:
 lb {-h|--help|-u|--usage|-v|--version}
 lb [FRONTEND_OPTIONS] COMMAND [COMMAND_OPTIONS]

though it is probably not worth is to update the description in the
manpages...? hmm...

so for instance this matters for color control with --color|--no-color
(you already had full control via environment vars). previously you could
do `lb COMMAND --no-color` to turn off colour, only to find that output
at the frontend level was still coloured (the option is processed at the
command context level, not the frontend), so you might try to instead use
`lb --no-color COMMAND`, only to find that this was not supported. Well
now it is, and used at the frontend level will fully control colour output
(after the command is processed anyway).

the full set of common options are thus available (except --force) at the
frontend level, and thus for instance all Echo_*() helpers used in the
frontend will work correctly after args are processed.

furthermore usage like `lb --color --help` will actually work. (not that
color is used there, but this previously would have failed with the
frontend treating the `--color` argument as the command; that's the point!)

Gbp-Dch: Short
2020-04-23 16:29:00 +02:00
Lyndon Brown 8ffe48d8f3 rename LB_BOOTSTRAP_QEMU_ARCHITECTURES to LB_BOOTSTRAP_QEMU_ARCHITECTURE 2020-04-23 16:00:34 +02:00
Lyndon Brown 6cc7250954 rename LB_ARCHITECTURES to LB_ARCHITECTURE
this was previously not done in 8b109ffb96
to keep the renaming simple, but leaving the variable plural is a cause
for confusion.

since this property is stored in the INI style config/build config file
rather than a shell script based one, at the property there is already
singular, there was no need for a backwards compatibility hack.

Gbp-Dch: Short
2020-04-23 15:54:19 +02:00
Lyndon Brown 6def2c27be fix usage
Gbp-Dch: Ignore
2020-04-23 15:53:30 +02:00
Lyndon Brown 430c48640c move script param capture to before arg processing
makes them consistent with other similar script-specific param handling;
saves the arg processing from dealing with it.

Gbp-Dch: Short
2020-04-23 15:53:12 +02:00
Lyndon Brown 3d2b280c8f firmware: robustify and simplify archive area checking 2020-04-23 15:46:43 +02:00
Lyndon Brown 9a91ca9fde config: obsolete old --tasksel option
note that the bit of code removed from source_debian relies upon a
variable LB_TASKS which itself is an old leftover artefact from before
v4.0.

Gbp-Dch: Short
2020-04-23 15:46:06 +02:00
Raphaël Hertzog d414b8fcdb config: obsolete --net-root-path 2020-04-23 15:44:17 +02:00
Lyndon Brown 1ca53bff52 config: obsolete --net-root-* options (except one)
--net-root-path probably needs to go too, but it is being used for
something i don't fully understand currently.

Gbp-Dch: Short
2020-04-23 15:30:41 +02:00
Lyndon Brown 1eee15e852 config: obsolete unused --net-cow-* options 2020-04-23 15:24:50 +02:00
Lyndon Brown 87b995597c config: obsolete unused --isohybrid-options option 2020-04-23 15:24:10 +02:00
Lyndon Brown c3f0d39675 config: apt-get should probably be an allowed and documented --apt value
since everywhere where 'apt' is a permitted value, 'apt-get' is also, it
just wasn't listed in the option's documentation and thus was also not
listed in the new validation check.

Gbp-Dch: Short
2020-04-23 15:23:30 +02:00
Lyndon Brown c57b8679a4 config: fix broken backwards compatibility hack
80aa5ab611 implemented a hack to handle
replacement of LB_LINUX_FLAVOURS with LB_LINUX_FLAVOURS_WITH_ARCH in
config files, but implemented it in the wrong place.

adding a conditional conversion within the config file meant that the old
value would only be read from **new** config files that are created
obviously without it, including re-saved configs if `lb config` were
re-run with additional options (not recommended). any existing value in an
existing config file would actually be ignored.

the right place to read the old value was in the Set_defaults() function
(since renamed).

a second issue also existed with the hack, it failed to excape the `$`
and thus printed the existing value of $LB_LINUX_FLAVOURS into the
conditional check being constructed in the config file, instead of
printing the name of the variable. the check embedded into the config
file thus became this on an amd64 machine:
```
if [ -n "amd64" ]
then
	LB_LINUX_FLAVOURS_WITH_ARCH="amd64"
fi
```
which is clearly not what was intended.

Gbp-Dch: Short
2020-04-23 15:23:15 +02:00
Lyndon Brown 3645719f22 config: stop writing 'default: <foo>' lines to config files
while helpful for users to know the defaults, the values printed as the
supposed defaults for most are actually the same values as being
configured, or in some cases a piece of text "autodetected or empty", and
thus the information is completely wrong and actually unhelpful since it
misinforms the user.

fixing this to give the real defaults is very much non-trivial.

as a workaround users wanting to know the default for an option can always:
 a. use `lb config` wit no options (or auto) in a clean directory and thus
    get a config with all defaults.
 b. look at the live-build code.

if they just want to reset an option, they can also just comment it out.

Gbp-Dch: Short
Closes: #904614
2020-04-23 15:16:46 +02:00
Lyndon Brown eb2eb9b51e installer: rework validation check for installer type
(and move the wget options setting down where it should be while at it)

the value of LB_DEBIAN_INSTALLER is now properly checked in the main
validation routine, so we can just directly exit here as a simple safety
check should validation be bypassed.

Gbp-Dch: Short
2020-04-23 15:16:26 +02:00
Lyndon Brown 554a8d1108 tidy up grub bootloader compatibility checking
- add a validation check where an error will be printed
 - replace the check done in the grub scripts with one that simple exits
   if executed bypassing the validation check

Gbp-Dch: Short
2020-04-23 15:08:07 +02:00
Lyndon Brown 34c3f79be4 config: better handle error condition
Gbp-Dch: Ignore
2020-04-23 15:02:14 +02:00
Lyndon Brown 576ec6165a config: reorganise the option case block
move away from the somewhat config file grouping based organisation to
an alphabetised list, after grouping into script-specific; general;
build-specific and other.

the config file based organisation was a bad choice, making it hard to
find the right place to insert options for instance.

Gbp-Dch: Short
2020-04-23 15:01:48 +02:00
Lyndon Brown 6c51a80e99 config: organise getopt longoption set
alphabetised per line lists, broken up into multiple lines where exceeding
80 chars.

Gbp-Dch: Short
2020-04-23 15:00:18 +02:00
Lyndon Brown 51f6f2e41d config: remove spurious secondary validation check
it is already done just before writing the config to disk; this check is
happening just after doing so and is thus pointless.

Gbp-Dch: Short
2020-04-23 14:59:47 +02:00
Lyndon Brown f8a401f068 config: add --validate option
running `lb config --validate` causes the script to stop after running
the validation check on the config compiled at that point, prior to
writing the config to disk.

this gives users the ability to check the validity of a config without
modifying or rewriting the saved config.

note that if users provide new config options alongside --validate, these
are taken into account in the check performed.

the 'check complete' message will not be seen if an error is reported by
the check function, while it will be seen if only warnings are given, but
it would require a redesign of the validation check function to make any
improvement in that area, and it's perhaps not worth it.

Gbp-Dch: Short
2020-04-23 14:53:06 +02:00
Lyndon Brown 5fb790e43e config: rename Set_config_defaults() to Prepare_config()
it mostly applies defaults where a value does not exist, but does more in
some cases. the new name better reflects its usage and functionality.

Gbp-Dch: Short
2020-04-23 14:52:20 +02:00
Lyndon Brown 7de8a0faa7 config: rename Check_config_defaults() to Validate_config()
this is used after applying user settings on top of the defaults,
so is not specific to checking defaults; it's a validation checker.

Gbp-Dch: Short
2020-04-23 14:51:58 +02:00
Lyndon Brown 39e4d3e3cb --binary-images can support only a single type
whilst some parts of the codebase were set up to work with multiple types
specified, others did not work with it and would not necessarily be easy
to adjust. this thus makes some tweaks to adjust things accordingly.

 - option renamed to singular form (maintaining backwards compatibility)
 - a validation check has been added
 - unnecessary glob style type references fixed
 - checks with In_list changed to a direct singular comparison
 - typo of type "netboot" written as just "net" fixed (though unreachable
   so of no consequence; really the code could be removed but it's trivial)

Gbp-Dch: Short
2020-04-23 14:51:09 +02:00
Lyndon Brown 997c978c0e manpages: document all values for --interactive 2020-04-23 11:52:13 +01:00
Lyndon Brown 9b61541ef1 manpage: fix consistency issues
- in underlining option parameters
 - in some cases of single or multiple (quoted + space separated) values

Gbp-Dch: Ignore
2020-04-23 11:52:13 +01:00
Lyndon Brown b833eb3650 manpages: indicate in usage that multiple bootloaders can be given
Gbp-Dch: Ignore
2020-04-23 11:52:13 +01:00
Lyndon Brown f73797158e bootloaders: improve bootloader list handling
two parts of the code worked with both comma and space separated lists,
while two others only worked with comma separated.

swapping out commas with spaces when we setup the var in
Set_config_defaults() means that individual scripts no longer need to worry
about it and everything supports both; and that we can avoid the
IFS/OLDIFS mess.

Gbp-Dch: Short
2020-04-23 11:52:04 +01:00
Lyndon Brown 286caf03be fix outdated grub-legacy bootloader name references 2020-04-23 11:46:36 +01:00
Lyndon Brown 91d446d93e Fix permissions & ownership of copied /etc/resolv.conf
Closes: #857740

[tweaked by Raphaël Hertzog to fix the chown root:root call]
2020-04-23 12:20:35 +02:00
Lyndon Brown 6fa4b5bae9 binary_hdd: fix variable name typo 2020-04-23 10:14:55 +00:00
Lyndon Brown 9fb3d69046 config: fix wrong saved value for parent archive areas 2020-04-23 10:13:21 +00:00
Lyndon Brown 1a0c813c46 chroot_apt: fix broken removal 2020-04-23 10:05:51 +00:00
Lyndon Brown affcbb95d1 chroot_apt: improve readability 2020-04-23 10:05:51 +00:00
Lyndon Brown 7d46dd81fc chroot_dpkg: remove redundant chmod
left over from before using `ln` to setup the diversion

Gbp-Dch: Ignore
2020-04-23 09:57:25 +00:00
Lyndon Brown 04c5aae0a9 chroot_prep: warn if running archives helper for bootstrap stage
to protect against simple mistake of using 'all' instead of
'all-except-archives' when manually executing scripts (e.g. during
development) at the bootstrap stage level. (the bootstrap stage does not
and should not use the archives helper).

Gbp-Dch: Ignore
2020-04-23 09:38:02 +00:00
Lyndon Brown d171426ae4 binary_rootfs: use new chroot_prep helper 2020-04-23 09:38:02 +00:00
Lyndon Brown f24ed6ba3e binary_rootfs: fix missing handling of chroot_tmpfs 2020-04-23 09:38:02 +00:00
Lyndon Brown 78b03ce8a3 bootstrap_archives: remove useless param 2020-04-23 09:38:02 +00:00
Lyndon Brown 38a5aed0dc chroot_prep: expand coverage
it now covers:
 - `lb chroot_apt install-binary`
 - `lb chroot_archives {chroot|binary|source} {install|remove}`

by expanding usage from:
`lb chroot_prep {install|remove} HELPERS [ARGS]`
to:
`lb chroot_prep {install|remove} HELPERS [MODE[ MODE..]] [ARGS]`

where `[MODE[ MODE..]]` is an optional set of one or more of:
 - archives-chroot, which specifies to use 'chroot' as the first param to
   the chroot_archives script
 - archives-binary, which specifies to use 'binary'
 - archives-source, which specifies to use 'source'
 - apt-install-binary, which specified to pass 'install-binary' instead of
   'install' to chroot_apt

thus _all_ chroot prep scripts can be run through this helper now!

note, in the case of the binary stage, 'archives' is deliberately not added
to CHROOT_PREP_OTHER, this is not a mistake!

Gbp-Dch: Short
2020-04-23 09:38:02 +00:00
Lyndon Brown 1f63c620f0 binary: add missing use of chroot_tmpfs 2020-04-23 09:38:02 +00:00
Lyndon Brown e22bd27170 add bulk chroot preparation script execution helper
rather than explicitly running one helper after another in the major
build stages, or by hand (e.g. while testing things during development),
they can be run in bulk via this new helper. it essentially just takes a
list of helpers to run and runs them one by one.

it supports running all helpers except chroot_archives because that one
has different parameter requirements to the rest and supporting it would
make things messier.

helper scripts can either be named by their full script name or without
the 'chroot_' prefix for brevity. you can also just specify 'all' to
refer to all helpers (except chroot_archives, per above).

it automatically reverses the order of the list when run in remove mode.

Gbp-Dch: Short
2020-04-23 09:38:02 +00:00
Lyndon Brown fc88358b29 binary: remove useless execution of `lb chroot_debianchroot remove`
it was not run in install mode so should not be run in remove mode.

(whether it should in fact be run in install mode is another question; as
is whether chroot_tmpfs should be being used)

Gbp-Dch: Short
2020-04-23 09:38:02 +00:00
Lyndon Brown 8c0e802d13 remove some unwanted quoting of list parameters
there are additional instances in binary_* scripts that are left here
because they are covered by changes in MR #157

Gbp-Dch: Short
2020-04-23 09:38:01 +00:00
Lyndon Brown 11836c0c18 fix $@ parameter expansion issues
$@ when unquoted is subject to further word splitting. this fixes a bunch
of instances where it was incorrectly being used unquoted.

Gbp-Dch: Short
2020-04-23 09:38:01 +00:00
jnqnfe 958251da67 binary_iso: remove duplicate copying of grub binaries
these files are already copied into place in the binary_grub-pc script.

Gbp-Dch: Short
2020-04-23 10:56:51 +02:00
Lyndon Brown 1517861c3e grub-pc: fix broken boot capability
Closes: #956131
2020-04-23 10:56:51 +02:00
adrian15 9220bde3df grub-efi: fix partial broken boot capability
when used alongside syslinux and when a single kernel flavour is used,
things work correctly. otherwise booting from EFI is broken.

the problem comes from the fact that syslinux, for a single kernel flavour
creates the file /live/vmlinuz, which is used by the minimal EFI grub.cfg
to locate the device and partition containing the live image. when multiple
kernel flavours are used, it instead creates /live/vmlinuz1, /live/vmlinuz2,
etc. which thus is a problem. similarly when syslinux is not used, you are
left only with long filenames for the kernel files, for example
/live/vmlinuz-4.19.0-8-amd64. in these situations grub cannot find the
device containing the image and thus fails to display the boot menu.

the solution here, instead of dynamically changing the filename searched
for depending upon bootloader configuration, switches to doing a search for
the file /.disk/info instead. this file is generated by binary_disk, and
is present for iso, iso-hybrid and hdd images types, though grub-efi cannot
be used for the hdd type. it is not created for the netboot type, but again,
grub-efi is not compatible with that anyway. it is not created for the tar
type, which the grub-efi script does not block as incompatible, but is this
not a mistake?

furthermore, switching to searching for /.disk/info helps avoid issues for
systems that happen to actually include a real /live/vmlinuz path other
than on a removable live disk or CD/DVD, as is the case with a HP system
discussed in #924053.

this patch was written by adrian15sgd@gmail.com, as per the authorship,
who attached it to the #924053 bug discussion. this commit message however
has been re-written by jnqnfe@gmail.com, prior to submission via an MR,
as part of the fix towards the issues reported in #956131.

Gbp-Dch: Short
Closes: #924053
2020-04-23 10:56:51 +02:00
Lyndon Brown 5ac625e3e1 grub2|loopback: define common target
Gbp-Dch: Ignore
2020-04-23 10:18:41 +02:00
Lyndon Brown 077d005a84 grub2|loopback: extract memtest menu entry creation to config file
backwards compatibility:

 1. the new file will be included alongside any user custom config
 2. rather than replace MEMTEST with an actual config entry, we replace it
    with a line to import the content of the new file, and thus will work
    just as before.

thus no backwards compatible breakage

Gbp-Dch: Short
2020-04-23 09:59:56 +02:00
Lyndon Brown 69093d9e3b grub2|loopback: extract install menu entries to config files
backwards compatibility:

 1. the new install.cfg and install_start.cfg files (chosen
    automatically from the install_*gui.cfg and install_*test.cfg
    files) will be included alongside any user custom config.
 2. the placeholders are now replaced with lines importing these files

thus everything will work just as before, i.e. no backwards
compatibility breakage.

Gbp-Dch: Short
2020-04-23 09:59:56 +02:00
Lyndon Brown 1f1b156697 grub2|loopback: move copying of files earlier
necessary for changes in followup commits.

Gbp-Dch: Short
2020-04-23 09:59:56 +02:00
Lyndon Brown 24658ce542 syslinux: overwrite default files with user ones
as just done for grub2|loopback

the primary benefit here is that it means that user configs do not
have to carry copies of all files; they just carry the ones they
want to replace (or add).

Gbp-Dch: Short
2020-04-23 09:59:56 +02:00
Lyndon Brown 81adab8555 syslinux: simplification
`$_SOURCE` is always composed of `<foo>/${_BOOTLOADER}`, so we can just use
`${_BOOTLOADER}` as the basename, without calling `basename ${_SOURCE}`

Gbp-Dch: Ignore
2020-04-23 09:59:56 +02:00
Lyndon Brown e5b2b56c7c grub2|loopback: overwrite default files with user ones
...rather than choosing between the default set and a user provided set

 1. ensures backwards compatibility after we switch from generation of
    certain content to that content being in pre-prepared config files,
    and thus no longer writing that config out to existing files.
 2. means that user configs do not have to carry copies of all files; they
    just carry the ones they want to replace (or add).

Gbp-Dch: Short
2020-04-23 09:59:56 +02:00
Lyndon Brown 457e800c94 grub2|loopback: move advanced installer entries under own submenu
this takes a step forward in moving towards the same updated layout as
with syslinux; here we get:

 - <live entries>
 - Start installer
 - Advanced install options...
    - <full set of install options>
 - Advanced options...
    - Memory Diagnostic Tool (memtest86[+])

note that this only affects the default menu. custom configs are not
affected by this change.

further steps to complete the move to the updated layout will follow
later.

"Advanced options..." should perhaps be renamed later.

Gbp-Dch: Short
2020-04-23 09:59:51 +02:00
Lyndon Brown 33af87e047 grub2|loopback: improve memtest label
make it consistent with syslinux

Gbp-Dch: Short
2020-04-23 09:12:52 +02:00
Lyndon Brown 96285a0e70 grub2|loopback: add hotkeys for some installer entries
an official current debian install disc was compared with to achieve
better consistency.

main menu:
 - i: for the single "start" entry

advanced submenu:
 - g: for the main graphical entry
 - i: for the main text-based entry
 - x: for the main expert entry
 - a: for the main auto entry
 - r: for the main rescue entry
 - s: for the synth entry

for expert, auto and rescue, the hotkey is given to the graphical entry
where present, otherwise to the text entry.

Gbp-Dch: Short
2020-04-23 09:12:52 +02:00
Lyndon Brown c2eb40d9b1 grub2|loopback: add hotkey for memtest (m) 2020-04-23 09:12:52 +02:00
Lyndon Brown 89d72410c4 grub2|loopback: add hotkey for single kernel live entry (l) 2020-04-23 09:12:52 +02:00
Lyndon Brown 6e86a6480c grub2|loopback: allow providing hotkey to menu entry creation helpers 2020-04-23 09:12:52 +02:00
Lyndon Brown 40a076bf35 grub2|loopback: use '@' bookended placeholders
...for consistency with syslinux config placeholders and improved
clarity of what text is a placeholder.

the old placeholders without the bookends are still replaced for
user configs for backwards compatibility.

the new ones are little used just at the moment but are expected to
become used much more in later commits.

Gbp-Dch: Short
2020-04-23 09:12:24 +02:00
Lyndon Brown d5d1e35f22 grub2|loopback: remove unnecessary perl based newline escaping for sed
none of the stuff changed here is multi-line so had no reason to use it.

Gbp-Dch: Short
2020-04-22 18:36:47 +02:00
Lyndon Brown bbeed4cb60 build: fix misleading message 2020-04-20 10:16:14 +00:00
Lyndon Brown f0588be19a loadlin: fix missing directory error
fixes an error I experienced in a test build

Gbp-Dch: Short
2020-04-01 19:04:14 +00:00
Lyndon Brown 1716958a8d bootstrap_cache: validate action param 2020-04-01 18:03:20 +00:00
Lyndon Brown 39dae8cdc7 move auto colouring decision
...from the `Set_config_defaults` function, to being done directly
in `build.sh` (the component which is also responsible for loading
functions, loaded at the start of every script, including the front
end).

thus the colouring decision will now correctly...
 - apply to the frontend, such as to the 'root privileges needed'
   error, the 'no such script' error, and the command name
   colouring that I want to add (the most significant issue).
 - apply to error messages generated by the `Arguments` and
   `Read_conffiles` functions, which are called before
   `Set_config_defaults` by scripts.

as things were, due to the comparison with "false", colour would
_always_ be used in these places (unless _COLOR_ERR=false or
_COLOR_OUT=false wrt. the new command highlight, were set in the
environment when executing a script throught the frontend).

this would not be a problem for normal terminal use of course,
besides being inconsistent where color were turned off, but would
be a bit of a problem if redirected to a file.

a re-evaluation of _COLOR is performed in `Set_config_defaults` to
adjust _COLOR_OUT and _COLOR_ERR where necessary, to correctly
respond to _COLOR being set in saved config files (disabled by
default but a user could always enable), after the point of config
files being loaded.

_COLOR can still be controlled from the environment just as before,
overriding both _COLOR_OUT and _COLOR_ERR.

note that this does not address the fact that --color|--no-color
do not work in the frontend and thus will not impact the colouring
of to-be-introduced command highlighting. this needs to be
addressed separately.

Gbp-Dch: Short
2020-03-23 08:06:51 +00:00
Lyndon Brown 85e0681ee8 args: fix a typo
Gbp-Dch: Ignore
2020-03-23 08:06:51 +00:00
jnqnfe a25b77e099 bootloaders: remove old "video=vesa:ywrap,mtrr" kernel param, as done in d-i
d-i removed this in commit 0917b2dde3ff73a204d27dd2f2fffc8a41175ddd

Note: There was inconsistency between grub and syslinux in use of this, with
syslinux not having it on graphical rescue and auto modes while grub entries
did. The patch to fix that has been dropped since we're removing it everywhere
anyway.

(#395040)

Gbp-Dch: Short
2020-03-22 19:43:56 +00:00
Lyndon Brown 757d1e6b48 binary_iso: remove duplicate xorriso param
-J is already in the generic set defined at the start

Gbp-Dch: Short
2020-03-20 16:17:16 +00:00
Lyndon Brown 92425bd99c archives: param is required
Gbp-Dch: Ignore
2020-03-20 11:43:01 +00:00
Lyndon Brown 7c4de2f20d archives: clarify var
Gbp-Dch: Ignore
2020-03-20 11:43:01 +00:00
Lyndon Brown 94a3e184c2 archives: explicitly pass along _PASS to Create_apt_sources_list
Gbp-Dch: Ignore
2020-03-20 11:43:01 +00:00
Lyndon Brown 945a166f75 strip progress-linux distro hacks
progress-linux, as discussed in MR #142 ([1]) is a little known distro,
which appears to be little more than a personal project of the original
author of live-build.

given that, the expense of maintaining all of these old hacks for it
cannot be justified. it is not known whether or not live-build is even
used with respect to it since the author abandoned live-build some
years ago.

also, at least one past change in live-build possibly broke progress-linux
compatibility anyway, which would have required progress-linux users of
live-build to use a custom progress-linux config, or a progress-linux
fork of live-build, and there is no knowing how much of the hacks in this
"upstream" codebase any user of progress-linux currently relies upon.
and again, progress-linux appears to just be a personal project of
Daniel's, with afaik very little userbase. (Daniel seems to be the only
developer working on the project which speaks to how small it is).

[1]: https://salsa.debian.org/live-team/live-build/-/merge_requests/142

Gbp-Dch: Short
2020-03-20 10:19:33 +00:00
jnqnfe 4fa83598a3 grub: remove old and unused splash code
The LB_GRUB_SPLASH variable is populated by the --grub-splash param
but is not actually used for anything.

Gbp-Dch: Short
2020-03-20 10:02:52 +00:00
Lyndon Brown 01a6de2f4c config: fix backwards compatibility break
when the --fdisk and --losetup options were removed, the entries in the
getopt option list should have remained for backwards compatibility such
that the usage warnings can kick in instead of unknown option errors.

Gbp-Dch: Ignore
2020-03-20 09:28:58 +00:00
Lyndon Brown 561f2dcc3a config: fix incomplete rename of --architectures
missed the getopt data update in 8b109ffb96

Gbp-Dch: Ignore
2020-03-20 09:28:58 +00:00
Lyndon Brown fb0790cc43 stagefiles: s/Require_stagefile/Require_stagefiles/
this function takes one or more required stage fileS _plural_, and exits
if any are missing (or at least it does now after the refactor).

let's rename it to make things more clear

Gbp-Dch: Short
2020-03-17 22:59:37 +00:00
Lyndon Brown dadeec9d39 stagefiles: fix doc mistake
missed in final revision of fe9195b59c

Gbp-Dch: Ignore
2020-03-17 22:09:51 +00:00
Lyndon Brown fe9195b59c stagefiles: further robustify with auto filenames
as suggested by Raphaël

rather than have fixed stagefile filename strings at all in the scripts,
use `$(basename $0)` to use the name of the script (which is the same for
almost all cases anyway, and the stage files are supposed to be almost
exclusively unique per-script). we can thus simplify things by determining
the filename for most use cases within the functions themselves.

this does change the file used by a couple of scripts, affecting backwards
compatibility of executing live-build upon an existing partially or fully
completed build:
 - binary_grub-pc used "binary_grub"
 - chroot_includes used "includes.chroot"

care had to be taken for the following cases:
 - there are some cases like bootstrap_cache, source_debian and
   bootstrap_debootstrap which are dealing with more than one file, and/or
   otherwise a filename that is not specific to the script itself exactly,
   or should not be based upon its name.
 - some cases like chroot_cache, bootstrap_cache and
   chroot_install-packages need to append something to the end of the name
   depending upon which pass/action mode the script is being executed with.
 - furthermore in the bootstrap_cache case one of the filenames is used
   within the bootstrap_debootstrap and thus needs very careful handling
   to be certain that a change in filename of bootstrap_cache does not
   break bootstrap_debootstrap.

Gbp-Dch: Short
2020-03-17 18:57:02 +00:00
Lyndon Brown 04d9ee0211 stagefiles: simplify & robustify
- avoid all need to pass ".build/" path in stage file names into the
   functions
 - add a helper to remove a stage file (required to complete the above
   properly)
 - avoid duplicating filenames within scripts which makes them prone to
   mistakes (some instances of which I've actually encountered and had
   to fix)

Gbp-Dch: Short
2020-03-17 18:57:02 +00:00
jnqnfe a773edb813 syslinux: apply kernel version filtering logic to multi-flavour kernel scenarios 2020-03-16 23:08:26 +00:00
jnqnfe 38af959aa5 syslinux: use more dynamic memtest menu config file
Fixes the following
 - Correct version (memtest86/memtest86+) shown instead of fixed 'memtest86+' text
 - Ensure correct directory path always used by using replaceable placeholder

Gbp-Dch: Short
2020-03-16 23:08:26 +00:00
jnqnfe 31fa6abd36 syslinux: add memtest menu entry only if including memtest 2020-03-16 23:08:26 +00:00
jnqnfe 7ffd2288d9 syslinux: add install menu entries only if including installer 2020-03-16 23:08:26 +00:00
Lyndon Brown 7e41b1267c fix another wrong stage file filename 2020-03-16 22:40:23 +00:00
Lyndon Brown c55eb8a0c3 use local scope for private function vars
all vars affected have been carefully checked to be quite certain
that they are definitely local

where variable is assigned the return value of a function/command, the
local "declaration" is deliberately done on a separate line, since
`local FOO` is actually treated itself as a command rather than a
declaration; will thus always cause $? to be zero, and thus if done on
the same line as such an assignment can not only clobber $? but in doing
so unintentionally blocks failure of a command from triggering the
expected exit from having `set -e`.

also, from testing, i have found that when assigning "${@}" this must be
done on a separate line confusingly as otherwise an error occurs.

Gbp-Dch: Short
2020-03-16 22:10:03 +00:00
Lyndon Brown af040d7803 add build & build stage success messages 2020-03-16 21:42:49 +00:00
jnqnfe 24aab15d2a bootloaders: add install with speech synthesis menu entries
Following the official Debian install disks

Gbp-Dch: Short
2020-03-16 20:33:18 +00:00
jnqnfe efbe50233e grub1: refactor install menu creation
This is necessary as the simplest solution to allow a single
speech-synth entry to be added.

Gbp-Dch: Short
2020-03-16 20:33:18 +00:00
jnqnfe 2fc60a1151 syslinux: remove replacement of unused label in menu configs 2020-03-16 16:29:00 +00:00
jnqnfe 8a7bc408e5 grub1: fix consistency
Use the normal appended-params directly in `Grub_live_entry` calls
like the failsafe ones.

Gbp-Dch: Short
2020-03-16 16:29:00 +00:00
jnqnfe aadf8c4cac grub1/grub2/loopback: fix missing delimiter in menu kernel parameter lists
The '---' delimiter should appear before the final 'quiet' parameter
(which is used by the debian installer I believe).

This delimiter is added by live-build in syslinux configs, and is present
in both grub2 and syslinux configs in an official debian 7.7 disc image,
suggesting strongly that live-build grub/grub2 menu creation code is in
the wrong here by missing it.

update: this commit previously used -- as was correct at the time, and has
since been updated to use --- per #775128; which was previously tackled in
a separate later commit. the switch to --- was already done for syslinux
(which was not missing the delimiter unlike grub) in
ba6b9adeff

Gbp-Dch: Short
Closes: #775143
2020-03-16 16:29:00 +00:00
jnqnfe a33938f8d4 grub1/grub2/loopback: fix order of quiet kernel parameters in menus
I believe that the `quiet` parameter is meant for d-i not the kernel and
thus should be given on the end after a delimiter, as done with syslinux.

Here we switch the order to move it to the end. The addition of the missing
delimiter will be done in a followup commit.

(See #775143)

Gbp-Dch: Short
2020-03-16 16:29:00 +00:00
jnqnfe 636e52c36e grub2/loopback: fix misapplication of quiet kernel parameter
When building grub2 menu entries the quiet param (meant for d-i)
was excluded from the rescue menu entries instead of expert.

This is the opposite to what is done in the following:
 - Menu entries seen in official debian 7.7 disc images (grub2 and syslinux configs)
 - Menu entries created for grub (legacy)
 - Menu entries created for syslinux

The evidence strongly suggests that the grub2 menu creation was in the wrong!

(See #775143)

Gbp-Dch: Short
2020-03-16 16:29:00 +00:00
jnqnfe 464c7a6946 grub1: fix wrong variable name 2020-03-16 16:29:00 +00:00
Lyndon Brown 49e68da5ee allow turning off colour
necessary to give control when colour is default enabled

Gbp-Dch: Short
2020-03-16 13:32:16 +00:00
Lyndon Brown 2cf397df66 installer: fix double slash in urls 2020-03-16 01:36:53 +00:00
Lyndon Brown b326c37f92 installer: expand debugging output 2020-03-16 01:36:53 +00:00
Lyndon Brown 2ea6eeefa2 installer: move an exclude removal outside of loop 2020-03-16 01:36:53 +00:00
Lyndon Brown 19e1a5b9c2 installer: tweak temp shell script construction
Gbp-Dch: Ignore
2020-03-16 01:36:53 +00:00
Lyndon Brown 47e136df6f installer: dedup long paths 2020-03-16 01:36:53 +00:00
Lyndon Brown 3fb0bb235d installer: tidy package lists
`DI_PACKAGES` does not need to include `DI_REQ_PACKAGES` so long as
we pass the latter to apt in the one case where it was not already
being given it.

in fact with it including that sub-list meant that in the other
case where it was being given to apt, it actually just resulted in
duplication.

Gbp-Dch: Short
2020-03-16 01:36:53 +00:00
Lyndon Brown 9a878350d3 installer: misc small tweaks
Gbp-Dch: Ignore
2020-03-16 01:36:53 +00:00
Lyndon Brown 2abf7bc65b installer: clear large string once done with
Gbp-Dch: Ignore
2020-03-16 01:36:53 +00:00
Lyndon Brown 1a9a1585ad installer: restore udeb existence check
this was removed as part of b54bdd7fb1
but is actually still needed.

Gbp-Dch: Ignore
2020-03-16 01:36:53 +00:00
Lyndon Brown 7891188557 installer: fix broken loop
Gbp-Dch: Ignore
2020-03-16 01:36:53 +00:00
Lyndon Brown 00a2fabcdf fix wrong description
Gbp-Dch: Ignore
2020-03-15 21:54:37 +00:00
Lyndon Brown a67febdd82 fix missing stage descriptions
Gbp-Dch: Ignore
2020-03-15 21:54:37 +00:00
Lyndon Brown b25db0a4bf source: properly fix _apt permissions warning
the chown command needed running within the chroot, since apt-get is being
run within the chroot and _apt might have a different UID there than on
the host.

Gbp-Dch: Short
Closes: #953957
2020-03-15 21:38:35 +00:00
Steven Shiau 0a353a7b46 Add grub EFI support for armhf arch. 2020-03-15 11:35:19 +00:00
Lyndon Brown 34ceb67718 hide mountpoints from nautilus
when building within a home directory, as /proc, /sys, etc are mounted
and unmounted into the chroot at various points in the build, corresponding
entries appear and disappear within the side panel of nautilus.

this is obviously undesirable.

use of `-o x-gvfs-hide` resolves this for the most part. i still see items
occasionally pop up and having spent some time experimenting, i'm putting
it down to buggy behaviour on the part of nautilus. (aside from those
appearing when debootstrap is running - debootstrap also needs this fix).

Gbp-Dch: Short
2020-03-13 20:28:15 +00:00
Lyndon Brown a46985b08a fix comment typo
Gbp-Dch: Ignore
2020-03-13 16:19:59 +00:00
jnqnfe b27927724a locks: tidy lock acquisition
Combine the check+create done in each script. (The original functions
are still callable as before, but a new combined `Aquire_lockfile`
function can be called instead, as now used).

Note, a further simplification could be done in removing the passing of
the lock filename in as a parameter since every use of the functions is
with ".lock". The lock functions already have a fallback to ".build/lock"
though. Checking the history, the fallback used to be for a system wide
lock, which was then replaced with this config-tree specific one. As long
as that is not used implicitly by 3rd-party hooks then surely we are free
to change the fallback to ".lock" and further remove passing in a name as
a param...?

history:
db5d2b0dcd
0aa8289a37

Gbp-Dch: Short
Closes: #952918
2020-03-13 15:37:38 +00:00
Lyndon Brown 5e423d0851 fix instances of bad stagefile creation circumstances
theres no point in creation of stagefiles being kept within a
conditional block of work. if the script completes with success
then it should create its stagefile to thus avoid repeating any
work that it might have done should it get re-run without being
forced.

Gbp-Dch: Short
2020-03-13 14:42:34 +00:00
Lyndon Brown 3e3e8c2c64 fix instances of broken stagefile handling
mismatches in filenames between check and create

Gbp-Dch: Short
2020-03-13 14:42:34 +00:00
Lyndon Brown 9f42bc1bdc fix splitting bootloader string
the existing solution simply did not work
2020-03-13 14:17:45 +00:00
jnqnfe a6cc72bf6d strip useless multi-arch separate directory stuff
(part of never completed side-by-side multi archi support)

Several scripts make a call to a function called Check_multiarchitectures,
the purpose of which is to adjust the target directory that certain 'live'
and 'install' files are located in. The idea is that a script sets up
'DESTDIR', 'DESTDIR_LIVE' and 'DESTDIR_INSTALL' as appropriate and then
the script appends a suitable arch dependant postfix to the directory
name, depending upon the arch currently being targetted. This would allow
the script to be run multiple times, each for a different architecture.

This is a part of an implementation of allowing multiple architectures to
sit side by side within the same live image, selectable from the
bootloader menus. (As opposed to multiple architectures mixed within the
same userland).

This is evidently the case both from the fact that:
  1) The arch specific postfix chosen in that function depends on a var
     called LB_CURRENT_ARCHITECTURE, which is never set. In fact going
     back through the git history to the introduction of the function in
     0d5ff4ca75, the var (even considering
     var name changes) has never been set by anything. So effectively the
     call to the function has been entirely redundant all this time.
  2) The major build stages do not perform multiple executions of substages
     per arch. Thus from this perspective it seems that the support was
     never fully implemented.
  3) If any doubt remained, there is an old branch called 'tmp-multiarch'
     which has a couple of commits making progress with completing support,
     such as implementing the above missing pieces.

The above mentioned branch is 10 years old and can be considered abandoned.

It is not clear whether the original author ever intended to complete and
merge this; nor is it at all clear at what stage of completion it was at.

At any rate, imo it is not at all particularly useful to have extra code
and complexity in order to be able to cram multiple environments side by
side in one image, not when CDs/DVDs and even to some extent USB pen drives
are so cheap. And who really needs more than one environment so
desperately on just one such medium.

If this was not enough to justify removal, then there is also the fact that
the support that was implemented has become completely broken over the
years with scripts diverging in terms of the variable names the function
modifies such that they are incompatible with it.

A quick assessment of the state of this latter aspect:

  good:
   - grub-legacy uses the correct var names so is fine
   - memtest similarly good
   - installer_debian-installer looks okay

  questionable:
   - binary_linux-image uses the correct vars but might not select the
     right kernel and initrd files to copy (seems to copy all)

  bad:
   - grub-pc is making a redundant call, after functionality was moved
     to the loopback script
   - loopback is using the wrong vars (INITFS instead of DESTDIR +
     DESTDIR_INSTALL + DESTDIR_LIVE), plus is doing its own amd64+i686
     thing anyway, so the function call would achieve nothing anyway.
   - syslinux is also using the wrong var names so would not work with
     it and is not even making the necessary function call. Also the
     install paths are fixed in the hard coded cfg files anyway so this
     would need addressing with placeholders and sed replacement, but
     then it is not entirely clear how things should work with respect
     to install entries and multi-arch anyway, are we having multiple
     copies of the installer, one for each target arch and then multiple
     copies of the install menus, perhaps under different submenus?

So, this removes the artefacts of this never completed feature.

Gbp-Dch: Short
2020-03-13 13:56:21 +00:00
Lyndon Brown 1edc3af346 debootstrap: use --force-check-gpg
I asked for such a switch to be added in debootstrap back at the start of
2015 in #775454 as part of a review I undertook of its security. A slightly
modified patch was merged a few months later and made it into version
1.0.69.

A patch was never merged into live-build to make use of it however. Let's
do that now.

The benefit of this, as explained in #775454, is that if we want strong
security (LB_APT_SECURE=true) then should debootstrap not be able to find
the GPG key to verify things with, it will abort with an error instead of
falling back to just https downloads with a warning. Such a warning would
be easy to miss in the log output, and security could potentially be
compromised if this were to happen.

Gbp-Dch: Short
2020-03-12 14:44:49 +00:00
Luca Boccassi 015e6b65f3 Revert "Test for executables: replace 'which' with more robust 'command -v'"
This reverts commit 2d9ab1f7f8.

Causes test failure due to bashism.
2020-03-12 12:32:26 +00:00
Lyndon Brown c2e73627db grub: fix incorrect error handling 2020-03-12 12:08:33 +00:00
johnraff 2d9ab1f7f8 Test for executables: replace 'which' with more robust 'command -v'
Instances of:
if [ $(which <command> ]
have been replaced with:
if command -v <command> >/dev/null
which is considered to be more robust in a range of environments.

scripts/build/chroot_archives: line 259:
	if [ "${LB_APT}" = "aptitude" ] && [ ! $(Chroot chroot "which aptitude") ]
has been left untouched because the chroot might require a more complex command
which would need more testing.

manpages/Makefile: line 42:
	@if [ ! -x "$$(which po4a 2>/dev/null)" ]; \
has been left untouched because I am not sufficiently familiar with makefiles.
2020-03-12 10:35:57 +00:00
Lyndon Brown 1e0339a4e3 remove obsolete loop-aes-utils related losetup hack
677415f6d7 (2007) in v1.0~a2-1 added a hack
relating to the loop-aes-utils package and losetup. this commit bundled
a bunch of changes, it was not specific to the hack, and so info about the
hack is limited to a brief comment included within the related change in
defaults:
```
# Workaround for loop-aes-utils divertion
# (loop-aes-utils' losetup lacks features).
```
though it is very similar to the removed fdisk hack in that it seems that
one package may replace a binary from another, moving the original to a
new location, and this hack gives the user the opportunity to select the
original instead of the one put in its place, for use in LB.

the comment mentions a package called loop-aes-utils as being the package
that performs such a diversion, and that the need for the hack was that
losetup itself lacked features, presumably encryption support, and it is
clear that it is the losetup binary that is the focus of the diversion.

looking into the history of loop-aes-utils a little, this package was
dropped from debian back in 2012 (#680748), favouring encrytion support of
dm-crypt/cryptsetup.

double checking file contents of packages, only the mount package carries
an /sbin/losetup file, so presumably this means that dm-setup/cryptsetup
do not perform such a diversion of losetup (i.e. their use is exclusively
done directly).

since the possible diversion is simply gone, that completely removes any
point in having the hack of giving users choice between losetup and the
diverted one. so let's remove this obsolete hack...
2020-03-12 10:31:39 +00:00
Lyndon Brown 9930ce1ea5 grub-efi: fix image type check ordering
this should take place before working on efi related stuff

Gbp-Dch: Short
2020-03-12 09:59:44 +00:00
Lyndon Brown a9d8aac959 grub-efi: fix incorrect error handling 2020-03-12 09:59:44 +00:00
Lyndon Brown d9f353c737 remove obsolete fdisk hack
8321653cb3 (from 2007) introduced a hack to
work around bug #445304 in gnu-fdisk for users who may have replaced fdisk
with the classic gnu version. the hack allowed users to select an alternate
fdisk binary to use to work around the buggy binary.

bug #445304 is marked as found in v1.0-1 and fixed in v1.2-1, though may
have been fixe din v1.1. it was marked fixed in 2009.

checking the package archive, gnu-fdisk does not actually exist anymore
in debian, with one exception - it is available for arm64 on sid via
debports, and that version is 1.3 so thus includes the necessary fix
anyway.

it is thus pointless now that we still carry this hack.

Gbp-Dch: Short
2020-03-11 19:06:54 +00:00
Lyndon Brown 7a4a9f94b8 amend copyright & licensing blocks
Current versions of the project files are built upon versions published
and licensed by Daniel Baumann, but are modified copies of those files and
thus need to be marked as such per licensing requirements (afaik he did
not pass along ownership / licensing rights to anyone when he left the
project). We should also be careful to not be misrepresenting such
modified copies as being attributed to Daniel.

Adding a new copyright line referring to "The Debian Live team" should
suffice for this.

The authorship block in man pages has also similarly been updated.

Notes:
 - tweaked a copy of daniel copyright lines stating 2014 instead of 2015.
   both of these cases were in files that i had personally introduced in
   some of my past merged commits that moved some code around. i don't know
   why they stated 2014.
 - binary_onie was introduced in 2018, so that has a 2018 date instead of
   2016 unlike the rest.
 - 'efi-image' is a 3rd-party (Canonical Ltd) work that we bundle, but it
   has been modified by 674794a8f4 and
   36a3ba7634 so I similarly added a
   debian live copyright line.
 - 'grub-cpmodules' is similar. it was only changed by the indentation fix
   of 36a3ba7634 but modification is
   modification, and this does help cover any possible future changes that
   might be made.
2020-03-11 13:51:19 +00:00
jnqnfe 87e9543c98 source: target downloads with corresponding version
Prefer downloading the version of the source package that actually
corresponds to the version of the binary. Should apt-update be
run and a package updated, we do not really want to fetch a newer
copy of the source than that of the binary, we want the exact
corresponding version (kinda the whole point of compiling a source
disc that they correspond). If the exact version is no longer
available then it is surely preferable to list it in the missing
list than end up with a newer version.

Gbp-Dch: Short
Closes: #952932
2020-03-11 11:45:27 +00:00
Lyndon Brown 744141c60f source: fix apt warnings
the source stage emitted the following output for each packages downloaded.
note the troubling warning at the end.

```
Reading package lists... Done
NOTICE: 'grep' packaging is maintained in the 'Git' version control system at:
https://salsa.debian.org/debian/grep.git
Please use:
git clone https://salsa.debian.org/debian/grep.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 1579 kB of source archives.
Get:1 http://deb.debian.org/debian buster/main grep 3.3-1 (dsc) [2038 B]
Get:2 http://deb.debian.org/debian buster/main grep 3.3-1 (tar) [1473 kB]
Get:3 http://deb.debian.org/debian buster/main grep 3.3-1 (diff) [104 kB]
Fetched 1579 kB in 1s (1293 kB/s)
Download complete and in download only mode
W: Download is performed unsandboxed as root as file 'grep_3.3-1.dsc' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
```

this occurred because the '_apt' user did not have permission to write to
the destination directory and so was falling back to downloading as root
in order to do its work.

prior to 158950b873 all source packages were
downloaded directly to the root of the chroot. that commit changed this to
save them into a new clean directory within it instead. thus to fix the
problem we can simply set the ownership of this new directory to '_apt'.

Gbp-Dch: Short
2020-03-10 18:11:21 +00:00