summaryrefslogtreecommitdiffstats
path: root/mkinitcpio
AgeCommit message (Collapse)AuthorFilesLines
2012-05-18mkinitcpio: write image config after install hooksDave Reisner1-0/+2
Break this out of install/base into a separate function. We need to be able to read from the RUNHOOKS array to accurately specify which hooks to execute at runtime. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-18functions: introduce add_runscriptDave Reisner1-0/+1
This function adds a runtime script to the /hooks directory on the initramfs image. Note that this function will also install hooks with executable permissions for use by a later change to early init. With this commit, there are now methods available which can be used in place of the MODULES, FILES, BINARIES, and SCRIPT variables, as we now offer error checking on the add_* functions. Usage of the variables is deprecated, and these will no longer be read in a future version of mkinitcpio. This commit also lays the groundwork for the addition of more early userspace hooks. Runtime hook files are parsed for specific functions and variables (not yet used) are populated. These will eventually be written to the image config so that early userspace knows exactly what to run. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-16move -g option checking to parseopts loopDave Reisner1-9/+5
Avoid any delay in checking this option, as it only serves to fragment the logic. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-16refactor error tracking in build hooksDave Reisner1-6/+7
Rather than catching errors solely from parse_hook via an ERR trap, implement a RETURN trap which catches all errors from the core add_* functions. In the future, this may mean that support for MODULES/FILES/BINARIES within hooks goes away, and those variables remain only in the config. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-16mkinitcpio: separate logic to resolve kernel versionDave Reisner1-8/+22
Rename get_kernelver -> resolve_kernelver, and ensure that it only does what it's name advertises. Introduce find_moduledir to locate the corresponding module directory in /usr/lib or /lib. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-16use MODULEDIR as reference for *.(order|builtin) filesDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-12remove unnecessary quoting/bracingDave Reisner1-5/+5
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-12mkinitcpio: remove --basedir optionDave Reisner1-28/+12
This option is just a bad idea. Initramfs creation is too important to get wrong, and running it from outside the root FS has too many gotchas, the worst of them being: - where do you pull hooks from? - how do you resolve binary dependencies within the root? In general, dealing with the extra luggage of the base directory makes the codebase more complicated than it needs to be (see all the '_' prefixed functions which are called from add functions). In favor of simplifying the code, and making it more maintainable, kill this off and force the sane option of chroot'ing into an install if the need arises. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-05-02ensure that cmdline added hooks are run properly in early initDave Reisner1-3/+13
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-22mkinitcpio: check return of cd before listing hooksDave Reisner1-2/+2
$ mkinitcpio -L ==> Available hooks /usr/bin/mkinitcpio: line 173: cd: /lib/initcpio/install: No such file or directory sort and dedupe as well, since we deal with a hierarchy which may (for some horrible reason) contain duplicates. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-22mkinitcpio: dont exit from usageDave Reisner1-2/+2
Additionally, exit zero after returning. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-22mkinitcpio: adopt parseopts for option parsingDave Reisner1-58/+94
Updates the doc and bash-completion, as well. Also adds the previously unmentioned -A option to the --help output. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-16mkinitcpio: refuse to run without hooks definedDave Reisner1-0/+4
This still doesn't solve all our problems, but it gets us closer. There's no point in creating an image if HOOKS aren't present as this is the bread and butter of any sane mkinitcpio recipe. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-16mkinitcpio: refer to /usr/lib/modules uniformlyDave Reisner1-5/+5
This should have been done as part of b65cf9cd9. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-02create /lib as a symlink to /usr/lib0.8.6Dave Reisner1-1/+1
This makes us a little more future proof as far as moving files around. No need for 2 lib/ directories in early userspace anyways. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-02mkinitcpio: hardcode a sane PATHDave Reisner1-3/+3
Avoid pulling insane apps from user added PATH elements. FS#29162 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-02add minor tweaks to make testing a bit easierDave Reisner1-2/+2
Since INSTDIR and HOOKDIR are understood as arrays now, declare them as such with the local 'hooks' and 'install' first to override the local FS. This makes the missing udev error go away and allows easier testing of other out of tree hooks. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-06mkinitcpio: force UID/GID 0 for files written to imageDave Reisner1-1/+1
This fixes a strange edge where-in a user creates an image as non-root and attempts to boot from it. Any setuid binaries (such as mount) will fail, as the ownership is preserved. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-04mkinitcpio: dedupe MODPATHS array before installation0.8.4Dave Reisner1-1/+2
The only reason this has to be done is because of the Kconfig option that reuses the ext4 module for ext[23], thereby aliasing ext[23] to ext4. This is (currently) the only case in the whole kernel where valid module names magically become aliases. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-04add -A option to specify extra hooksDave Reisner1-2/+5
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-04mkinitcpio: allow -S to be specified multiple timesDave Reisner1-1/+3
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-04add support for HOOKDIR/INSTDIR as arraysDave Reisner1-34/+48
This is a really ugly patch, but allows mkinitcpio to read hooks from multiple locations, namely: /usr/lib/initcpio/{install,hooks} /lib/initcpio/{install,hooks} Preference is given to the first, and all files included with mkinitcpio are moved there. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-02-17mkinitcpio: unzip modules before image compressionTom Gundersen1-0/+3
This increases compression efficiency, which might be useful on an image containing a lot of modules. For the usecase I had in mind, this reduced the size by about a quarter. Signed-off-by: Tom Gundersen <teg@jklm.no> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-02-14mkinitcpio: install all modules to a single dirDave Reisner1-6/+2
depmod doesn't care where modules are, within reason, and separating modules into the respective hierarchies only serves to irritate users who go looking for modules in the rootfs (aka me). Forget all this and dump everything into the kernel/ dir. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-02-14mkinitcpio: catch more buildtime errorsDave Reisner1-3/+6
Move the unsetting of the errtrace and ERR trap flags to after the image has been built. This lets us capture errors during module installation to the build root and the call to depmod. Either of these steps failing could be hazardous and should prompt a failure. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-01-28mkinitcpio: obsolete install as a buildhook functionDave Reisner1-7/+1
All official hooks have been using build() for quite some time now. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-01-11Keep modules.devname needed for on-demand module loadingGerardo Exequiel Pozzi1-2/+2
Otherwise we need to modprobe module manually. (Particulary I need this for archiso for using /dev/loop-control) Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
2012-01-05mkinitcpio: include modules.{builtin,order} for depmod callDave Reisner1-1/+6
When present, modules.order will allow depmod to order the binary module indicies for faster lookups and more deterministic behavior in resolving aliases. We can discard this file from the buildroot after depmod is called. modules.builtin.bin is added as well (generated from modules.builtin), to allow modprobe to not fail when a symbol is provided as a builtin. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-01-05mkinitcpio: remove hardcoded pathsDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-26mkinitcpio: avoid color when stdout isn't a ttyDave Reisner1-1/+1
Follow suit with lsinitcpio (change 0495018d) and make output colorless on redirecting/piping stdout. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-17ensure MODULEDIR is declared with a trailing slashDave Reisner1-1/+1
This forces bash tests as well as utilities like find to dereference MODULEDIR in the odd case that it's a symlink. Addresses FS#27494 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-05mkinitcpio: add VERSION stamp to imageDave Reisner1-1/+6
This is mostly a debugging aid. lsinitcpio will be taught to read this. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-11-29mkinitcpio: parse vars from config file lastDave Reisner1-2/+10
This lets the config file be an override for any files or binaries added by hooks. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-11-29mkinitcpio: warn when no modules are added to the imageDave Reisner1-0/+2
Maybe something went wrong with depmod after a kernel install, or the user grabbed a kernel directory for an old kernel. Either way, if you're using an initramfs, there's a very high probability that you'll have at least 1 module on it. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-25mkinitcpio: dereference symlinks when resolving kernverDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-16mkinitcpio: ensure get_kernver always returns a kverDave Reisner1-12/+17
- Always call this function. At worst, just return the current kver. - Do all our error reporting from within the function. - Add an additional check for existance prior to allow for a more appropriate error message when we encounter a situation such as /boot not being mounted. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-16mkinitcpio: avoid stomping on TMPDIR from the environmentDave Reisner1-10/+13
cc36db45 was a bit too strict about localizing variables and blew out TMPDIR, which might be a legit variable sourced from the calling environment. Restore this behavior with a bit of refactoring, and additionally add in a check to make sure the temporary directory is writeable before proceeding. Fixes FS#26373. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-09mkinitcpio: avoid using mountpointDave Reisner1-2/+4
As it turns out, the mountpoint toy from util-linux isn't really at feature parity with sysvinit's. In particular, and with respect to v2.20: - It throws false negatives when /proc isn't mounted. Rather, it should fall back on using stat(2), as is the basis for sysvinit's tool. - when /proc is mounted with as source of 'none', it segfaults on a null dereference. Patches have been sent upstream to resolve these issues, but in the meantime, we're mounting /dev and /proc for very specific reasons. Instead of relying on a fork/exec to figure out if these API FS's are mounted, use a simple bash test to see if these specific needs are available within the FS. One of many possible fixes for FS#26344. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-01mkinitcpio: avoid creating savelist in main loopDave Reisner1-3/+3
If PRESET is set, we're in the main loop, not a worker process. No image will ever be created here, so there's never a need for saving any build dir. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-01remove duplicate "error" in error messageDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-01use correct variable to reference compression methodDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-01mkinitcpio: insist that /dev and /proc be mountedDave Reisner1-0/+4
This avoids errors with process substitutions in chroots, among other things. It's important that /proc be checked first as /etc/mtab might be a link to /proc/self/mounts. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-27mkinitcpio: keep going even when a hook isn't foundDave Reisner1-1/+2
Instead of bailing entirely, throw an error, and ensure that we exit with a non-zero status. The user might do something as simple as misspell a hook name which may or may not prevent a useful image from being created. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-27mkinitcpio: explicitly create $BUILDROOTDave Reisner1-0/+3
Avoids explosions if a user has no HOOKS in their config, as seen: https://bbs.archlinux.org/viewtopic.php?pid=966344 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-27mkinitcpio: fix whitespace errors in error messagesDave Reisner1-2/+2
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-27mkinitcpio: simplify setting of SKIPHOOKSDave Reisner1-6/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-09-27ensure local scoping of variablesDave Reisner1-2/+2
Also make sure that simple variables are declared as null strings. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-09mkinitcpio: reference -h on failed option parsingDave Reisner1-2/+2
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-09mkinitcpio: add --quiet to bsdcpio without -vDave Reisner1-1/+3
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-07-04mkinitcpio: include version in help msgDave Reisner1-0/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>