summaryrefslogtreecommitdiff
path: root/osi-mk
diff options
context:
space:
mode:
Diffstat (limited to 'osi-mk')
-rwxr-xr-xosi-mk35
1 files changed, 27 insertions, 8 deletions
diff --git a/osi-mk b/osi-mk
index a46ee17..58dc1e5 100755
--- a/osi-mk
+++ b/osi-mk
@@ -87,9 +87,10 @@ main() {
local arg_directories=()
local arg_modules=()
local arg_packages=()
+ local arg_package_files=()
local args
- if ! args="$(getopt -n "${0##*/}" -o "s:e::d:m:p:hV" -l "inside:,size:,edit::,directory:,module:,package:,help,version" -- "$@")"; then
+ if ! args="$(getopt -n "${0##*/}" -o "s:e::d:m:p:P:hV" -l "inside:,size:,edit::,directory:,module:,package:,package-file:,help,version" -- "$@")"; then
arg_mode=error
else
eval "set -- $args"
@@ -102,6 +103,7 @@ main() {
-d|--directory) shift; arg_directories+=("$1"); shift;;
-m|--module) shift; arg_modules+=("$1"); shift;;
-p|--package) shift; arg_packages+=("$1"); shift;;
+ -P|--package-file) shift; arg_package_files+=("$1"); shift;;
-V|--version) shift; arg_mode=version;;
-h|--help) shift; arg_mode=usage;;
@@ -133,6 +135,12 @@ main() {
arg_mode=error
fi
done
+ for package_file in "${arg_package_files[@]}"; do
+ if ! [[ -f "$package_file" ]]; then
+ error 0 'Package file does not exist: %s' "$package_file"
+ arg_mode=error
+ fi
+ done
if [[ $arg_mode = outside ]]; then
if [[ ( $arg_edit = false || -n $arg_edit_base ) && -e $arg_file ]]; then
error 2 'Image file already exists, refusing to overwrite: %s' "$arg_file"
@@ -163,16 +171,19 @@ main() {
print 'Create a mountable, bootable OS image.'
echo
print 'OPTIONS:'
+ # 000000000011111111112222222222333333333344444444445555555555666666666677777777778
+ # 012345678901234567890123456789012345678901234567890123456789012345678901234567890
+ print ' -s SIZE, --size=SIZE set the size of the image'
+ print ' -e[BASE.img], --edit[=BASE.img] edit an existing image'
# --inside is internal-only; undocumented
- print ' -s SIZE, --size=SIZE set the size of the image (default: 1G)'
- print ' -e[BASE.img], --edit[=BASE.img] edit an existing image'
echo
- print ' -d OUTSIDE:INSIDE, --directory=OUTSIDE:INSIDE include the given directory'
- print ' -m MOD.sh, --module=MOD.sh include the given module'
- print ' -p PACKAGE, --package=package include the given package (or group)'
+ print ' -d OUTSIDE:INSIDE, --directory=OUTSIDE:INSIDE include the given directory'
+ print ' -m MOD.sh, --module=MOD.sh include the given module'
+ print ' -p PKGNAME, --package=PKGNAME include the given package (or group)'
+ print ' -P PKG.pkg.tar.xz, --package-file=PKG.pkg.tar.xz include the given package file'
echo
- print ' -h, --help display this help'
- print ' -V, --version output version information'
+ print ' -h, --help display this help'
+ print ' -V, --version output version information'
return 0
;;
@@ -272,6 +283,14 @@ main() {
--needed \
"${packages[@]}"
fi
+ if (( ${#arg_package_files[@]} > 0 )); then
+ dir="$(mktemp -d -- "$arg_mountpoint/tmp/package-files.XXXXXXXXXX")"
+ trap "rm -rf -- ${dir@Q}" EXIT
+ cp -t "$dir" -- "${arg_package_files[@]}"
+ arch-chroot -- "$arg_mountpoint" pacman -U --noconfirm -- "${arg_package_files[@]/#*\//"/tmp/${dir##*/tmp/}"}"
+ rm -rf -- "$dir"
+ trap - EXIT
+ fi
} |& sed "s|^|${prefix} |"
### post_install ###