Commit Graph

3519 Commits

Author SHA1 Message Date
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 f1647f0dac functions: consistency fix
missed in 7ee59d408e

Gbp-Dch: Ignore
2020-03-11 09:56:53 +00:00
Lyndon Brown 6cec4a7a74 exit: fix no /usr/bin/env error
if you execute the bootstrap stage with no internet connection, you get
the following output:

```
[2020-03-10 19:18:46] lb bootstrap
P: Setting up clean exit handler
[2020-03-10 19:18:46] lb bootstrap_cache restore
[2020-03-10 19:18:46] lb bootstrap_debootstrap
P: Begin bootstrapping system...
P: If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy.
P: Running debootstrap (download-only)...
I: Retrieving InRelease
I: Retrieving Release
E: Failed getting release file http://deb.debian.org/debian/dists/buster/Release
P: Begin unmounting filesystems...
P: Saving caches...
chroot: failed to run command ‘/usr/bin/env’: No such file or directory
```

the last line looked suspicious. investigating it turns out that there was
a deficiency in the exit handler.

when debootstrap fails to download what it needs due to lack of a
connection, that failure due to `set -e` causes the Exit() handler to kick
in. Part of this includes outputting the "Saving caches..." line, before
then making a call to Save_package_cache(). That in turn runs the following
command:
```
Chroot chroot "apt-get autoclean" || true
```
The Chroot() function includes a line starting with:
```
${_LINUX32} chroot "${CHROOT}" /usr/bin/env
```
which is the source of the last output line.

the reason we see this unexpected output is that with bootstrapping having
failed, there is no /usr/bin/env within the chroot so it is bound to fail.

the fact is, the exit handler has no business trying to pretty much
anything that it does if the bootstrap_debootstrap stage has not
completed.

this implements such a restriction and thus resolves the problem of this
unexpected and confusing output in the described situation.

we will now see:
```
[2020-03-10 19:18:46] lb bootstrap
P: Setting up clean exit handler
[2020-03-10 19:18:46] lb bootstrap_cache restore
[2020-03-10 19:18:46] lb bootstrap_debootstrap
P: Begin bootstrapping system...
P: If the following stage fails, the most likely cause of the problem is with your mirror configuration or a caching proxy.
P: Running debootstrap (download-only)...
I: Retrieving InRelease
I: Retrieving Release
E: Failed getting release file http://deb.debian.org/debian/dists/buster/Release
```
2020-03-11 09:55:37 +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
Lyndon Brown e3da1b6f8d debootstrap: remove redundant check
the check for existence of debootstrap here was completely redundant since
there is a check at the beginning of the file which already outputs an
appropriate error and exists if missing.
2020-03-10 17:47:41 +00:00
Lyndon Brown d79fd1e760 archives: fix typo
introduced in ee2bbe4578

Gbp-Dch: Ignore
2020-03-10 17:36:10 +00:00
Lyndon Brown 48df750411 config: improve documentation 2020-03-10 14:12:45 +00:00
Lyndon Brown 9faf9bcbed hooks: run bin without explicit path
this got lost in reworking 7ee59d408e

Gbp-Dch: Short
2020-03-10 13:59:01 +00:00
Lyndon Brown 24f04a924b chroot: clarify stages
the cache restore/save script is not a chroot modification script unlike
the rest of the scripts that it was bunched up with. It is an actual
component part of the chroot build stage.

let's bring clarity to this with improved documentation.

Gbp-Dch: Short
2020-03-10 12:51:55 +00:00
Lyndon Brown 9f2b7b40e8 archives: always include enabled/disabled deb-src apt entries
LB_APT_SOURCE_ARCHIVES determines whether or not deb-src entries are
desired to be included in apt's sources.list. here, instead of excuding
them we always include them but commented out where they would previously
have been excluded. this means that if a user later changes their mind and
wants to make use of them all they have to do is uncomment them rather
than add the necessary lines.

Gbp-Dch: Short
Closes: #952929
2020-03-10 12:50:39 +00:00
Lyndon Brown ee2bbe4578 archives: simplification
as suggested by Raphaël

Gbp-Dch: Short
2020-03-10 12:49:36 +00:00
Lyndon Brown cf2a9b951c arguments: fix unreachable and poor argument error handling
all scripts use `set -e` which means that if getop fails, the subsequent
error check that would print an error in addition to any printed by getopt
itself would never actually be reached.

