Commit Graph

89 Commits

Author SHA1 Message Date
Roland Clobus 4a8b01df80 Fixes error message for local .deb files in config/packages.chroot.
The error message:
N: Download is performed unsandboxed as root as file '/root/packages/./InRelease' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

The _apt user cannot access files in /root/packages, instead /packages
will be used.
2024-11-24 22:41:35 +00:00
snip 58f7a9e379 Use same naming scheme for archive keys in chroot and binary stages
Commit 8403487d introduced in the chroot stage a naming scheme for local
archive keys which distinguishes between ASCII-armored keys and binary
ones, and then adds the appropriate extension (either `.asc` or `.gpg`,
respectively) when copying them to `/etc/apt/trusted.gpg.d`.

However, this change was not applied to the binary stage: ASCII-armored
and binary keys are still both copied with the `.asc` extension, which
introduces a discrepancy between the two stages. This, in turn,
may prevent using the same `.list` file for both stages, as entries
such as

    deb [signed-by=/etc/apt/trusted.gpg.d/my-repository.key.asc] ...

will fail in the chroot stage if `config/archives/my-repository.key`
is in binary format (as it will be copied with the `.gpg` extension),
while entries such as

    deb [signed-by=/etc/apt/trusted.gpg.d/my-repository.key.gpg] ...

will fail in the binary stage (as the key will this time be copied
with the `.asc` extension).
2023-01-05 09:52:48 +01:00
Roland Clobus 5b44eb3bf5
Remove a left-over file when using a package in config/packages.chroot. 2022-04-20 10:26:24 +02:00
Nick Brown f04dc6dc49 Add auth.conf.d support to archives
Allow APT_AUTH.CONF(5) config files to be used with archives.

