live-sdk

simple distro kit (livecd edition)
git clone git://parazyd.org/live-sdk.git
Log | Files | Refs | Submodules | README | LICENSE

devuan-desktop-live.blend (9560B)


      1 #!/usr/bin/env zsh
      2 # Copyright (c) 2017 Dyne.org Foundation
      3 # live-sdk is written and maintained by Ivan J. <parazyd@dyne.org>
      4 #
      5 # This file is part of live-sdk
      6 # devuan-desktop-live.blend is maintained by fsmithred
      7 #
      8 # This source code is free software: you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation, either version 3 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This software is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this source code. If not, see <http://www.gnu.org/licenses/>.
     20 
     21 BLENDPATH="${BLENDPATH:-$(dirname $0)}"
     22 
     23 source $BLENDPATH/config
     24 
     25 blend_release_path=$BLENDPATH/$release/
     26 blend_scripts=${blend_release_path}/scripts
     27 
     28 blend_preinst() {
     29 	fn blend_preinst
     30 	req=(blend_name username userpass)
     31 	ckreq || return 1
     32 
     33 	notice "executing $blend_name preinst"
     34 
     35 	add-user $username $userpass
     36 
     37 	notice "copying blend-specific debs"
     38 	cp -fv "$blend_release_path"/*.deb "$R/extra/custom-packages"
     39 }
     40 
     41 blend_postinst() {
     42 	fn blend_postinst
     43 	req=(strapdir blend_name)
     44 	ckreq || return 1
     45 
     46 	notice "executing $blend_name postinst"
     47 
     48 	[[ $mkefi = yes ]] && {
     49 		iso_make_efi
     50 		iso_write_grub_cfg
     51 	}
     52 
     53 	install-custdebs || zerr
     54 	pushd "$strapdir"
     55 		sudo rsync -avx --no-o --no-g "$blend_release_path"/rootfs-overlay/* . || zerr
     56 	popd
     57 
     58 	blend_finalize || zerr
     59 }
     60 
     61 iso_write_isolinux_cfg() {
     62 	fn iso_write_isolinux_cfg "(override)"
     63 	req=(workdir arch username)
     64 	ckreq || return 1
     65 
     66 	notice "writing isolinux configuration"
     67 
     68 	cat <<EOF | sudo tee ${workdir}/binary/isolinux/isolinux.cfg >/dev/null
     69 ui vesamenu.c32
     70 prompt 0
     71 menu title devuan-live boot menu
     72 timeout 70
     73 menu background /isolinux/splash.png
     74 menu color title	* #FFFFFFFF *
     75 menu color border	* #00000000 #00000000 none
     76 menu color sel         * #ffffff #44424E *
     77 menu color hotsel      1;7;37;40 #dad9dc #44424E *
     78 menu color tabmsg	* #dad9dc #00000000 *
     79 menu color cmdline 0 #dad9dc #00000000
     80 menu tabmsg Press ENTER to boot or TAB to edit a menu entry
     81 menu vshift 12
     82 menu rows 12
     83 
     84 label live
     85 	menu label ${os}-live (${arch})
     86 	menu default
     87 	linux /live/vmlinuz
     88 	append initrd=/live/initrd.img boot=live username=${username} 
     89 
     90 label lang
     91 	menu label Other language (TAB to edit)
     92 	linux /live/vmlinuz
     93 	append initrd=/live/initrd.img boot=live username=${username} locales=it_IT.UTF-8 keyboard-layouts=it 
     94 
     95 label toram
     96 	menu label ${os}-live (${arch}) (load to RAM)
     97 	linux /live/vmlinuz
     98 	append initrd=/live/initrd.img boot=live username=${username} toram 
     99 
    100 label failsafe
    101 	menu label ${os}-live (${arch}) (failsafe)
    102 	kernel /live/vmlinuz noapic noapm nodma nomce nolapic nosmp nomodeset vga=normal 
    103 	append initrd=/live/initrd.img boot=live
    104 
    105 label memtest
    106 	menu label Memory test
    107 	kernel /live/memtest
    108 
    109 endtext
    110 EOF
    111 
    112 	notice "copying isolinux overlay"
    113 	sudo mkdir -p "$workdir"/binary/{live,isolinux}
    114 	sudo cp -rav "$blend_release_path"/isolinux-overlay/* "$workdir"/binary/isolinux/
    115 #	[[ -n "$hookscripts" ]] && {
    116 #		sudo cp -av "$blend_release_path"/hooks "$workdir"/binary/live/
    117 #	}
    118 }
    119 
    120 # create /boot and /efi for uefi.
    121 # uefi code borrowed and adapted from David Hare, who borrowed and adapted it
    122 # from similar scripts by Colin Watson and Patrick J. Volkerding.
    123 iso_make_efi() {
    124 	fn iso_make_efi
    125 	req=(workdir efi_work)
    126 	ckreq || return 1
    127 
    128 	notice "creating efi boot files"
    129 
    130 	tempdir="$(mktemp -d /tmp/work_temp.XXXX)"
    131 	# for initial grub.cfg
    132 	mkdir -p "$tempdir"/boot/grub
    133 
    134 	if [ "$arch" = amd64 ] ; then
    135 		grubarch="x86_64-efi"
    136 	elif [ "$arch" = i386 ] ; then
    137 		grubarch="i386-efi"
    138 	fi
    139 
    140 	cat >"$tempdir"/boot/grub/grub.cfg <<EOF
    141 search --file --set=root /isolinux/isolinux.cfg
    142 set prefix=(\$root)/boot/grub
    143 source \$prefix/${grubarch}/grub.cfg
    144 EOF
    145 
    146 	mkdir -p "$efi_work"
    147 	pushd "$efi_work"
    148 
    149 	# start with empty directories.
    150 	rm -rf boot; mkdir -p boot/grub/${grubarch}
    151 	rm -rf efi ; mkdir -p efi/boot
    152 
    153 	# second grub.cfg file
    154 	for i in $(find $strapdir/usr/lib/grub/${grubarch} -name 'part_*.mod'); do
    155 		print "insmod $(basename $i)" >> boot/grub/${grubarch}/grub.cfg
    156 	done
    157 
    158 	# Additional modules so we don't boot in blind mode.
    159 	# I don't know which ones are really needed.
    160 	efimods=(
    161 		efi_gop
    162 		efi_uga
    163 		ieee1275_fb
    164 		vbe
    165 		vga
    166 		video_bochs
    167 		video_cirrus
    168 		jpeg
    169 		png
    170 		gfxterm
    171 	)
    172 	for i in $efimods; do
    173 		print "insmod $i" >> boot/grub/${grubarch}/grub.cfg
    174 	done
    175 
    176 	print "source /boot/grub/grub.cfg" >> boot/grub/${grubarch}/grub.cfg
    177 
    178 	pushd "$tempdir"
    179 		# make a tarred "memdisk" to embed in the grub image
    180 		tar -cvf memdisk boot
    181 
    182 		# make the grub images
    183 		grub-mkimage -O "x86_64-efi" -m "memdisk" -o "bootx64.efi" \
    184 			-p '(memdisk)/boot/grub' \
    185 				search iso9660 configfile normal memdisk tar cat \
    186 				part_msdos part_gpt fat ext2 ntfs ntfscomp hfsplus \
    187 				chain boot linux
    188 		grub-mkimage -O "i386-efi" -m "memdisk" -o "bootia32.efi" \
    189 			-p '(memdisk)/boot/grub' \
    190 				search iso9660 configfile normal memdisk tar cat \
    191 				part_msdos part_gpt fat ext2 ntfs ntfscomp hfsplus \
    192 				chain boot linux
    193 	popd
    194 
    195 	# copy the grub image to efi/boot (to go later in the device's root)
    196 	cp "$tempdir"/bootx64.efi efi/boot
    197 	cp "$tempdir"/bootia32.efi efi/boot
    198 
    199 	# Do the boot image "boot/grub/efiboot.img"
    200 	dd if=/dev/zero of=boot/grub/efiboot.img bs=1K count=1440
    201 	mkfs.vfat -F 12 boot/grub/efiboot.img
    202 
    203 	sudo mkdir img-mnt
    204 	sudo mount -o loop boot/grub/efiboot.img img-mnt
    205 	sudo mkdir -p img-mnt/efi/boot
    206 	sudo cp "$tempdir"/bootx64.efi img-mnt/efi/boot/
    207 	sudo cp "$tempdir"/bootia32.efi img-mnt/efi/boot/
    208 
    209 	# copy modules and font
    210 	cp $strapdir/usr/lib/grub/${grubarch}/* boot/grub/${grubarch}/
    211 
    212 	# if this doesn't work try another font from the same place (grub's default, unicode.pf2, is much larger)
    213 	# Either of these will work, and they look the same to me. Unicode seems to work with qemu. -fsr
    214 	# cp /usr/share/grub/ascii.pf2 boot/grub/font.pf2
    215 	cp $strapdir/usr/share/grub/unicode.pf2 boot/grub/font.pf2
    216 
    217 	# copy splash
    218 	sudo cp -rav "$blend_release_path"/isolinux-overlay/splash.png boot/grub/splash.png
    219 
    220 	# Cleanup efi temps
    221 	sudo umount img-mnt
    222 	sudo rmdir img-mnt
    223 	rm -rf "$tempdir"
    224 
    225 	popd
    226 
    227 
    228 	# Copy efi files to iso
    229 	pushd $workdir
    230 	sudo rsync -avx "$efi_work"/boot binary/
    231 	sudo rsync -avx "$efi_work"/efi  binary/
    232 	popd
    233 
    234 }
    235 
    236 
    237 iso_write_grub_cfg() {
    238 	fn iso_write_grub_cfg "(override)"
    239 	req=(workdir arch username)
    240 	ckreq || return 1
    241 
    242 	notice "writing grub configuration"
    243 
    244 	# Do the main grub.cfg (which gets loaded last):
    245 	cat <<EOF | sudo tee ${workdir}/binary/boot/grub/grub.cfg
    246 if loadfont $prefix/font.pf2 ; then
    247   set gfxmode=640x480
    248   insmod efi_gop
    249   insmod efi_uga
    250   insmod video_bochs
    251   insmod video_cirrus
    252   insmod gfxterm
    253   insmod jpeg
    254   insmod png
    255   terminal_output gfxterm
    256 fi
    257 
    258 background_image /boot/grub/splash.png
    259 set menu_color_normal=white/black
    260 set menu_color_highlight=dark-gray/white
    261 set timeout=6
    262 
    263 menuentry "${os}-live (${arch})" {
    264     set gfxpayload=keep
    265     linux   /live/vmlinuz boot=live username=$username 
    266     initrd  /live/initrd.img
    267 }
    268 
    269 menuentry "Other language" {
    270 	set gfxpayload=keep
    271 	linux /live/vmlinuz boot=live username=$username locales=it_IT.UTF-8 keyboard-layouts=it 
    272 	initrd /live/initrd.img
    273 }
    274 
    275 menuentry "${os}-live (load to RAM)" {
    276     set gfxpayload=keep
    277     linux   /live/vmlinuz boot=live username=$username toram 
    278     initrd  /live/initrd.img
    279 }
    280 
    281 menuentry "${os}-live (failsafe)" {
    282     set gfxpayload=keep
    283     linux   /live/vmlinuz boot=live username=$username noapic noapm nodma nomce nolapic nosmp vga=normal 
    284     initrd  /live/initrd.img
    285 }
    286 
    287 menuentry "Memory test" {
    288 	linux /live/memtest
    289 }
    290 
    291 EOF
    292 }
    293 
    294 blend_finalize() {
    295 	fn blend_finalize
    296 	req=(strapdir username default_shell)
    297 	ckreq || return 1
    298 
    299 	cat <<EOF | sudo tee ${strapdir}/finalize >/dev/null
    300 #!/bin/sh
    301 
    302 ## permissions
    303 for i in cdrom floppy audio dip video plugdev netdev lpadmin scanner; do
    304 	gpasswd -a ${username} \$i
    305 done
    306 
    307 chsh -s "${default_shell}" ${username}
    308 chown -R 1000:1000 /home/${username}
    309 #cp /home/${username}/Desktop/refractainstaller.desktop /usr/share/applications/
    310 chmod +x /home/${username}/Desktop/refractainstaller.desktop
    311 
    312 # This can go away when desktop-base is fixed to do the grub theme. (SEEMS TO BE FIXED-no it's not.)
    313 grep -q GRUB_THEME /etc/default/grub || {
    314 	printf "\nGRUB_THEME=/usr/share/desktop-base/grub-themes/desktop-grub-theme/theme.txt\n" >> /etc/default/grub
    315 }
    316 
    317 # This needs to stay
    318 cp /splash.png /usr/lib/refractasnapshot/iso/isolinux/
    319 rm -f /splash.png
    320 
    321 # This has been fixed (in devuan-baseconf) in suites/ascii
    322 #rm -rf /data
    323 
    324 rm -f /etc/fstab
    325 rm -f /etc/popularity-contest.conf
    326 
    327 # For ascii if no display manager is used. Maybe this should have a
    328 # contitional that's turned on/off in the config?
    329 # echo "needs_root_rights=yes" >> /etc/X11/Xwrapper.config
    330 
    331 # Disable contrib and non-free after installing firmware.
    332 sed -i 's/contrib//g' /etc/apt/sources.list
    333 sed -i 's/non-free//g' /etc/apt/sources.list
    334 
    335 ## package list - Why does this make an empty file?
    336 #dpkg -l | awk '/^ii/ { print $2 " " $3 }' > /home/${username}/package_list
    337 #printf "\nGo to files.devuan.org\n" >> /home/${username}/package_list
    338 
    339 # Enable encryption (e.g. for live-usb with persistence)
    340 #sed -i 's/#CRYPTSETUP=/CRYPTSETUP=y/' /etc/cryptsetup-initramfs/conf-hook
    341 CRYPTSETUP=y update-initramfs -u -k all
    342 
    343 apt-get update
    344 apt-get clean
    345 updatedb
    346 EOF
    347 	chroot-script -d finalize || zerr
    348 }