the first though here would be to remove the pointless error check, but
getopt does not include the word "error" with an unrecognised option
failure, nor does it use colour to highlight problems, both of which mean
that it is a little lacking in terms of highlighting problems to users.

thus we properly capture and use the exit code here and output an
appropriate message per invalid argument vs getopt internal error.

also, removed the redundant stderr redirection which is already done
by Echo_error().

Gbp-Dch: Short
2020-03-10 12:45:23 +00:00
Lyndon Brown d6096622f9 help/usage: remove pointless vars
build scripts never call Help() and so the empty HELP strings are pointless.
(when called with --help they call Man()).

Closes: #952859
Gbp-Dch: Short
2020-03-10 12:45:23 +00:00
Lyndon Brown 9f1fdac303 help/usage: simplify
Gbp-Dch: Ignore
2020-03-10 12:45:23 +00:00
Lyndon Brown bc199a73b6 help/usage: fix output of `lb config --usage`
broken by d0eb72a5ef

also, needed spaces before per-script output

Gbp-Dch: Ignore
2020-03-10 12:45:23 +00:00
Lyndon Brown 4e45586daf help/usage: fix too many empty lines
Gbp-Dch: Ignore
2020-03-10 12:45:23 +00:00
jnqnfe 158950b873 source: downloaded pkgs to a clean directory rather than chroot root
Closes: #952931
2020-03-10 12:44:11 +00:00
jnqnfe feec626274 source: minor tweaks
Gbp-Dch: Ignore
2020-03-10 12:44:11 +00:00
jnqnfe 532144ce66 chroot: improve directory creation/destruction efficiency
Closes: #952924
2020-03-10 12:41:15 +00:00
jnqnfe 0dee07f122 config: rename the config set/check functions for clarity
Gbp-Dch: Short
Closes: #952920
2020-03-10 12:39:37 +00:00
Lyndon Brown b4598b234c tidy script init (4/4) - top level cmd "auto redirect" handling
Partial fix for #952919

Gbp-Dch: Short
Closes: #952919
2020-03-10 12:39:37 +00:00
jnqnfe dff08fa3f7 tidy script init (3/4) - top level commands
Partialfix for #952919

Gbp-Dch: Short
2020-03-10 12:39:37 +00:00
jnqnfe 061d7cb340 tidy script init (2/4) - build stage scripts
Partial fix for #952919

Gbp-Dch: Short
2020-03-10 12:39:37 +00:00
jnqnfe b49abcc1a8 tidy script init (1/4) - arg and config processing
Partial fix for #952919

Gbp-Dch: Short
2020-03-10 12:39:37 +00:00
jnqnfe ed2d70bde1 simplify STAGE checks - use In_List
Closes: #952917
2020-03-10 00:02:43 +00:00
Lyndon Brown 62b3efa686 echo: fix bad colour choice
white is not going to work well on a terminal with a white background,
obviously. We should keep the standard colour and just try applying the
bold.

or do we want to consider a non black/white colour? like blue...?

Gbp-Dch: Short
2020-03-09 12:52:08 +00:00
Lyndon Brown a6c4094cf0 echo: don't mangle backslashes for file printing 2020-03-09 12:47:08 +00:00
Lyndon Brown 8545c048c6 use actual boolean state for some simple vars
Gbp-Dch: Ignore
2020-03-09 11:21:24 +00:00
Lyndon Brown 2c78d36bd5 use actual bool state where applicable within functions 2020-03-09 11:17:53 +00:00
Lyndon Brown 093a5ea99c installer: use boolean for clarity
Closes: #952930
2020-03-09 10:58:53 +00:00
Lyndon Brown e5d006cbc0 archives: tidy deb-src exclusion
instead of conditionally writing deb-src lines, it is **much** neater if
we use sed to optionally removed them at the end.

Gbp-Dch: Short
Closes: #952928
2020-03-09 10:54:23 +00:00
Lyndon Brown 7ee59d408e fix consistency in binary execution and existance checking
- prefer using `which` over hard coded paths
 - it is redundant to check that the bin pointed to the return of
   `which` exists and is executable, `which` already gives us
   assurance of that if it returns true!
 - the redirection of output (`2>/dev/null`) seems to be
   unnecessary from my testing.