Note that config/archives/*.conf are assumed to be apt.conf files,
so the apt_auth files are required to end with .auth and will be renamed
to .conf when copied into the chroot.

Closes: #991065
2022-02-18 10:47:45 +00:00
Lyndon Brown 18eefdd6f3 s/Remove_package/Remove_packages/
it removes one or more, so should be plural for clarity

Gbp-Dch: Short
2020-05-05 19:55:28 +01:00
Lyndon Brown 919a464b64 s/Install_package/Install_packages/
it installs one or more, so should be plural for clarity

Gbp-Dch: Short
2020-05-05 19:55:28 +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 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
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
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 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 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 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 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
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
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
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 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
Lyndon Brown d79fd1e760 archives: fix typo
introduced in ee2bbe4578

Gbp-Dch: Ignore
2020-03-10 17:36:10 +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 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
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
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 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 ac4ba405df archives: deduplicate apt sourcelist file construction
Geez :O

Gbp-Dch: Short
Closes: #952889
2020-03-05 21:08:53 +00:00
jnqnfe a67e01638f help/usage: fix overly complex script description handling
Closes: #952887
2020-03-05 20:48:49 +00:00
jnqnfe 512dd58240 archives: fix mount local repo comments
Closes: #952873
2020-03-05 20:36:21 +00:00
Lyndon Brown 36a3ba7634 fix indentation
including:
 - spaces replaced with tabs for consistency
 - alignment of `;;` in some case statements changed for consistency

Gbp-Dch: Short
Closes: #952857
2020-03-05 11:29:01 +00:00
Lyndon Brown 9c062e1f8b archives: fix deb-src entry exclusion
the sed commands were missing '-i' to actually modify the file (rather
than output to stdout)

Gbp-Dch: Short
Closes: #952842
2020-03-05 09:46:56 +00:00
Lyndon Brown d74f2102a0 archives: add 'pass' param validation check
if this had already been in place then it would have caught
bug #952837.

Gbp-Dch: Short
Closes: #952841
2020-03-05 02:41:26 +00:00
Lyndon Brown ae2012953b archives: fix incorrect usage string
Gbp-Dch: Ignore
Closes #952839
2020-03-05 02:40:59 +00:00
jnqnfe f3ebc44e13 archives: fix removal of chroot/root/packages.chroot package list
Gbp-Dch: Short
Closes: #952838
2020-03-05 02:40:42 +00:00
John Estabrook b6ad08c270 Add local archive keys before configuring local package repository
In the binary stage, chroot is restored from cache/bootstrap, which contains
neither custom repo lists, nor keys. If local packages are present,
chroot_archives will call 'Apt chroot update' after adding custom repo lists
without adding keys. apt-get will then fail instead of warn as of apt version
1.5.

Closes: #941691
2019-12-19 18:52:05 +01:00
Raphaël Hertzog 44b9b0a650 Support --distribution-binary and --distribution-chroot
This makes it possible to build an image against a first distribution
(--distribution-chroot) and have the resulting image point to another
distribution (--distribution-binary). We can use this to build against a
snapshot and have the result use the original distribution that was
snapshotted.

Closes: #888507
2019-12-19 18:18:44 +01:00
Marcel Partap 8403487d4e copy keys to /etc/apt/trusted.gpg.d with appropriate extension for them to not be ignored. 2018-09-13 16:25:09 +01:00
Luca Boccassi e5492b1c70 Avoid apt-key add and just drop the key in /etc/apt/trusted.gpg.d
Only gnupgv is part of the deboostrap set these days, but apt-key needs
the full gpg (with gpg-agent) which is just a recommends.
Instead just drop the key with an .asc suffix in /etc/apt/trusted.gpg.d
which is supported since apt version 1.4
2018-06-03 22:06:36 +01:00
Luca Boccassi 9a0c6102fd Fix build with local offline mirrors
Commit a15b579652 (#775989) dropped an early exit from the
chroot_archives remove step in case the parent mirror chroot and binary
parameters are the same and introduced a regression, as with the
following live-build now fails when the parent mirror is using a file:/
local apt repository (for example when the build worker is offline and
uses a pre-built cache of packages).

Example config:

  lb config --mirror-bootstrap "file:/pkgs" \
    --mirror-chroot "file:/pkgs/" \
    --mirror-binary "file:/pkgs" \
    --parent-mirror-bootstrap "file:/pkgs" \
    --parent-mirror-chroot "file:/pkgs/" \
    --parent-mirror-binary "file:/pkgs" \
    ...

with /pkgs being a directory with the packages for the installation and
the apt metadata (Packages/Sources/Release).

The problem is that, with such a setup, the /pkgs directory is bind
mounted inside the chroot as an optimisation in the install step,
and umounted as one of the first actions in the remove step for
chroot_archives.

Before that fix, the script terminated immediately. But now it
progresses and at the end it tries to run apt update inside the chroot
which will fail since the repository directory has been umounted, and
thus the packages and the apt metadata are no longer available, while
still being listed in /etc/apt/sources.list.

The proposed solution is to umount the local directory at the end of
the remove step, rather than at the beginning.

Closes: #891206
2018-02-23 14:04:59 +00:00
Raphaël Hertzog a15b579652 Drop an optimization in chroot_archives that has undesired side-effects
Thanks to jnqnfe for the patch.

Closes: #775989
2016-11-28 21:48:18 +01:00
Sophie Brun e92dbc3696 Handle packages.chroot with an explicitly trusted file:// repository
Up to now we created a temporary GPG key that we registered with apt-key
but with the switch to GnuPG 2 by default, this code broke. Now we stop
doing that but we add the “trusted=yes“ attribute in sources.list so
that APT knows that the repository can be trusted even if it's unsigned.

Signed-off-by: Raphaël Hertzog <hertzog@debian.org>
2016-10-28 08:57:37 +02:00
Daniel Baumann 2dcb4dc06e Updating stat calls to also give the right result in container setups, thanks to Kristian Klausen <klausenbusk@hotmail.com> (Closes: #789300). 2015-08-10 21:45:00 +02:00
Daniel Baumann 279a149d8a Dropping automagics for ubuntu.
Future live-build versions will still allow to use casper,
but its configuration will be done differently by a custom
config tree, rather than embedded and maintenance intensive
code in live-build itself.
2015-05-03 16:03:10 +02:00
Daniel Baumann 242aef5d83 Updating year in copyright notices to 2015. 2015-01-04 20:05:44 +01:00
Daniel Baumann fdc9250bca Changing package dependency checks within chroot to work outside as well. 2015-01-04 18:19:47 +01:00