summaryrefslogtreecommitdiffstats
path: root/mkinitcpio
AgeCommit message (Collapse)AuthorFilesLines
2012-10-25Add -V/--version option to display version informationEric Bélanger1-2/+12
Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
2012-10-21function: add a map() utility function0.11.0Dave Reisner1-3/+1
map() runs the first argument (a function) with each of the remaining arguments as $1. The return value of map() is only 0 if all the calls succeeded. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-10-21convert autodetect cache to hashDave Reisner1-3/+4
If mkinitcpio -s is run, we still flush this cache to disk before exiting. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-10-07ensure builtins are dash/underscore translatedDave Reisner1-2/+4
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-10-07mkinitcpio: remove find_moduledirDave Reisner1-20/+2
Using anything but /lib/modules isn't really sane, and it shouldn't be supported. If you want to use /usr/lib/modules, then /lib must be a symlink to usr/lib. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-10-07separate image building to functionsDave Reisner1-129/+137
Mostly in favor of scoping out some variables further. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-10-07honor -n for presetsDave Reisner1-0/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-10-07mkinitcpio: check for preset file by sourcing itDave Reisner1-42/+44
Instead of using a bash test, just source the preset file. If it fails, exit. This patch is a bit ugly because it remove a level of indentation.
2012-10-07commit to some level of style in variable namingDave Reisner1-101/+104
This is an ugly patch, and probably does more than I'd like it to. The idea is that mkinitcpio adopts some sort of consistent style which I'm actually happy with. I define 3 kinds of variables: 1) local variables: all lower case, and scoped within functions. Use freely, as they're well contained. 2) global variables: these are known to mkinitcpio internally, but are global in scope. They mainly carry runtime configuration and collected data during the image generation process. These are always lower case, but carry a leading underscore to denote that they're global. 3) "API" variables: also global in scope, but exist "outside" of mkinitcpio -- either drawn in from the configuration file, or "exported" to the install hooks. These are always all upper case. When introducing new variables, extreme care must be taken to pick names that will not conflict with the environment inherited by mkinitcpio. A HACKING file is introduced with a similar description of the above, and more. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-30mkinitcpio: munge modules.order before calling depmodDave Reisner1-1/+7
The initramfs installs all modules to kernel/ which devalues the modules.order file. To avoid any edge cases with the wrong module being loaded (because all matching modules for a given alias will be added), make sure that the modules.order file is actually valid. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-30functions: always treat ADDED_MODULES as a hashDave Reisner1-1/+1
Overlooked in b8d9c5cd2753e9. This change also assigns a value of "2" to builtin modules which are added to the the ADDED_MODULES array, to distinguish them from actual modules on disk. Using this, we can avoid adding builtins to the image's runtime config. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-24mkinitcpio: protect module install on $MODPATHSDave Reisner1-1/+1
This was always wrong and should have been braced by MODPATHS rather than ADDED_MODULES. However, since ADDED_MODULES now possibly contains modules that weren't actually added (builtins), creating an initramfs without modules causes cp to be passed a null string to be copied. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-24force bsdcpio to run with LANG=CDave Reisner1-1/+1
In case mkinitcpio is in run via chroot(1), this possibly silences a harmless warning about bsdcpio failing to set the default locale. This comes up fairly often with the recent install media and users think that it's something to be concerned about. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-17silently ignore builtin modulesDave Reisner1-0/+7
Assuming modules.builtin exists, add the module names it contains to the ADDED_MODULES hash so that we silently skip over them. Suggested-by: Matthew Monaco <dgbaley27@0x01b.net> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-17declare ADDED_MODULES as associative arrayDave Reisner1-2/+2
Lookups in the hash table are far faster than traversing the entire array, as this grows O(n) and introduces a particularly noticeable slowdown on larger images. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-09-01mkinitcpio: refuse to run if image path isn't writeableDave Reisner1-0/+7
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-07-28mkinitcpio: rename longopt for --add to --addhooksDave Reisner1-7/+7
Rename this option so that it mirrors the longopt name for -S, --skiphooks. The original --add option remains behind in the option parser for backwards compatability, but no other references remain. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-07-28implement --moduleroot optionDave Reisner1-3/+7
This might be useful for creating an initramfs image as part of a kernel package. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-07-15initalize buildroot later, and out outside of hooksDave Reisner1-26/+9
mkinitcpio needs to be able to more tightly control the layout of the image. By moving this outside the control of the base hook, it's more reasonable to believe that a drop-in replacement for the base hook could be written, as it now only contains the utilities required for the /init that it provides. Being that initialize_buildroot is outside of a hook, we can make "raw" calls to coreutils that create the directories and symlinks, saving some overhead and forking. This also symlinks /usr/local/{lib,bin} into the common /usr/lib and /usr/bin, respectively, so that there's always a way to override libs and bins, and they're automatically pulled into our strict early init path of /usr/bin. Finally, we lump all this generally a little "later" in the early setup. This addresses an unseen "bug" wherein an extra temp directory that never gets used is created when leveraging a preset. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-07-15use last exit status as default arg for cleanupDave Reisner1-1/+3
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-08remove redundant header commentDave Reisner1-8/+1
I've adopted the convention of specifying the shebang for the interpreter any given install or runtime hook that a script runs under. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-08Use declare -f over type -t to avoid subshellsDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-02Don't report success when builderrors > 00.9.1Dave Reisner1-1/+1
Technically, we report success when we wrote an image to disk, but this might not be obvious to users, even with a blaring warning right before this line. If in the event builderrors is incremented at all, avoid reporting any sort of "success", since there might be cause for concern. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-01add hookpoints to --hookhelp outputDave Reisner1-0/+1
Generalize the awk program embedded in add_runscript and create a separate function which can be reused to display the specific hooks that a script has. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-01avoid subshell in adding --quiet to bsdcpioDave Reisner1-4/+13
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-06-01move running of hooks to separate functionDave Reisner1-42/+2
This allows us to declare sourced variables that we want to shield from stomping on our config variables, and without needing to use a subshell. Incidentally, this also fixes FS#29992 in a more permanent way. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
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>