the instances relatnig to fdisk and losetup in functions/defaults.sh have
been left as they are since they get executed by `lb config` which can run
without sudo elevation unlike `lb build` and in that case `which` would
fail to find these binaries resulting in error.

this also fixes a bug showing an error for missing debootstrap - this tool
requires sudo privileges to run and thus is not found via a none elevated
which search.

Gbp-Dch: Short
Closes: #952927
2020-03-09 10:51:11 +00:00
Lyndon Brown 37f0432e98 fix inadequate chroot_archives validation
commit d74f2102a0 added a validation check
to chroot_archives for its 'pass' parameter. this was based upon finding
an instance where the wrong value was being submitted to the script and
wanting to ensure such mistakes would be caught.

unfortunately it seems that I made a mistake in misremembering the facts
surrounding the latter issue when constructing the validation check and
failed to double check with testing until it was already merged. a
correction is needed. the set of valid values is not limited to only
'source|binary' but actually 'source|binary|chroot'. I'd misremembered
'chroot' as being a completely invalid value.
2020-03-09 10:51:11 +00:00
jnqnfe 7624527d77 defaults: ensure global caching param overrides specific caching params if disabled
Closes: #952923
2020-03-09 10:38:09 +00:00
jnqnfe 8008b57fc2 source: add output of config readme file to source image
To provide an explanation

Gbp-Dch: Short
Closes: #952921
2020-03-05 22:35:52 +00:00
Lyndon Brown 4d0c3a1169 firmware: enable caching for archive content file with firmware lists
the existing logic for obtaining a list of firmware packages always
downloaded a fresh copy of the archive content file, deleting the file
already in the cache. here we move to actually making use of the cache.

this helps when building multiple times, at least for the same distro. the
package list obtained is rarely going to change after all. it could of
course differ between distros, but the cache is per-distro, as it has
always been.

we of course here switch to caching each of the archive-area files
individually rather than having one file that gets overwritten (or
appended to in the case of when we kept the decompressed file).

Gbp-Dch: Short
Closes: #952911
2020-03-05 22:13:57 +00:00
Lyndon Brown 7867641fd0 firmware: save the compressed contents file to disk instead of decompressed
the existing logic was to decompress the contents file from the downloaded
archive to disk, then process it to obtain a package list. the largest
one by far is for 'main'; 'non-free' and 'contrib' are tiny in comparison.
for sid-amd64 currently, the archive file is 37 MB, while the decompressed
file it contains is 592.3 MB.

we always delete the files and download afresh (currently), and a previous
commit optimised by deleting the files once we're done with them to avoid
wasting disk space leaving them behind.

here we switch to storing the downloaded compressed file to disk instead,
reducing disk space usage (and IO) by hundreds of megabytes; piping the
decompression directly into awk instead of having awk read from the stored
file.

this moves the appending of new items into the list back within the archive
area loop, which is fine since we're replacing the file for each loop now
so the previous issue relating to appending is of no concern.

Gbp-Dch: Short
Closes: #952910
2020-03-05 22:13:57 +00:00
Lyndon Brown a120bc5445 firmware: avoid potentially duplicate work
addressing an old fixme, should distro and parent-distro be identical (in
a derivative build) we want to avoid wasting effort downloading and
processing the same content files twice.

since parent and non-parent have separate archive-area lists though we
should perhaps not just assume that they are identical or ignore any
differences; thus here in such a situation we ensure that we handle any
archive areas not already done for parent-distro handling in such a case,
while skipping those already done.

i notice that the fixme actually also refers to avoiding actual
overlapping of the cached files, however the cached files are (currently)
always ignored anyway, so this is of no concern. reusing the cached files
is an entirely separate issue.

Gbp-Dch: Short
Closes: #952909
2020-03-05 22:13:57 +00:00
Lyndon Brown 94d126c043 firmware: reorder firmware list construction
the 'manually add firmware-linux package' bit was stuck inbetween the
parent and non-parent logic, which was especially unhelpful before we
de-duplicated the logic into a common function.

Gbp-Dch: Short
2020-03-05 22:13:57 +00:00
Lyndon Brown aa745de0bb firmware: de-dup firmware list parsing
Edit: There were four copies of the same logic to keep in sync;
Originally this patch deduplicated each file, but leaving a copy of
the new function in each, thus reducing the duplication but not
eliminating it. A later patch moved it into a shared function file
following further enhancements to the code in question. This has
since been revised to have the function moved to a shared file here,
which simplifies and gives a cleaner diff.

