summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rwxr-xr-xconfigs/profile/build.sh39
-rw-r--r--configs/profile/root-image/etc/motd2
-rw-r--r--configs/profile/root-image/etc/pacman-offline.conf10
-rwxr-xr-xconfigs/profile/root-image/root/customize_root_image.sh20
-rwxr-xr-xparabolaiso/mkparabolaiso39
6 files changed, 88 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index 879fd3a..c7c7494 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,6 @@
# mkparabolaiso output dirs
work
out
+
+# package caches
+configs/*/isorepo*/
diff --git a/configs/profile/build.sh b/configs/profile/build.sh
index 959c9eb..fe2bdfb 100755
--- a/configs/profile/build.sh
+++ b/configs/profile/build.sh
@@ -12,6 +12,7 @@ iso_arch='dual'
iso_version=$(date +%Y.%m.%d)
iso_label="PARA_$(date +%Y%m)"
iso_dirname='parabola'
+enable_offline_install='false'
work_dir=./work
out_dir=./out
target=''
@@ -40,6 +41,8 @@ _usage ()
echo " Default: ${iso_label}"
echo " -D <iso_dirname> Set the name of the directory inside the ISO"
echo " Default: ${iso_dirname}"
+ echo " -O Enable offline install."
+ echo " Default: '${enable_offline_install}'"
echo " -w <work_dir> Set the working directory"
echo " Default: ${work_dir}"
echo " -o <out_dir> Set the output directory"
@@ -60,9 +63,7 @@ run_once() {
# Setup custom pacman.conf with current cache directories.
make_pacman_conf() {
- local _cache_dirs
- _cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
- sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${_cache_dirs[@]})|g" ${releng_dir}/pacman.conf > ${pacman_conf}
+ sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${work_dir}/${arch}/root-image/isorepo/|g" ${releng_dir}/pacman.conf > ${pacman_conf}
}
# Base installation, plus needed packages (root-image)
@@ -74,6 +75,13 @@ make_basefs() {
# Additional packages (root-image)
make_packages() {
setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "$(grep -h -v ^# ${releng_dir}/packages.{both,${arch}})" install
+
+ # create live environment local repo
+ if [[ "$enable_offline_install" == 'true' ]]; then
+ local iso_repo_dir=${work_dir}/${arch}/root-image/isorepo
+
+ setarch ${arch} repo-add ${iso_repo_dir}/isorepo.db.tar.gz ${iso_repo_dir}/*
+ fi
}
# Copy mkinitcpio parabolaiso hooks and build initramfs (root-image)
@@ -91,13 +99,17 @@ make_setup_mkinitcpio() {
# Customize installation (root-image)
make_customize_root_image() {
+ [[ "$enable_offline_install" == 'true' ]] && offline='-O' || offline=''
+
cp -af ${releng_dir}/root-image ${work_dir}/${arch}
echo "Customizing root image"
iso_title="${iso_title}" \
+ enable_offline_install="${enable_offline_install}" \
setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} \
-C ${pacman_conf} \
-D ${iso_dirname} \
+ ${offline} \
-r ${chroot_customization_script} run
rm ${work_dir}/${arch}/root-image${chroot_customization_script}
}
@@ -225,9 +237,11 @@ make_aitab() {
# Build all filesystem images specified in aitab (.fs.sfs .sfs)
make_prepare() {
+ [[ "$enable_offline_install" == 'true' ]] && offline='-O' || offline=''
+
cp -a -l -f ${work_dir}/${arch}/root-image ${work_dir}
setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} pkglist
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} prepare
+ setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} ${offline} prepare
rm -rf ${work_dir}/root-image
# rm -rf ${work_dir}/${arch}/root-image (if low space, this helps)
@@ -245,13 +259,13 @@ make_iso() {
## prepare state ##
# set CLI options
-
-while getopts 'T:V:L:D:w:o:vh' arg; do
+while getopts 'T:V:L:D:Ow:o:vh' arg; do
case "${arg}" in
T) target="${OPTARG}" ;;
V) iso_version="${OPTARG}" ;;
L) iso_label="${OPTARG}" ;;
D) iso_dirname="${OPTARG}" ;;
+ O) enable_offline_install='true' ;;
w) work_dir="${OPTARG}" ;;
o) out_dir="${OPTARG}" ;;
v) verbose="-v" ;;
@@ -268,17 +282,18 @@ case "${target}" in
'i686'|'x86_64')
archs=${target}
iso_arch=${target}
- launch_msg="Building single-architecture ${iso_edition} ISO for ${target}"
+ launch_msg="Building single-architecture ${iso_edition} ISO for ${archs}"
;;
*)
- launch_msg="Building dual-architecture ${iso_edition} ISO for i686 and x86_64"
+ launch_msg="Building multi-architecture ${iso_edition} ISO for ${archs}"
;;
esac
-if [ "$enable_offline_install" == 'true' ]; then
+if [[ "$enable_offline_install" == 'true' ]]; then
iso_arch="${iso_arch}-complete"
- launch_msg="${launch_msg} with offline install enabled"
+ launch_msg="${launch_msg} (net-install or offline install)"
else
iso_arch="${iso_arch}-netinstall"
+ launch_msg="${launch_msg} (net-install only)"
fi
[ "${archs}" == 'i686' ] && arch='i686' || arch='x86_64'
iso_filename="parabola-${iso_edition}-${iso_arch}-${iso_version}.iso"
@@ -327,13 +342,13 @@ if ! (($is_done)); then echo ${launch_msg}; else echo "Nothing to do"; exit; fi;
## build ISO ##
+# prepare environment
chown -R 0:0 "${releng_dir}/root-image/"
mkdir -p ${work_dir}
-run_once make_pacman_conf
-
# prepare target filesystems
for arch in ${archs}; do
+ run_once make_pacman_conf
run_once make_basefs
run_once make_packages
run_once make_setup_mkinitcpio
diff --git a/configs/profile/root-image/etc/motd b/configs/profile/root-image/etc/motd
index a2bf698..49febe9 100644
--- a/configs/profile/root-image/etc/motd
+++ b/configs/profile/root-image/etc/motd
@@ -3,6 +3,8 @@
_EDITION_TITLE_
+ _NETWORK_MSG_
+
To install Parabola, the system must be connected to the internet.
For help establishing an internet connection, enter this command:
 lynx network.html 
diff --git a/configs/profile/root-image/etc/pacman-offline.conf b/configs/profile/root-image/etc/pacman-offline.conf
new file mode 100644
index 0000000..e6efcf1
--- /dev/null
+++ b/configs/profile/root-image/etc/pacman-offline.conf
@@ -0,0 +1,10 @@
+[options]
+HoldPkg = pacman glibc
+Architecture = auto
+CheckSpace
+SigLevel = Required DatabaseOptional
+LocalFileSigLevel = Optional
+
+[isorepo]
+SigLevel = Optional TrustAll
+Server = file:///isorepo/
diff --git a/configs/profile/root-image/root/customize_root_image.sh b/configs/profile/root-image/root/customize_root_image.sh
index de5481b..7505d8b 100755
--- a/configs/profile/root-image/root/customize_root_image.sh
+++ b/configs/profile/root-image/root/customize_root_image.sh
@@ -1,5 +1,16 @@
#!/bin/bash
+readonly ISO_REPO_DEFINITION="[isorepo]\nSigLevel = Optional TrustAll\nServer = file:///isorepo/"
+readonly NETINSTALL_MSG="To install Parabola, the system must be connected to the internet."
+readonly COMPLETE_MSG="This ISO is capable of installing a complete Parabola system\n\
+>>>>without a connection to the internet. If you would like to fetch\n\
+>>>>the latest packages from the internet, run the following command\n\
+>>>>before beginning the install:\n\
+ # cp /etc/pacman-online.conf /etc/pacman.conf"
+[ "${enable_offline_install}" == 'false' ] && readonly NETWORK_MSG=${NETINSTALL_MSG} || \
+ readonly NETWORK_MSG=${COMPLETE_MSG}
+
+
set -e -u
sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
@@ -17,7 +28,14 @@ chmod 750 /etc/sudoers.d
chmod 440 /etc/sudoers.d/g_wheel
sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist
+if [ "${enable_offline_install}" == 'true' ]
+then echo -e "${ISO_REPO_DEFINITION}" >> /etc/pacman.conf
+ mv /etc/pacman.conf /etc/pacman-online.conf
+ cp /etc/pacman-offline.conf /etc/pacman.conf
+else rm /etc/pacman-offline.conf
+fi
systemctl enable multi-user.target pacman-init.service choose-mirror.service
-sed -i "s|_EDITION_TITLE_|${iso_title}|" /etc/motd
+sed -i "s|_EDITION_TITLE_|${iso_title}|" /etc/motd
+sed -i "s|_NETWORK_MSG_|${NETWORK_MSG}| ; s|^>>>>\(.*\)| \1|g" /etc/motd
diff --git a/parabolaiso/mkparabolaiso b/parabolaiso/mkparabolaiso
index 7e70554..82eab30 100755
--- a/parabolaiso/mkparabolaiso
+++ b/parabolaiso/mkparabolaiso
@@ -16,6 +16,8 @@ iso_application="Parabola GNU/Linux-libre Live/Rescue CD"
install_dir="parabola"
work_dir="work"
out_dir="out"
+enable_offline_install='false'
+
# Show an INFO message
# $1: message string
@@ -77,6 +79,10 @@ _chroot_init() {
_pacman "base"
_pacman "syslinux"
fi
+ # Restore live local repo cache
+ if [[ -d "${work_dir}/isorepo-${arch}" ]]; then
+ mv "${work_dir}/isorepo-${arch}" "${work_dir}/root-image/"
+ fi
}
_chroot_run() {
@@ -152,6 +158,8 @@ _usage ()
echo " -D <install_dir> Set an install_dir. All files will by located here."
echo " Default: '${install_dir}'"
echo " NOTE: Max 8 characters, use only [a-z0-9]"
+ echo " -O Enable offline install."
+ echo " Default: '${enable_offline_install}'"
echo " -w <work_dir> Set the working directory"
echo " Default: '${work_dir}'"
echo " -o <out_dir> Set the output directory"
@@ -196,8 +204,10 @@ _show_config () {
;;
run)
_msg_info " Run command: ${run_cmd}"
+ _msg_info " Offline install: ${enable_offline_install}"
;;
prepare)
+ _msg_info " Offline install: ${enable_offline_install}"
;;
checksum)
;;
@@ -243,17 +253,21 @@ _cleanup () {
if [[ -d "${work_dir}/root-image/boot" ]]; then
find "${work_dir}/root-image/boot" -type f -name 'vmlinuz*' -delete
fi
- # Delete pacman database sync cache files (*.tar.gz)
- if [[ -d "${work_dir}/root-image/var/lib/pacman" ]]; then
- find "${work_dir}/root-image/var/lib/pacman" -maxdepth 1 -type f -delete
- fi
- # Delete pacman database sync cache
- if [[ -d "${work_dir}/root-image/var/lib/pacman/sync" ]]; then
- find "${work_dir}/root-image/var/lib/pacman/sync" -delete
- fi
- # Delete pacman package cache
- if [[ -d "${work_dir}/root-image/var/cache/pacman/pkg" ]]; then
- find "${work_dir}/root-image/var/cache/pacman/pkg" -type f -delete
+ if [[ "${enable_offline_install}" == 'false' ]]; then
+ # Delete pacman database sync cache files (*.tar.gz)
+ if [[ -d "${work_dir}/root-image/var/lib/pacman" ]]; then
+ find "${work_dir}/root-image/var/lib/pacman" -maxdepth 1 -type f -delete
+ fi
+ # Delete pacman database sync cache
+ if [[ -d "${work_dir}/root-image/var/lib/pacman/sync" ]]; then
+ find "${work_dir}/root-image/var/lib/pacman/sync" -delete
+ fi
+ # Delete pacman package cache
+ if [[ -d "${work_dir}/root-image/var/cache/pacman/pkg" ]]; then
+ find "${work_dir}/root-image/var/cache/pacman/pkg" -type f -delete
+ fi
+ # Stash live local repo cache
+ mv "${work_dir}/root-image/isorepo" "${work_dir}/isorepo-${arch}" 2> /dev/null || true
fi
# Delete all log files, keeps empty dirs.
if [[ -d "${work_dir}/root-image/var/log" ]]; then
@@ -526,7 +540,7 @@ if [[ ${EUID} -ne 0 ]]; then
_msg_error "This script must be run as root." 1
fi
-while getopts 'p:r:C:L:P:A:D:w:o:vh' arg; do
+while getopts 'p:r:C:L:P:A:D:Ow:o:vh' arg; do
case "${arg}" in
p) pkg_list="${pkg_list} ${OPTARG}" ;;
r) run_cmd="${OPTARG}" ;;
@@ -535,6 +549,7 @@ while getopts 'p:r:C:L:P:A:D:w:o:vh' arg; do
P) iso_publisher="${OPTARG}" ;;
A) iso_application="${OPTARG}" ;;
D) install_dir="${OPTARG}" ;;
+ O) enable_offline_install='true' ;;
w) work_dir="${OPTARG}" ;;
o) out_dir="${OPTARG}" ;;
v) quiet="n" ;;