Commit Graph

46 Commits

Author SHA1 Message Date
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 29ab2459c8 a couple tiny doc fixes
Gbp-Dch: Ignore
2020-04-29 10:27:16 +01: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 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
Raphaël Hertzog bdffaebe12 Minor cleanups in Require_stagefiles 2020-03-18 09:37:22 +01: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 fe0d2358b9 stagefiles: only list missing stages 2020-03-17 22:59:34 +00:00
Lyndon Brown 3bed138fda stagefiles: avoid stagename in required error
the name of the stage is already printed earlier in the output prior to
the error here being printed. so the error really does not need to include
the script name itself.
2020-03-17 22:57:09 +00:00
Lyndon Brown ea0f6b7810 stagefiles: fix completely wrong require-stages logic
now having investigated my suspicions of the functionality and use of
Require_stagefile(), i conclude that it has been fundamentally broken
all the way back to v1.0~a8-1 (or at least usage of it since v1.0.1-2).

gah. (╯°□°)╯︵ ┻━┻

----

very early on in the history of live-build this function took the name of
a _single_ stage file only and did `exit 1` should the file not be found.
this was simple and clearly accomplished "what was on the tin", so to
speak.

in bd1a5ddc82 (2007, 1.0~a8-1) things got
weird. it was modified to support a list of multiple files. but instead of
being written to cause failure if _any_ of the listed files were missing
as perhaps one might expect, it was instead written to fail only if all
files were missing!

if you jump to the conclusion that i'm talking about a simple flipped
logic from a lack or otherwise of a `!` here, you'd be mistaken; there is
a comment inside the function that could not be more clear about what was
intended by the author - "Find at least one of the required stages"! this
makes me thoroughly confused about what they were thinking.

as we'll get to, this was fundamentally flawed (or at least its later use
was), but furthermore there were other notable issues introduced at this
point (but don't worry too much about these, they've all been addressed):
 - `NAME` was modified in the loop, using the existing value, but nothing
   initially set it...
 - the setting of `NAME` seems related to its use in the subsequent error
   output, yet they are logically separated; it is only set if a file
   exists, while the error is only printed if none exist.
 - it is pointlessly using a messy `CONTINUE="true"` based mechanism,
   when it could just `return 0`.
 - it did not handle correctly the bad use case of no params having been
   supplied.

it doesn't seem to have been entirely thought through, despite its
pervasive use throughout the build system.

note that no change was made in that commit to make actual use of the
new multi-param support. it would not be used until about a year later.

the function has remained largely untouched since then. in
c68c0a2708 a notable change was made to add
an initial setting of `NAME`, which partially addressed one of the above
issues. but it did not really address the issue the change was meant to
solve, since the `NAME` as printed in the error was now the name of the
script when what was really wanted was the name of the stagefile. this was
finally fixed properly in d54990695f.
however the weirdly pointless setting of `NAME` persisted in the loop.

finally i personally just refactored the function in the commit prior to
this one, retaining the same functionality but addressing the remaining
of the above minor implementation issues.

looking at usage of the new functionality introduced in
bd1a5ddc82, it does not seem to have been
until 0cbbde2b96 (2008, almost a year after
it was made possible) that changes were made to finally start making use
of the ability to pass more than one filename at a time to the function,
and it would appear that perhaps the author forgot what it actually was
that the function accomplished when used with multiple params, and failed
to double check.

in this first use of multiple parameters, this commit went from passing
single file names to individual calls to the function to passing the files
in one single call, in a commit the purpose of which was described as
simply tidying things up. it was most certainly not intended to change
stage requirements.

unfortunately, a change in requirements did occur as a result since the
new usage of the function was not accomplishing the same as before. this
change completely broke the stage requirements protection mechanism such
that only a single one of the listed stages needed to have completed for
the check to pass, rather than all as expected.

this flaw made it into release v1.0.1-2 and it has existed every since.

in the very next commit from that one,
6204dc0e6d things got even worse. here we
see the config stage being specified commonly as the first stage listed,
which is still the case today. this means that ever since this commit,
if you've already got a config before building (which you inevitably do,
especially after some later commits introduced automatically creating it
if missing), then all other stage requirements are simply ignored.

so it seems pretty damn clear that this function is accomplishing
completely the wrong objective. it _should_ be checking that _all_ files
given to it exist, not just one or more. ¯\_(ツ)_/¯

this FINALLY addresses this mistake.

(not that i wish to berate the author; i've made silly mistakes of my own
before)
2020-03-17 22:57:09 +00:00
Lyndon Brown 1b09b15277 stagefiles: refactor Require_stagefile()
- count of params is available as $#, we don't need the pipe-to-wc logic.
 - the whole 'CONTINUE' based logic is silly, we can just return once one
   of the files is found.
 - setting of 'NAME' in the loop was completely pointless.
 - the error message for multiple files was not very clear just injecting
   a sequence of words into a sentence.
 - it did not work correctly if no arguments were given (bad usage)