Gbp-Dch: Short
Closes: #952908
2020-03-05 22:13:57 +00:00
Lyndon Brown 4933beffce firmware: delete pointlessly cached (large) file after use
the archive content file downloaded to obtain a list of firmware packages
is always deleted and downloaded afresh currently. it may not be ideal that
we do not make use of the cache here, however while that remains
unaddressed, we might as well delete the file after we've used it in order
to not pointlessly waste disk space.

note that this file is ~613 MB for sid-amd64 currently.

Gbp-Dch: Short
Closes: #952907
2020-03-05 22:13:57 +00:00
Lyndon Brown c53a949325 firmware: fix possible duplication in firmware package lists (inefficiency)
where multiple archive areas are used, the code here on each loop is:
  1) fetching the archive area contents file (compressed)
  2) **appending** the output to that of the previous loop
  3) searching the file for firmware references, adding to the list

since it appends rather than replaces, entries found in each loop get
re-added on each subsequent loop, resulting in duplication in the
resulting list

below I evaluate the possible solutions to explain why I chose the one
I chose, however the reader should not waste too much time worrying about
whether one of the other solution would have actually been better because
things are changed significantly in further commits shortly!

possible solutions:
  a) switching to output (>) rather than append (>>), but this might fail
     against an existing file
  b) removing the file on each loop, but this will complicate any future
     caching improvements that might be made here (currently the files are
     always deleted and thus downloaded fresh)
  c) allow the appending, evaluating the complete file after the loop

solution C warrants consideration of disk space consumption; currently the
compressed 'main' archive (for sid on amd64) expands to 592.3 MB (feb-2020),
'contrib' is 3.1 MB, and 'non-free' is 18.5 MB.

solution C was chosen here; the difference of accumulated file size vs.
max-single was minor enough to not be of particular concern (~613 vs.
~592 MB).

Gbp-Dch: Short
Closes: #952906
2020-03-05 22:13:57 +00:00
Lyndon Brown a951fe7ba6 firmware: construct file location once and reuse 2020-03-05 22:13:57 +00:00
Lyndon Brown c140efe41e firmware: avoid building unnecessary lists 2020-03-05 22:13:57 +00:00
jnqnfe 055907592c cache: clarify and simplify package cache save/restore
These functions are specific to handling packages stored in the
cache, not other files. They are also always used with the same
`cache/packages.` prefix to the path.

Gbp-Dch: Short
Closes: #952916
2020-03-05 22:09:20 +00:00
jnqnfe c1dcc4dd89 aliases: simplify excessively complex In_list function
This function is never used to find multiple needles at one time.

Gbp-Dch: Short
Closes: #952915
2020-03-05 22:07:50 +00:00
Lyndon Brown 0869a890ae installer: download udebs directly from correct mirror
instead of trying all from derived mirror then falling back to parent upon
failure, which as pointed out by a message printed out can result in a
load of spurious 404 errors; actually get each udeb from the mirror it is
supposed to be retrieved from.

Partial fix for #952914, this is the last commit for it so closes it

Gbp-Dch: Short
Closes: #952914
2020-03-05 21:34:38 +00:00
Lyndon Brown b54bdd7fb1 installer: filter derived udebs from parent list
the existing logic just bundled the entire parent and derived udeb lists
together, ignoring the fact that there might thus be two instances of some
packages, and relying upon getting derived ones first and checking file
existence to avoid handling the overridden parent instances.

here we now actually filter the list of parent udebs to exclude packages
that are to be obtained from the derivative.

this enables avoiding the file existence checking

Partial fix for #952914

Gbp-Dch: Short
2020-03-05 21:34:38 +00:00
Lyndon Brown 2e3f195c38 installer: robustify udeb inclusion
move the code that checks whether a version of a given package has already
been obtained (to account for parent and derived both listing the same
package) to guard the copy from cache action also, not just the download
action.

in rare but possible scenarios it would have been possible to end up with
both the parent and derived copies of a package included.

Partial fix for #952914

Gbp-Dch: Short
2020-03-05 21:34:38 +00:00