Merge pull request #247 from manjaro/netinstall

Netinstall
This commit is contained in:
udeved 2016-08-01 19:10:22 +02:00 committed by GitHub
commit a2ac03afc2
8 changed files with 237 additions and 125 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
*~
*.tar.gz
*.tar.xz
.kateproject.d
.kateproject.d
data/misc

View file

@ -35,6 +35,9 @@ show_profile(){
[[ ${target_arch} == 'x86_64' ]] && msg2 "multilib: %s" "${multilib}"
msg2 "cal_netinstall: %s" "${cal_netinstall}"
msg2 "cal_unpackfs: %s" "${cal_unpackfs}"
msg2 "efi_boot_loader: %s" "${efi_boot_loader}"
msg2 "efi_part_size: %s" "${efi_part_size}"

View file

@ -37,6 +37,15 @@
# set uefi partition size
# efi_part_size=31M
# configure calamares for netinstall
# cal_netinstall="false"
# the default url for the netinstall.yaml
# cal_netgroups="https://raw.githubusercontent.com/calamares/calamares-manjaro/master/netinstall.yaml"
# configure calamares to use chrootcfg instead of unpackfs
# cal_unpackfs="true"
# unset defaults to given value
# plymouth_theme=manjaro-elegant

View file

@ -131,6 +131,31 @@
</listitem>
</varlistentry>
<varlistentry>
<term><varname>cal_netinstall=</varname></term>
<listitem><para>Accepts
<option>true</option> (the default)
<option>false</option>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>cal_unpackfs=</varname></term>
<listitem><para>Accepts
<option>true</option> (the default)
<option>false</option>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>cal_netgroups=</varname></term>
<listitem><para>Default url for the netinstall.yaml.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>efi_boot_loader=</varname></term>

View file

@ -9,50 +9,32 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
write_calamares_branding_desc(){
local conf="$1/usr/share/calamares/branding/sonar/branding.desc"
if [[ -f "$conf" ]];then
echo '---' > "$conf"
echo "componentName: sonar" >> "$conf"
echo '' >> $conf
echo 'strings:' >> $conf
echo " productName: ${dist_name} GNU Linux" >> "$conf"
echo " shortProductName: ${dist_name}" >> "$conf"
echo " version: ${dist_release}" >> "$conf"
echo " shortVersion: ${dist_release}" >> "$conf"
echo " versionedName: ${dist_name} GNU Linux ${dist_release}" >> "$conf"
echo " shortVersionedName: ${dist_name} Linux ${dist_release}" >> "$conf"
echo " bootloaderEntryName: ${dist_name}" >> "$conf"
echo '' >> $conf
echo 'images:' >> $conf
echo ' productLogo: "squid.png"' >> "$conf"
echo ' productIcon: "logo.png"' >> "$conf"
echo ' productWelcome: "languages.png"' >> "$conf"
echo '' >> $conf
echo 'slideshow: "show.qml"' >> "$conf"
echo 'style:' >> $conf
echo ' sidebarBackground: "#292F34"' >> "$conf"
echo ' sidebarText: "#FFFFFF"' >> "$conf"
echo ' sidebarTextSelect: "#292F34"' >> "$conf"
write_machineid_conf(){
local conf="$1/etc/calamares/modules/machineid.conf"
if [[ ${initsys} == 'openrc' ]];then
echo "systemd: false" > $conf
echo "dbus: true" >> $conf
echo "symlink: true" >> $conf
else
echo "systemd: true" > $conf
echo "dbus: true" >> $conf
echo "symlink: true" >> $conf
fi
}
write_calamares_machineid_conf(){
local conf="$1/etc/calamares/modules/machineid.conf"
echo "systemd: false" > $conf
echo "dbus: true" >> $conf
echo "symlink: true" >> $conf
}
write_calamares_finished_conf(){
write_finished_conf(){
local conf="$1/etc/calamares/modules/finished.conf"
echo '---' > "$conf"
echo 'restartNowEnabled: true' >> "$conf"
echo 'restartNowChecked: false' >> "$conf"
echo 'restartNowCommand: "shutdown -r now"' >> "$conf"
if [[ ${initsys} == 'openrc' ]];then
echo 'restartNowCommand: "shutdown -r now"' >> "$conf"
else
echo 'restartNowCommand: "systemctl -i reboot"' >> "$conf"
fi
}
write_calamares_bootloader_conf(){
write_bootloader_conf(){
source "$1/etc/mkinitcpio.d/${kernel}.preset"
local conf="$1/etc/calamares/modules/bootloader.conf"
echo '---' > "$conf"
@ -69,7 +51,7 @@ write_calamares_bootloader_conf(){
echo '#efiBootloaderId: "dirname"' >> "$conf"
}
write_calamares_services_conf(){
write_services_conf(){
local conf="$1/etc/calamares/modules/services.conf"
echo '---' > "$conf"
echo '' >> "$conf"
@ -110,7 +92,7 @@ write_calamares_services_conf(){
fi
}
write_calamares_displaymanager_conf(){
write_displaymanager_conf(){
local conf="$1/etc/calamares/modules/displaymanager.conf"
echo "displaymanagers:" > "$conf"
echo " - ${displaymanager}" >> "$conf"
@ -124,25 +106,27 @@ write_calamares_displaymanager_conf(){
echo "basicSetup: false" >> "$conf"
}
write_calamares_initcpio_conf(){
write_initcpio_conf(){
local conf="$1/etc/calamares/modules/initcpio.conf"
echo "---" > "$conf"
echo "kernel: ${kernel}" >> "$conf"
}
write_calamares_unpack_conf(){
write_unpack_conf(){
local conf="$1/etc/calamares/modules/unpackfs.conf"
echo "---" > "$conf"
echo "unpack:" >> "$conf"
echo " - source: \"/bootmnt/${iso_name}/${target_arch}/root-image.sqfs\"" >> "$conf"
echo " sourcefs: \"squashfs\"" >> "$conf"
echo " destination: \"\"" >> "$conf"
echo " - source: \"/bootmnt/${iso_name}/${target_arch}/${profile}-image.sqfs\"" >> "$conf"
echo " sourcefs: \"squashfs\"" >> "$conf"
echo " destination: \"\"" >> "$conf"
if [[ -f /bootmnt/${iso_name}/${target_arch}/${profile}-image.sqfs ]];then
echo " - source: \"/bootmnt/${iso_name}/${target_arch}/${profile}-image.sqfs\"" >> "$conf"
echo " sourcefs: \"squashfs\"" >> "$conf"
echo " destination: \"\"" >> "$conf"
fi
}
write_calamares_users_conf(){
write_users_conf(){
local conf="$1/etc/calamares/modules/users.conf"
echo "---" > "$conf"
echo "userGroup: users" >> "$conf"
@ -157,82 +141,146 @@ write_calamares_users_conf(){
echo "setRootPassword: true" >> "$conf"
}
brand_calamares_settings_conf(){
local conf="$1/usr/share/calamares/settings.conf"
if [[ -f $conf ]];then
if [[ -d $1/usr/share/calamares/branding/${iso_name}-${profile} ]];then
sed -i -e "s|^.*branding:.*|branding: ${iso_name}-${profile}|" "$conf"
elif [[ -d $1/usr/share/calamares/branding/${iso_name} ]];then
sed -i -e "s|^.*branding:.*|branding: ${iso_name}|" "$conf"
write_packages_conf(){
local conf="$1/etc/calamares/modules/packages.conf"
echo "---" > "$conf"
echo "backend: pacman" >> "$conf"
}
write_welcome_conf(){
local conf="$1/etc/calamares/modules/welcome.conf"
echo "---" > "$conf" >> "$conf"
echo "showSupportUrl: true" >> "$conf"
echo "showKnownIssuesUrl: true" >> "$conf"
echo "showReleaseNotesUrl: true" >> "$conf"
echo '' >> "$conf"
echo "requirements:" >> "$conf"
echo "requiredStorage: 5.5" >> "$conf"
echo "requiredRam: 1.0" >> "$conf"
echo "check:" >> "$conf"
echo " - storage" >> "$conf"
echo " - ram" >> "$conf"
echo " - power" >> "$conf"
echo " - internet" >> "$conf"
echo " - root" >> "$conf"
echo "required:" >> "$conf"
echo " - storage" >> "$conf"
echo " - ram" >> "$conf"
echo " - root" >> "$conf"
${cal_netinstall} && echo " - internet" >> "$conf"
}
write_settings_conf(){
local conf="$1/etc/calamares/settings.conf"
echo "---" > "$conf"
echo "modules-search: [ local ]" >> "$conf"
echo '' >> "$conf"
echo "instances:" >> "$conf"
echo '' >> "$conf"
echo "sequence:" >> "$conf"
echo "- show:" >> "$conf"
echo " - welcome" >> "$conf"
${cal_netinstall} && echo " - netinstall" >> "$conf"
echo " - locale" >> "$conf"
echo " - keyboard" >> "$conf"
echo " - partition" >> "$conf"
echo " - users" >> "$conf"
echo " - summary" >> "$conf"
echo "- exec:" >> "$conf"
echo " - partition" >> "$conf"
echo " - mount" >> "$conf"
if ${cal_netinstall};then
if ${cal_unpackfs};then
echo " - unpackfs" >> "$conf"
echo " - networkcfg" >> "$conf"
echo " - packages" >> "$conf"
else
echo " - chrootcfg" >> "$conf"
fi
else
echo " - unpackfs" >> "$conf"
echo " - networkcfg" >> "$conf"
fi
echo " - machineid" >> "$conf"
echo " - fstab" >> "$conf"
echo " - locale" >> "$conf"
echo " - keyboard" >> "$conf"
echo " - localegen" >> "$conf"
echo " - luksopenswaphookcfg" >> "$conf"
echo " - luksbootkeyfile" >> "$conf"
echo " - initcpiocfg" >> "$conf"
echo " - initcpio" >> "$conf"
echo " - users" >> "$conf"
echo " - displaymanager" >> "$conf"
echo " - hardwarecfg" >> "$conf"
echo " - networkcfg" >> "$conf"
echo " - hwclock" >> "$conf"
echo " - services" >> "$conf"
echo " - grubcfg" >> "$conf"
echo " - bootloader" >> "$conf"
echo " - postcfg" >> "$conf"
echo " - umount" >> "$conf"
echo "- show:" >> "$conf"
echo " - finished" >> "$conf"
echo '' >> "$conf"
echo "branding: ${iso_name}" >> "$conf"
echo '' >> "$conf"
echo "prompt-install: false" >> "$conf"
echo '' >> "$conf"
echo "dont-chroot: false" >> "$conf"
}
write_chrootcfg_conf(){
local conf="$1/etc/calamares/modules/chrootcfg.conf"
echo "---" > "$conf"
echo "requirements:" >> "$conf"
echo " - directory: /etc" >> "$conf"
echo " - directory: /var/log" >> "$conf"
echo " - directory: /var/cache/pacman/pkg" >> "$conf"
echo " - directory: /var/lib/pacman" >> "$conf"
echo '' >> "$conf"
echo "packages:" >> "$conf"
echo " - pacman" >> "$conf"
echo " - ${kernel}" >> "$conf"
echo '' >> "$conf"
echo "keyrings:" >> "$conf"
echo " - archlinux" >> "$conf"
echo " - manjaro" >> "$conf"
}
write_netinstall_conf(){
local conf="$1/etc/calamares/modules/netinstall.conf"
echo "---" > "$conf"
echo "groupsUrl: ${cal_netgroups}" >> "$conf"
}
configure_calamares(){
msg2 "Configuring Calamares ..."
mkdir -p $1/etc/calamares/modules
write_calamares_bootloader_conf "$1"
write_calamares_unpack_conf "$1"
write_calamares_displaymanager_conf "$1"
write_calamares_initcpio_conf "$1"
brand_calamares_settings_conf "$1"
if [[ ${initsys} == 'openrc' ]];then
write_calamares_machineid_conf "$1"
write_calamares_finished_conf "$1"
fi
write_calamares_services_conf "$1"
write_calamares_users_conf "$1"
if [[ -f $1/usr/share/applications/calamares.desktop && -f $1/usr/bin/kdesu ]];then
sed -i -e 's|sudo|kdesu|g' $1/usr/share/applications/calamares.desktop
fi
if [[ "${edition}" == 'sonar' ]]; then
write_calamares_branding_desc "$1"
fi
}
write_cli_inst_conf(){
local conf=$1/profile.conf
echo '' >> ${conf}
echo '# profile image name' >> ${conf}
echo "profile=${profile}" >> ${conf}
echo '' >> ${conf}
echo '# iso_name' >> ${conf}
echo "iso_name=${iso_name}" >> ${conf}
echo '' >> ${conf}
echo '# kernel' >> ${conf}
echo "kernel=${kernel}" >> ${conf}
}
configure_cli_inst(){
msg2 "Configuring cli-installer ..."
local path=$1${DATADIR}
[[ ! -d $path ]] && mkdir -p $path
cp ${profile_conf} $path
write_cli_inst_conf "$path"
}
configure_thus(){
msg2 "Configuring Thus ..."
source "$1/etc/mkinitcpio.d/${kernel}.preset"
local conf="$1/etc/thus.conf"
echo "[distribution]" > "$conf"
echo "DISTRIBUTION_NAME = \"${dist_name} Linux\"" >> "$conf"
echo "DISTRIBUTION_VERSION = \"${dist_release}\"" >> "$conf"
echo "SHORT_NAME = \"${dist_name}\"" >> "$conf"
echo "[install]" >> "$conf"
echo "LIVE_MEDIA_SOURCE = \"/bootmnt/${iso_name}/${target_arch}/root-image.sqfs\"" >> "$conf"
echo "LIVE_MEDIA_DESKTOP = \"/bootmnt/${iso_name}/${target_arch}/${profile}-image.sqfs\"" >> "$conf"
echo "LIVE_MEDIA_TYPE = \"squashfs\"" >> "$conf"
echo "LIVE_USER_NAME = \"${username}\"" >> "$conf"
echo "KERNEL = \"${kernel}\"" >> "$conf"
echo "VMLINUZ = \"$(echo ${ALL_kver} | sed s'|/boot/||')\"" >> "$conf"
echo "INITRAMFS = \"$(echo ${default_image} | sed s'|/boot/||')\"" >> "$conf"
echo "FALLBACK = \"$(echo ${fallback_image} | sed s'|/boot/||')\"" >> "$conf"
if [[ -f $1/usr/share/applications/thus.desktop && -f $1/usr/bin/kdesu ]];then
sed -i -e 's|sudo|kdesu|g' $1/usr/share/applications/thus.desktop
fi
write_settings_conf "$1"
write_welcome_conf "$1"
write_packages_conf "$1"
write_bootloader_conf "$1"
write_unpack_conf "$1"
write_displaymanager_conf "$1"
write_initcpio_conf "$1"
write_machineid_conf "$1"
write_finished_conf "$1"
write_netinstall_conf "$1"
write_chrootcfg_conf "$1"
write_services_conf "$1"
write_users_conf "$1"
}

View file

@ -385,6 +385,23 @@ configure_custom_image(){
msg "Done configuring [%s-image]" "${profile}"
}
write_live_session_conf(){
msg2 "Configuring live session ..."
local path=$1${DATADIR}
[[ ! -d $path ]] && mkdir -p $path
local conf=$path/live.conf
echo '# live session configuration' > ${conf}
echo '' >> ${conf}
echo '# autologin' >> ${conf}
echo "autologin=${autologin}" >> ${conf}
echo '' >> ${conf}
echo '# live username' >> ${conf}
echo "username=${username}" >> ${conf}
echo '' >> ${conf}
echo '# live password' >> ${conf}
echo "password=${password}" >> ${conf}
}
configure_live_image(){
msg "Configuring [live-image]"
configure_hosts "$1"
@ -404,7 +421,7 @@ configure_live_image(){
echo ${hostname} > $1/etc/hostname
msg2 "Disable systemd-gpt-auto-generator"
ln -sfv /dev/null "${path}/usr/lib/systemd/system-generators/systemd-gpt-auto-generator"
ln -sf /dev/null "${path}/usr/lib/systemd/system-generators/systemd-gpt-auto-generator"
;;
'openrc')
msg2 "Configuring hostname ..."
@ -414,8 +431,7 @@ configure_live_image(){
esac
configure_services_live "$1"
configure_calamares "$1"
configure_thus "$1"
configure_cli_inst "$1"
write_live_session_conf "$1"
msg "Done configuring [live-image]"
}

View file

@ -561,6 +561,10 @@ check_profile(){
done
[[ -f "${profile_dir}/Packages-Mhwd" ]] && packages_mhwd=${profile_dir}/Packages-Mhwd
if ! ${cal_netinstall};then
cal_unpackfs="true"
fi
}
check_requirements(){
@ -671,6 +675,8 @@ reset_profile(){
unset login_shell
unset tracker_url
unset piece_size
unset cal_netinstall
unset cal_unpackfs
}
make_profile(){

View file

@ -123,20 +123,12 @@ get_timer(){
echo $(date +%s)
}
get_timer_ms(){
echo $(date +%s%3N)
}
# $1: start timer
elapsed_time(){
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
}
# $1: start timer
elapsed_time_ms(){
echo $(echo $1 $(get_timer_ms) | awk '{ printf "%0.3f",($2-$1)/1000 }')
}
show_elapsed_time(){
info "Time %s: %s minutes" "$1" "$(elapsed_time $2)"
}
@ -373,6 +365,12 @@ check_profile_vars(){
if ! is_valid_bool "${pxe_boot}";then
die "pxe_boot only accepts true/false value!"
fi
if ! is_valid_bool "${cal_netinstall}";then
die "cal_netinstall only accepts true/false value!"
fi
if ! is_valid_bool "${cal_unpackfs}";then
die "cal_unpackfs only accepts true/false value!"
fi
}
load_profile_config(){
@ -439,6 +437,12 @@ load_profile_config(){
[[ -z ${piece_size} ]] && piece_size=21
[[ -z ${cal_netinstall} ]] && cal_netinstall='false'
[[ -z ${cal_unpackfs} ]] && cal_unpackfs='true'
[[ -z ${cal_netgroups} ]] && cal_netgroups="https://raw.githubusercontent.com/calamares/calamares-manjaro/master/netinstall.yaml"
check_profile_vars
return 0