note, you might question whether the functionality of this function is
correct, as did I; this is tackled in a followup commit whilst this
commit retains the existing functionality!

Gbp-Dch: Short
2020-03-17 22:57:04 +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 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 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 2c78d36bd5 use actual bool state where applicable within functions 2020-03-09 11:17:53 +00:00
jnqnfe 5a00487872 fix capitalisation of some output messages
Closes: #952875
2020-03-05 20:36:54 +00:00
Daniel Baumann 242aef5d83 Updating year in copyright notices to 2015. 2015-01-04 20:05:44 +01:00
Daniel Baumann eb336bb782 Updating copyright notices for 2014. 2014-02-08 17:47:24 +01:00
Daniel Baumann 59ce459f40 Removing all references to my old email address. 2013-05-06 14:50:06 +02:00
Daniel Baumann 62d94a4454 Updating year in all copyright notices. 2013-05-06 14:50:03 +02:00
Daniel Baumann d1047e809a Adding debian version 4.0~a1-1. 2013-05-06 14:48:46 +02:00
Daniel Baumann a203b86fdd Updating year in all copyright notices. 2013-01-01 00:13:01 +01:00
Daniel Baumann 508510e097 Updating GPL standard header in all files. 2012-07-30 18:19:27 +02:00
Daniel Baumann 822dc2c028 Updating year in copyright notices for 2012. 2012-02-06 23:15:12 +01:00
Daniel Baumann 65f626fe9c Improve message when skipping a helper because it is already run. 2011-09-07 15:53:50 +02:00
Daniel Baumann 18eeaae602 Updating year in hooks and script files. 2011-03-09 19:20:42 +01:00
Daniel Baumann c5c3f6133a Adding debian version 3.0~a1-1. 2011-03-09 19:19:23 +01:00
Daniel Baumann 2ddc0cef5d Updating year in manpage, hooks, script and template files. 2011-03-09 19:17:33 +01:00
Daniel Baumann 4d22ca948a Updating copyright headers for live-build. 2011-03-09 19:17:18 +01:00
Daniel Baumann 54518852c8 Updating year to 2010 in copyright notices. 2011-03-09 19:17:04 +01:00
Daniel Baumann 701b5affd4 For consistency, using true|false instead of enabled|disabled in configuration options. 2011-03-09 19:17:03 +01:00
Daniel Baumann 989f26d87b Updating year in copyright notices for 2009. 2011-03-09 19:09:40 +01:00
Daniel Baumann 137f573c85 Generalizing internal LH_FORCE variable. 2011-03-09 19:03:43 +01:00
Daniel Baumann 37d2fb4b0f Don't use set -e in sourced functions, this is the job of the actual executed script. 2011-03-09 19:03:43 +01:00
Tiago Bortoletto Vaz 6205a24620 Adding last modifications in order to have localization fully working in live-helper. This commit goes with some pt_BR translations just for testing. Thanks to Antonio Terceiro for helping and coding in some shell stuff. 2011-03-09 19:03:38 +01:00
Daniel Baumann d54990695f Applying patch from Bas Wijnen <wijnen@debian.org> to correct error messages in Require_stagefile (Closes: #472774). 2011-03-09 19:03:31 +01:00
Daniel Baumann c5a91189a0 Updating copyright years to 2008. 2011-03-09 19:01:41 +01:00
Daniel Baumann f2734daf0a Replacing backticks with POSIX expression. 2011-03-09 18:22:27 +01:00
Daniel Baumann c68c0a2708 Adding live-helper 1.0~a21-1. 2011-03-09 18:22:26 +01:00
Daniel Baumann 85c342c299 Adding live-helper 1.0~a13-1. 2011-03-09 18:18:30 +01:00
Daniel Baumann bd1a5ddc82 Adding live-helper 1.0~a8-1. 2011-03-09 18:18:29 +01:00
Daniel Baumann 8a4a50fdb6 Adding live-helper 1.0~a7-1. 2011-03-09 18:18:29 +01:00
Daniel Baumann 1863ed8874 Adding live-helper 1.0~a5-1. 2011-03-09 18:18:29 +01:00
Daniel Baumann da353a5231 Adding live-helper 1.0~a4-1. 2011-03-09 18:18:29 +01:00
Daniel Baumann 799d4bfb31 Adding live-helper 1.0~a3-1. 2011-03-09 18:18:28 +01:00
Daniel Baumann fe6eb1c593 Adding live-helper 1.0~a1-1. 2011-03-09 18:14:51 +01:00