From 8d56527fd07e199b78437bcc7fd8d87cb1a81e09 Mon Sep 17 00:00:00 2001 From: wangchuanguo Date: Sat, 2 Sep 2023 14:31:04 +0800 Subject: [PATCH] add tool of creating liveISO Signed-off-by: wangchuanguo --- create-liveiso.sh | 352 ++++++++++++++++++++++++++++++++++++++ livemedia.conf | 25 +++ livemedia.ks | 428 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 805 insertions(+) create mode 100755 create-liveiso.sh create mode 100644 livemedia.conf create mode 100644 livemedia.ks diff --git a/create-liveiso.sh b/create-liveiso.sh new file mode 100755 index 0000000..ed1b4a5 --- /dev/null +++ b/create-liveiso.sh @@ -0,0 +1,352 @@ +#! /bin/bash +source ./livemedia.conf + +###################### +PRODUCT=`cat "$target"/etc/os-release | grep "^NAME" | cut -d \" -f2` +PRODUCT=`echo $PRODUCT|sed 's/ /-/g'|awk '{print tolower($0)}'` + +if [ -z "$VERSION" ]; then + for file in /etc/{kos,anolis,system}-release; do + if [ -r "$file" ]; then + VERSION="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' "$file")" + break + fi + done +fi + +if [ -z "$VERSION" ]; then + echo >&2 "warning: cannot autodetect OS version, using '$PRODUCT' as VERSION" + version=$PRODUCT +fi +echo "PRODUCT: $PRODUCT VERSION: $VERSION" + +####################################################################################################### +CURDIR=$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd) +cd $CURDIR + +if [ -z "$PRODUCT" ] || [ -z "$VERSION" ] || [ -z "$RESULT_DIR" ] ;then + echo "Error: PRODUCT, VERSION, RESULT_DIR must be set!" + exit 1 +fi +if [ -z "$BASEOS_REPO" ] || [ -z "$APPSTREAM_REPO" ] ;then + echo "Error: BASEOS_REPO,APPSTREAM_REPO must be set!" + exit 1 +fi + +valid_char_for_pkg_group='^[a-zA-Z0-9 _\.\+\-]\+$' +if [ ! -z "$ADD_PACKAGES" ]; then + if echo "$ADD_PACKAGES" | grep "$valid_char_for_pkg_group"; then + echo "Info: ADD_PACKAGES style checked" + else + echo "Error: ADD_PACKAGES contains incorrect data" + exit 2 + fi +fi +if [ ! -z "$ADD_GROUPS" ]; then + if echo "$ADD_GROUPS" | grep "$valid_char_for_pkg_group"; then + echo "Info: ADD_GROUPS style checked" + else + echo "Error: ADD_GROUPS contains incorrect data" + exit 2 + fi +fi + +ADD_FILES=`echo "$ADD_FILES"|sed 's/ //g'` +valid_char_for_filetarget='^[a-zA-Z0-9 /_\.\+\-]\+$' +if [ ! -z "$ADD_FILES" ]; then + if echo "$ADD_FILES" | grep "$valid_char_for_filetarget"; then + if [ ! -e "$ADD_FILES" ];then + echo "Error: File to be added does not exist." + exit 3 + fi + ADD_FILES=$(readlink -f $ADD_FILES) + else + echo "Error: ADD_FILES contains incorrect data, and valid chars are: upper and lower case letters numbers / - _ + ." + exit 3 + fi +fi +ADD_FILES_TARGET=`echo "$ADD_FILES_TARGET"|sed 's/ //g'` +if [ ! -z "$ADD_FILES_TARGET" ]; then + if echo "$ADD_FILES_TARGET" | grep "$valid_char_for_filetarget"; then + echo " " + else + echo "Error: ADD_FILES_TARGET contains incorrect data, and valid chars are: upper and lower case letters numbers / - _ + ." + exit 4 + fi +fi +if [[ "$ADD_FILES_TARGET" != "" && "$ADD_FILES" == "" ]];then + echo "ADD_FILES must have value when ADD_FILES_TARGET has value" + exit 5 +fi +if [[ "$ADD_FILES" != "" && "$ADD_FILES_TARGET" == "" ]];then + echo "ADD_FILES_TARGET must have value when ADD_FILES has value, use /root by default." + ADD_FILES_TARGET="/" +fi + +################################ +function get_param() +{ + echo "Parsing input parameters ..." + ret=0 #0 success, else error + while [ -n "$1" ] + do + case "$1" in + -u|--uefi) + #echo "create qcow2 image that use UEFI boot mode." + UEFI_FLAG=true + shift 1 + ;; + -s|--image-disk-size) + #echo "set the qcow2 image size. Only for autopart" + if grep '^[[:digit:]]*$' <<< "$2" > /dev/null; then + DISK_SIZE_OF_IMAGE=$2 + else + echo "image disk size must be a number in megabytes." + return 1 + fi + shift 2 + ;; + -h|--help|*) + usage + ret=1 + break + ;; + *) + ret=1 + ;; + esac + done +return $ret +} +function usage() +{ +cat << EOF +Usage: +$0 [-u | --uefi] +$0 -h + +Options: +-h Print this help +-u | --uefi Create live ISO that use UEFI boot mode, and LEGACY BIOS will be used by default +-s | --image-disk-size Image disk size that is 4000 megabytes as default(when no -s or --image-disk-size) + +EOF +} +function uefi_firmware_check() +{ + #we can make uefi-image at legacy-machine,but can not make legacy-image at uefi-machine + if [ -d /sys/firmware/efi ]; then + echo "your machine is UEFI, so the image to be created is must be UEFI" + UEFI_FLAG=true + fi +} +get_param $* +ret_get_param=$? +if [ $ret_get_param -ne 0 ]; then + #echo "input params have some error, return" + exit 3 +fi +uefi_firmware_check + + +####################### +CUR_ARCH=`LANG=en_US.UTF-8 lscpu|grep "Architecture"|awk '{print $2}'` +KS_FILE="livemedia.ks" +PROJECT=$PRODUCT +PROJECT_ALL=$PRODUCT"-"$VERSION"-live" +PROJECT_ALL=`echo $PROJECT_ALL | sed 's/\./-/g'` + +###check needed tools +echo "check whether all needed rpms had been installed..." +if test -z "$(rpm -qa lorax)"; then + echo "Error: lorax has not been installed, exec iso-tools-setup.sh firstly please!" + exit 1 +fi +lorax_templates_name="lorax-templates-rhel" +if [ -f /etc/kos-release ]; then + lorax_templates_name="lorax-templates-anolis" +fi +if [ -f /etc/anolis-release ]; then + lorax_templates_name="lorax-templates-anolis" +fi +if test -z "$(rpm -qa $lorax_templates_name)"; then + echo "Error: $lorax_templates_name has not been installed, exec iso-tools-setup.sh firstly please!" + exit 1 +fi +if test -z "$(rpm -qa lorax-lmc-virt)"; then + echo "Error: lorax-lmc-virt has not been installed, exec iso-tools-setup.sh firstly please!" + exit 1 +fi +if test -z "$(rpm -qa isomd5sum)"; then + echo "Error: isomd5sum has not been installed, exec iso-tools-setup.sh firstly please!" + exit 1 +fi +if test -z "$(rpm -qa genisoimage)"; then + echo "Error: genisoimage has not been installed, exec iso-tools-setup.sh firstly please!" + exit 1 +fi +if [ $CUR_ARCH = "x86_64" ]; then + if test -z "$(rpm -qa syslinux)"; then + echo "Error: syslinux has not been installed, exec iso-tools-setup.sh firstly please!" + exit 1 + fi +fi + + +###### +ISO_NAME="" +if [ $CUR_ARCH = "x86_64" ]; then + BASEOS_REPO=`echo $BASEOS_REPO | sed 's/aarch64/x86_64/g'` + APPSTREAM_REPO=`echo $APPSTREAM_REPO | sed 's/aarch64/x86_64/g'` + + if [ $UEFI_FLAG = true ]; then + RESULT_DIR=$RESULT_DIR"/uefi" + ISO_NAME=$PROJECT_ALL"-"$CUR_ARCH"-uefi.iso" + sed -i "s/^#grub2-efi.*cdboot/grub2-efi-x64-cdboot/g" $KS_FILE + sed -i "s/^#shim.*/shim-x64/g" $KS_FILE + sed -i "s/^#syslinux/syslinux/g" $KS_FILE + sed -i "s/^#memtest86+/memtest86+/g" $KS_FILE + else + RESULT_DIR=$RESULT_DIR"/legacy" + ISO_NAME=$PROJECT_ALL"-"$CUR_ARCH"-legacy.iso" + sed -i "s/^grub2-efi.*cdboot/#grub2-efi-x64-cdboot/g" $KS_FILE + sed -i "s/^shim.*/#shim-x64/g" $KS_FILE + sed -i "s/^#syslinux/syslinux/g" $KS_FILE + sed -i "s/^#memtest86+/memtest86+/g" $KS_FILE + fi +elif [ $CUR_ARCH = "aarch64" ]; then + BASEOS_REPO=`echo $BASEOS_REPO | sed 's/x86_64/aarch64/g'` + APPSTREAM_REPO=`echo $APPSTREAM_REPO | sed 's/x86_64/aarch64/g'` + + if [ $UEFI_FLAG = true ]; then + RESULT_DIR=$RESULT_DIR"/uefi" + ISO_NAME=$PROJECT_ALL"-"$CUR_ARCH"-uefi.iso" + sed -i "s/^#grub2-efi.*cdboot/grub2-efi-aa64-cdboot/g" $KS_FILE + sed -i "s/^#shim.*/shim-aa64/g" $KS_FILE + sed -i "s/^syslinux/#syslinux/g" $KS_FILE + sed -i "s/^memtest86+/#memtest86+/g" $KS_FILE + else + RESULT_DIR=$RESULT_DIR"/legacy" + ISO_NAME=$PROJECT_ALL"-"$CUR_ARCH"-legacy.iso" + sed -i "s/^grub2-efi.*cdboot/#grub2-efi-aa64-cdboot/g" $KS_FILE + sed -i "s/^shim-aa64/#shim-aa64/g" $KS_FILE + sed -i "s/^#syslinux/syslinux/g" $KS_FILE + sed -i "s/^memtest86+/#memtest86+/g" $KS_FILE + fi +fi + +sed -i "s#^url --url=.*#url --url=\"$BASEOS_REPO\"#g" $KS_FILE +sed -i "s#^repo --name=appstream --baseurl=.*#repo --name=appstream --baseurl=\"$APPSTREAM_REPO\"#g" $KS_FILE +#add other repos +sed -i '/###add otherrepos start###/,/###add otherrepos end###/{/###add otherrepos start###/!{/###add otherrepos end###/!d}}' $KS_FILE +for ((i=5; i>0; --i)) +do + tmp="OTHER_REPO$i" + if [ -z "${!tmp}" ]; then + continue + fi + repostr="repo --name=${tmp} --baseurl='${!tmp}' " + sed -i "/###add otherrepos start###/a $repostr" $KS_FILE +done + + +#add pkgs && groups +sed -i '/###add packages start###/,/###add packages end###/{/###add packages start###/!{/###add packages end###/!d}}' $KS_FILE +if [ ! -z "$ADD_PACKAGES" ]; then + #del multi-space + ADD_PACKAGES=`echo $ADD_PACKAGES | sed 's/ \+/ /g'` + #del space at the begin or end of string + ADD_PACKAGES=`echo $ADD_PACKAGES | sed 's/^[ \\t]*//g' | sed 's/[ \\t]*$//g'` + #change space to \n + ADD_PACKAGES=`echo $ADD_PACKAGES | sed 's/ /\\\n/g'` + + + #echo "ADD_PACKAGES:$ADD_PACKAGES" + if [ ! -z "$ADD_PACKAGES" ]; then + sed -i "/###add packages start###/a $ADD_PACKAGES" $KS_FILE + fi +fi +if [ ! -z "$ADD_GROUPS" ]; then + #del multi-space + ADD_GROUPS=`echo $ADD_GROUPS | sed 's/ \+/ /g'` + #del space at the begin or end of string + ADD_GROUPS=`echo $ADD_GROUPS | sed 's/^[ \\t]*//g' | sed 's/[ \\t]*$//g'` + #change space to \n@ + ADD_GROUPS=`echo $ADD_GROUPS | sed 's/ /\\\n@/g'` + #add @ for first group + if [ ! -z "$ADD_GROUPS" ]; then + ADD_GROUPS="@""$ADD_GROUPS" + fi + + #echo "ADD_GROUPS:$ADD_GROUPS" + if [ ! -z "$ADD_GROUPS" ]; then + sed -i "/###add packages start###/a $ADD_GROUPS" $KS_FILE + fi +fi + +#disable Gtk for hanging if installed GTK/GUI +sed -i "s/initialized = Gtk.init_check.*/initialized = 0/g" /usr/lib64/python3.6/site-packages/pyanaconda/exception.py + +date_str=$(date "+%Y%m%d%H%M%S") +RESULT_DIR="$RESULT_DIR""/""$date_str" + +cmd="livemedia-creator --ks $KS_FILE --no-virt --resultdir $RESULT_DIR --project $PROJECT --make-iso --iso-only --iso-name $ISO_NAME --releasever $VERSION --volid $PROJECT_ALL --title $PROJECT_ALL --image-size-align=$DISK_SIZE_OF_IMAGE --nomacboot --keep-image " +echo "runcmd:"$cmd +eval $cmd +if [[ "$ADD_FILES_TARGET" != "" && -f $CURDIR/$RESULT_DIR/$ISO_NAME ]];then +#if [ "$ADD_FILES_TARGET" != "" ]; then + cd $RESULT_DIR + mkdir newiso oldiso + mount $ISO_NAME oldiso + cp -r oldiso/* newiso/ + rm -rf newiso/LiveOS/squashfs.img + unsquashfs -d tmp_squanshfs oldiso/LiveOS/squashfs.img + umount oldiso + mkdir tmp_rootfs + mount -rw tmp_squanshfs/LiveOS/rootfs.img tmp_rootfs + + if [ -e "tmp_rootfs/$ADD_FILES_TARGET" ];then + if [ ! -d "tmp_rootfs/$ADD_FILES_TARGET" ];then + echo "Error: ADD_FILES_TARGET[$ADD_FILES_TARGET] is not a directory in squashfs.img!" + umount tmp_rootfs + exit 10 + fi + else + echo "mkdir -p tmp_rootfs/$ADD_FILES_TARGET" + mkdir -p "tmp_rootfs/$ADD_FILES_TARGET" + fi + + echo "copy file into squanshfs.img" + echo "cp [$ADD_FILES] [$ADD_FILES_TARGET]" + cp -r $ADD_FILES tmp_rootfs/$ADD_FILES_TARGET + if [ $? != 0 ];then + echo "Error: copy file into squashfs.img failed!" + umount tmp_rootfs + exit 10 + fi + + + umount tmp_rootfs + mksquashfs tmp_squanshfs newiso/LiveOS/squashfs.img -comp xz #-Xbcj x86 + if [ $? != 0 ];then + echo "Error: mksquashfs failed!" + exit 10 + fi + + mv $ISO_NAME "$ISO_NAME""_old" + cd newiso + if [ $CUR_ARCH = "x86_64" ]; then + mkisofs -o ../$ISO_NAME -b isolinux/isolinux.bin -c isolinux/boot.cat -boot-load-size 4 -boot-info-table -no-emul-boot -R -J -V $PROJECT_ALL -T ./ + elif [ $CUR_ARCH = "aarch64" ]; then + mkisofs -o ../$ISO_NAME -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -R -J -V $PROJECT_ALL -T ./ + fi + cd .. + + if [ $CUR_ARCH = "x86_64" ]; then + isohybrid $ISO_NAME + fi + implantisomd5 $ISO_NAME +fi +if [ -f $CURDIR/$RESULT_DIR/$ISO_NAME ]; then + echo "Your LiveISO is : [$CURDIR/$RESULT_DIR/$ISO_NAME]" +fi diff --git a/livemedia.conf b/livemedia.conf new file mode 100644 index 0000000..2cab631 --- /dev/null +++ b/livemedia.conf @@ -0,0 +1,25 @@ +#! /bin/bash + +###################### +#Parameters that may need to be modified by the user +RESULT_DIR="livemedia" +BASEOS_REPO="http://mirrors.openanolis.cn/anolis/8.6/BaseOS/x86_64/os/" +#BASEOS_REPO="http://kos.ieisystem.com/kos/5.8/BaseOS/x86_64/os/" +APPSTREAM_REPO="http://mirrors.openanolis.cn/anolis/8.6/AppStream/x86_64/os/" +#APPSTREAM_REPO="http://kos.ieisystem.com/kos/5.8/AppStream/x86_64/os/" +OTHER_REPO1="" +OTHER_REPO2="" +OTHER_REPO3="" +OTHER_REPO4="" +OTHER_REPO5="" +UEFI_FLAG=false +DISK_SIZE_OF_IMAGE=51200 +#add pkgs to minimal install, split with ' ', e.g. "vim ssh" +#can select kernel-4.18.0 by :ADD_PACKAGES="bpftool-4.18.0 kernel-4.18.0 kernel-devel-4.18.0 kernel-headers-4.18.0 kernel-tools-4.18.0 perf-4.18.0 python3-perf-4.18.0 -bpftool-4.19.91 -kernel-4.19.91 -kernel-devel-4.19.91 -kernel-headers-4.19.91 -kernel-tools-4.19.91 -perf-4.19.91 -python3-perf-4.19.91 " +ADD_PACKAGES="" +#add group pkgs to minimal install, split with ' ', e.g. "gnome-desktop guest-desktop-agents" +ADD_GROUPS="" +#add file or directory into liveISO's squanshfs.img +ADD_FILES="" +ADD_FILES_TARGET="" + diff --git a/livemedia.ks b/livemedia.ks new file mode 100644 index 0000000..08b0904 --- /dev/null +++ b/livemedia.ks @@ -0,0 +1,428 @@ +# Live ISO Image +# NOTE: This example is for creating a live-iso, eg. +# livemedia-creator --project RHEL --releasever 8 --make-iso --ks=rhel-livemedia.ks --no-virt +# NOTE: This example does not include Anaconda and cannot be installed to a harddrive. + +# X Window System configuration information +xconfig --startxonboot +# Keyboard layouts +keyboard 'us' + +# System timezone +timezone US/Eastern +# System language +lang en_US.UTF-8 +# Firewall configuration +firewall --enabled --service=mdns +url --url="http://mirrors.openanolis.cn/anolis/8.6/BaseOS/x86_64/os/" +repo --name=appstream --baseurl="http://mirrors.openanolis.cn/anolis/8.6/AppStream/x86_64/os/" +###add otherrepos start### +###add otherrepos end### + +# Network information +network --bootproto=dhcp --device=link --activate + +# SELinux configuration +selinux --enforcing + +# System services +services --disabled="sshd" --enabled="NetworkManager" + +# livemedia-creator modifications. +shutdown +# System bootloader configuration +bootloader --location=none +# Clear blank disks or all existing partitions +clearpart --all --initlabel +rootpw rootme +# Disk partitioning information +autopart --type=lvm + +%post +# FIXME: it'd be better to get this installed from a package +cat > /etc/rc.d/init.d/livesys << EOF +#!/bin/bash +# +# live: Init script for live image +# +# chkconfig: 345 00 99 +# description: Init script for live image. +### BEGIN INIT INFO +# X-Start-Before: display-manager +### END INIT INFO + +. /etc/init.d/functions + +if ! strstr "\`cat /proc/cmdline\`" rd.live.image || [ "\$1" != "start" ]; then + exit 0 +fi + +if [ -e /.liveimg-configured ] ; then + configdone=1 +fi + +exists() { + which \$1 >/dev/null 2>&1 || return + \$* +} + +livedir="LiveOS" +for arg in \`cat /proc/cmdline\` ; do + if [ "\${arg##rd.live.dir=}" != "\${arg}" ]; then + livedir=\${arg##rd.live.dir=} + return + fi + if [ "\${arg##live_dir=}" != "\${arg}" ]; then + livedir=\${arg##live_dir=} + return + fi +done + +# enable swaps unless requested otherwise +swaps=\`blkid -t TYPE=swap -o device\` +if ! strstr "\`cat /proc/cmdline\`" noswap && [ -n "\$swaps" ] ; then + for s in \$swaps ; do + action "Enabling swap partition \$s" swapon \$s + done +fi +if ! strstr "\`cat /proc/cmdline\`" noswap && [ -f /run/initramfs/live/\${livedir}/swap.img ] ; then + action "Enabling swap file" swapon /run/initramfs/live/\${livedir}/swap.img +fi + +mountPersistentHome() { + # support label/uuid + if [ "\${homedev##LABEL=}" != "\${homedev}" -o "\${homedev##UUID=}" != "\${homedev}" ]; then + homedev=\`/sbin/blkid -o device -t "\$homedev"\` + fi + + # if we're given a file rather than a blockdev, loopback it + if [ "\${homedev##mtd}" != "\${homedev}" ]; then + # mtd devs don't have a block device but get magic-mounted with -t jffs2 + mountopts="-t jffs2" + elif [ ! -b "\$homedev" ]; then + loopdev=\`losetup -f\` + if [ "\${homedev##/run/initramfs/live}" != "\${homedev}" ]; then + action "Remounting live store r/w" mount -o remount,rw /run/initramfs/live + fi + losetup \$loopdev \$homedev + homedev=\$loopdev + fi + + # if it's encrypted, we need to unlock it + if [ "\$(/sbin/blkid -s TYPE -o value \$homedev 2>/dev/null)" = "crypto_LUKS" ]; then + echo + echo "Setting up encrypted /home device" + plymouth ask-for-password --command="cryptsetup luksOpen \$homedev EncHome" + homedev=/dev/mapper/EncHome + fi + + # and finally do the mount + mount \$mountopts \$homedev /home + # if we have /home under what's passed for persistent home, then + # we should make that the real /home. useful for mtd device on olpc + if [ -d /home/home ]; then mount --bind /home/home /home ; fi + [ -x /sbin/restorecon ] && /sbin/restorecon /home + if [ -d /home/liveuser ]; then USERADDARGS="-M" ; fi +} + +findPersistentHome() { + for arg in \`cat /proc/cmdline\` ; do + if [ "\${arg##persistenthome=}" != "\${arg}" ]; then + homedev=\${arg##persistenthome=} + return + fi + done +} + +if strstr "\`cat /proc/cmdline\`" persistenthome= ; then + findPersistentHome +elif [ -e /run/initramfs/live/\${livedir}/home.img ]; then + homedev=/run/initramfs/live/\${livedir}/home.img +fi + +# if we have a persistent /home, then we want to go ahead and mount it +if ! strstr "\`cat /proc/cmdline\`" nopersistenthome && [ -n "\$homedev" ] ; then + action "Mounting persistent /home" mountPersistentHome +fi + +if [ -n "\$configdone" ]; then + exit 0 +fi + +# add liveuser with no passwd +action "Adding live user" useradd \$USERADDARGS -c "Live System User" liveuser +passwd -d liveuser > /dev/null +usermod -aG wheel liveuser > /dev/null + +# Remove root password lock +passwd -d root > /dev/null + +# turn off firstboot for livecd boots +systemctl --no-reload disable firstboot-text.service 2> /dev/null || : +systemctl --no-reload disable firstboot-graphical.service 2> /dev/null || : +systemctl stop firstboot-text.service 2> /dev/null || : +systemctl stop firstboot-graphical.service 2> /dev/null || : + +# don't use prelink on a running live image +sed -i 's/PRELINKING=yes/PRELINKING=no/' /etc/sysconfig/prelink &>/dev/null || : + +# turn off mdmonitor by default +systemctl --no-reload disable mdmonitor.service 2> /dev/null || : +systemctl --no-reload disable mdmonitor-takeover.service 2> /dev/null || : +systemctl stop mdmonitor.service 2> /dev/null || : +systemctl stop mdmonitor-takeover.service 2> /dev/null || : + +# don't enable the gnome-settings-daemon packagekit plugin +gsettings set org.gnome.software download-updates 'false' || : + +# don't start cron/at as they tend to spawn things which are +# disk intensive that are painful on a live image +systemctl --no-reload disable crond.service 2> /dev/null || : +systemctl --no-reload disable atd.service 2> /dev/null || : +systemctl stop crond.service 2> /dev/null || : +systemctl stop atd.service 2> /dev/null || : + +# Don't sync the system clock when running live (RHBZ #1018162) +sed -i 's/rtcsync//' /etc/chrony.conf + +# Mark things as configured +touch /.liveimg-configured + +# add static hostname to work around xauth bug +# https://bugzilla.redhat.com/show_bug.cgi?id=679486 +echo "localhost" > /etc/hostname + +EOF + +# bah, hal starts way too late +cat > /etc/rc.d/init.d/livesys-late << EOF +#!/bin/bash +# +# live: Late init script for live image +# +# chkconfig: 345 99 01 +# description: Late init script for live image. + +. /etc/init.d/functions + +if ! strstr "\`cat /proc/cmdline\`" rd.live.image || [ "\$1" != "start" ] || [ -e /.liveimg-late-configured ] ; then + exit 0 +fi + +exists() { + which \$1 >/dev/null 2>&1 || return + \$* +} + +touch /.liveimg-late-configured + +# read some variables out of /proc/cmdline +for o in \`cat /proc/cmdline\` ; do + case \$o in + ks=*) + ks="--kickstart=\${o#ks=}" + ;; + xdriver=*) + xdriver="\${o#xdriver=}" + ;; + esac +done + +# if liveinst or textinst is given, start anaconda +if strstr "\`cat /proc/cmdline\`" liveinst ; then + plymouth --quit + /usr/sbin/liveinst \$ks +fi +if strstr "\`cat /proc/cmdline\`" textinst ; then + plymouth --quit + /usr/sbin/liveinst --text \$ks +fi + +# configure X, allowing user to override xdriver +if [ -n "\$xdriver" ]; then + cat > /etc/X11/xorg.conf.d/00-xdriver.conf <> /etc/fstab << EOF +vartmp /var/tmp tmpfs defaults 0 0 +EOF + +# work around for poor key import UI in PackageKit +rm -f /var/lib/rpm/__db* +releasever=$(rpm -q --qf '%{version}\n' --whatprovides system-release) +basearch=$(uname -i) +rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta +rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release +echo "Packages within this LiveCD" +rpm -qa +# Note that running rpm recreates the rpm db files which aren't needed or wanted +rm -f /var/lib/rpm/__db* + +# go ahead and pre-make the man -k cache (#455968) +/usr/bin/mandb + +# make sure there aren't core files lying around +rm -f /core* + +# convince readahead not to collect +# FIXME: for systemd + +echo 'File created by kickstart. See systemd-update-done.service(8).' \ + | tee /etc/.updated >/var/.updated + +# Remove random-seed +rm /var/lib/systemd/random-seed + +# Remove the rescue kernel and image to save space +# Installation will recreate these on the target +rm -f /boot/*-rescue* + +# Remove machine-id on pre generated images +rm -f /etc/machine-id +touch /etc/machine-id +%end + +%post + +cat >> /etc/rc.d/init.d/livesys << EOF + +# disable gnome-software automatically downloading updates +cat >> /usr/share/glib-2.0/schemas/org.gnome.software.gschema.override << FOE +[org.gnome.software] +download-updates=false +FOE + +# don't autostart gnome-software session service +rm -f /etc/xdg/autostart/gnome-software-service.desktop + +# disable the gnome-software shell search provider +cat >> /usr/share/gnome-shell/search-providers/org.gnome.Software-search-provider.ini << FOE +DefaultDisabled=true +FOE + +# don't run gnome-initial-setup +mkdir ~liveuser/.config +touch ~liveuser/.config/gnome-initial-setup-done + +# suppress anaconda spokes redundant with gnome-initial-setup +cat >> /etc/sysconfig/anaconda << FOE +[NetworkSpoke] +visited=1 + +[PasswordSpoke] +visited=1 + +[UserSpoke] +visited=1 +FOE + +# make the installer show up +if [ -f /usr/share/applications/liveinst.desktop ]; then + # Show harddisk install in shell dash + sed -i -e 's/NoDisplay=true/NoDisplay=false/' /usr/share/applications/liveinst.desktop "" + # need to move it to anaconda.desktop to make shell happy + mv /usr/share/applications/liveinst.desktop /usr/share/applications/anaconda.desktop + + cat >> /usr/share/glib-2.0/schemas/org.gnome.shell.gschema.override << FOE +[org.gnome.shell] +#favorite-apps=['firefox.desktop', 'evolution.desktop', 'rhythmbox.desktop', 'shotwell.desktop', 'org.gnome.Nautilus.desktop', 'anaconda.desktop'] +favorite-apps=['evolution.desktop', 'rhythmbox.desktop', 'shotwell.desktop', 'org.gnome.Nautilus.desktop', 'anaconda.desktop'] +FOE + + # Make the welcome screen show up + if [ -f /usr/share/anaconda/gnome/rhel-welcome.desktop ]; then + mkdir -p ~liveuser/.config/autostart + cp /usr/share/anaconda/gnome/rhel-welcome.desktop /usr/share/applications/ + cp /usr/share/anaconda/gnome/rhel-welcome.desktop ~liveuser/.config/autostart/ + fi + + # Copy Anaconda branding in place + if [ -d /usr/share/lorax/product/usr/share/anaconda ]; then + cp -a /usr/share/lorax/product/* / + fi +fi + +# rebuild schema cache with any overrides we installed +glib-compile-schemas /usr/share/glib-2.0/schemas + +# set up auto-login +cat > /etc/gdm/custom.conf << FOE +[daemon] +AutomaticLoginEnable=True +AutomaticLogin=liveuser +FOE + +# Turn off PackageKit-command-not-found while uninstalled +if [ -f /etc/PackageKit/CommandNotFound.conf ]; then + sed -i -e 's/^SoftwareSourceSearch=true/SoftwareSourceSearch=false/' /etc/PackageKit/CommandNotFound.conf +fi + +# make sure to set the right permissions and selinux contexts +chown -R liveuser:liveuser /home/liveuser/ +restorecon -R /home/liveuser/ + +EOF + +%end + +%packages +####standard#### +@base-x +@fonts +@guest-desktop-agents +@hardware-support +@multimedia +@networkmanager-submodules +@workstation-product +@gnome-desktop +#firefox +gnome-terminal +aajohan-comfortaa-fonts +#####minimal##### +#@^minimal-environment +#kexec-tools +#inspur-logos +################# +dracut-config-generic +dracut-live +glibc-all-langpacks +grub2-efi +grub2-pc-modules +kernel +# Make sure that DNF doesn't pull in debug kernel to satisfy kmod() requires +kernel-modules +kernel-modules-extra +memtest86+ +syslinux +#grub2-efi-x64-cdboot +#shim-x64 +-@dial-up +-@input-methods +-gfs2-utils +-dracut-config-rescue + +###add packages start### +###add packages end### + +%end -- Gitee