Started adding support for offline installer image
- If geninstaller is run with -o or --offline, then during generate_img, chroot into target and run apt-get install with all required packges for subiquity. - At the moment, cloud-init will still attempt to install packages when it boots without network, then fail over to the next part of the init, and eventually will run subiquity. - While this is functional for an offline installer, it is preferrable to tell cloud-init not to try to install packages, to avoid extra delays and to keep errors out of the cloud-init log
This commit is contained in:
parent
bd2f6014e5
commit
411656ed99
|
@ -33,6 +33,13 @@ SRC_DEPS=(
|
|||
"bzr" "lp:~wesley-wiedenmeier/curtin/custom-partitioning-layout" "curtin"
|
||||
"git" "https://github.com/CanonicalLtd/probert.git" "probert"
|
||||
)
|
||||
INSTALLER_DEPS=(
|
||||
"python3-parted"
|
||||
"python3-urwid"
|
||||
"python3-pyudev"
|
||||
"python3-netifaces"
|
||||
"python-urwid"
|
||||
)
|
||||
CACHEDIR=""
|
||||
|
||||
cleanup_noexit() {
|
||||
|
@ -102,6 +109,7 @@ usage: $PROG [PARAMS] [ARGS]
|
|||
-a, --arch=ARCH For ARCH in [i386, amd64, ppc64el, armf, arm64]
|
||||
-b, --bootloader=TYPE For TYPE in [syslinux, grub2, uboot]
|
||||
-h, --help This output.
|
||||
-o, --offline Offline installer img.
|
||||
-r, --release=RELEASE For RELEASE in [trusty, utopic, vivid, wily]
|
||||
-s, --stream=STREAM For STREAM in [daily, released]
|
||||
-V, --version=VERSION VERSION=YYYYMMDD , 20150623
|
||||
|
@ -284,7 +292,7 @@ acquire_image() {
|
|||
|
||||
generate_seed() {
|
||||
_RETVAL=""
|
||||
[ $# -lt 2 ] && {
|
||||
[ $# -lt 3 ] && {
|
||||
log "ERROR: not enough arguments passed to $FUNCNAME";
|
||||
return 1;
|
||||
}
|
||||
|
@ -293,6 +301,7 @@ generate_seed() {
|
|||
local cachedir=${2};
|
||||
local seed=$cachedir/seed/nocloud-net
|
||||
local installer_user_data=${TOPDIR}/resources/user-data/installer-user-data
|
||||
local installer_user_data_offline=${TOPDIR}/resources/user-data/installer-offline-data
|
||||
|
||||
# create curtin payload
|
||||
log "Generating curtin payload file"
|
||||
|
@ -317,6 +326,11 @@ generate_seed() {
|
|||
# append the curtin-cmd file
|
||||
rm -f ${seed}/user-data &&
|
||||
cp $installer_user_data $seed/user-data &&
|
||||
|
||||
if [ "${OFFLINE}" == "yes" ]; then
|
||||
log "Disabling package_update/upgrade"
|
||||
fi
|
||||
|
||||
userdata_write_file "/usr/local/bin/curtin-archive" \
|
||||
"root:root" "0755" "none" \
|
||||
"$curtin_cmd" >> $seed/user-data || {
|
||||
|
@ -355,7 +369,7 @@ generate_seed() {
|
|||
|
||||
generate_img() {
|
||||
_RETVAL=""
|
||||
[ $# -lt 3 ] && {
|
||||
[ $# -lt 4 ] && {
|
||||
log "ERROR: not enough arguments passed to $FUNCNAME";
|
||||
return 1;
|
||||
}
|
||||
|
@ -444,6 +458,20 @@ generate_img() {
|
|||
sudo mount none -t sysfs ${mnt}/sys &&
|
||||
sudo mount -o bind /dev ${mnt}/dev &&
|
||||
|
||||
if [ "${OFFLINE}" == "yes" ]; then
|
||||
set -x
|
||||
log "Setting up for offline use"
|
||||
local resolvconf=${mnt}/etc/resolv.conf
|
||||
sudo mv ${resolvconf} ${resolvconf}.old
|
||||
sudo cp /etc/resolv.conf ${resolvconf}
|
||||
for installer_package in "${INSTALLER_DEPS[@]}"; do
|
||||
sudo chroot ${mnt} apt-get install $installer_package
|
||||
done
|
||||
sudo rm ${resolvconf}
|
||||
sudo mv ${resolvconf}.old ${resolvconf}
|
||||
set +x
|
||||
fi
|
||||
|
||||
if [ "${bootloader}" == "syslinux" ]; then
|
||||
sudo mkdir -p ${mnt}/boot/extlinux &&
|
||||
sudo extlinux --install ${mnt}/boot/extlinux &&
|
||||
|
@ -479,8 +507,8 @@ parse_args() {
|
|||
# args:
|
||||
[ $# -lt 1 ] && { usage; exit 0; }
|
||||
|
||||
OPTS_LONG="arch:,bootloader:,download:,help,release:,stream:,verbose,version:"
|
||||
OPTS="a:b:d:hr:s:vV:"
|
||||
OPTS_LONG="arch:,bootloader:,download:,help,offline,release:,stream:,verbose,version:"
|
||||
OPTS="a:b:d:hor:s:vV:"
|
||||
ARGS=`getopt --name "$PROG" --long $OPTS_LONG --options $OPTS -- "$@"`
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$PROG: usage error (use -h for help)" >&2
|
||||
|
@ -491,6 +519,7 @@ parse_args() {
|
|||
ARCH="amd64"
|
||||
BOOTLOADER="syslinux"
|
||||
DLDIR=~/download
|
||||
OFFLINE="no"
|
||||
RELEASE="wily"
|
||||
STREAM="daily"
|
||||
VERBOSE="no"
|
||||
|
@ -501,6 +530,7 @@ parse_args() {
|
|||
-b | --bootloader) BOOTLOADER="$2"; shift;;
|
||||
-d | --download) DLDIR="$2"; shift;;
|
||||
-h | --help) usage; exit 0;;
|
||||
-o | --offline) OFFLINE="yes";;
|
||||
-r | --release) RELEASE="$2"; shift;;
|
||||
-s | --stream) STREAM="$2"; shift;;
|
||||
-V | --version) VERSION="$2"; shift;;
|
||||
|
@ -538,11 +568,11 @@ main() {
|
|||
CACHEDIR=${_RETVAL}
|
||||
log "CACHEDIR=$CACHEDIR"
|
||||
|
||||
generate_seed ${DLDIR} $CACHEDIR || {
|
||||
generate_seed ${DLDIR} $CACHEDIR $OFFLINE || {
|
||||
return 1;
|
||||
}
|
||||
|
||||
generate_img ${DLDIR} $CACHEDIR $BOOTLOADER || {
|
||||
generate_img ${DLDIR} $CACHEDIR $BOOTLOADER $OFFLINE || {
|
||||
return 1;
|
||||
}
|
||||
INSTALLIMG=${_RETVAL}
|
||||
|
|
Loading…
Reference in New Issue