2014-12-08 23:50:56 +01:00
#!/bin/bash
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
2015-01-28 21:05:18 +01:00
[ [ -r ${ LIBDIR } /util-iso-image.sh ] ] && source ${ LIBDIR } /util-iso-image.sh
2015-03-04 00:40:44 +01:00
[ [ -r ${ LIBDIR } /util-iso-boot.sh ] ] && source ${ LIBDIR } /util-iso-boot.sh
2015-01-29 05:16:15 +01:00
[ [ -r ${ LIBDIR } /util-iso-calamares.sh ] ] && source ${ LIBDIR } /util-iso-calamares.sh
2015-02-09 20:34:37 +01:00
check_run_dir( ) {
2015-03-02 23:35:15 +01:00
if [ [ ! -f shared/Packages-Systemd ] ] || [ [ ! -f shared/Packages-Openrc ] ] ; then
2015-02-13 15:17:00 +01:00
die " ${ 0 ##*/ } is not run in a valid iso-profiles folder! "
fi
2015-02-09 20:34:37 +01:00
}
2014-12-19 04:29:18 +01:00
copy_overlay_root( ) {
2015-02-13 15:17:00 +01:00
msg2 "Copying overlay ..."
cp -a --no-preserve= ownership overlay/* $1
2014-12-12 05:18:17 +01:00
}
2015-01-29 05:16:15 +01:00
copy_overlay_custom( ) {
2015-02-13 15:17:00 +01:00
msg2 " Copying ${ custom } -overlay ... "
cp -a --no-preserve= ownership ${ custom } -overlay/* ${ work_dir } /${ custom } -image
2014-12-12 05:18:17 +01:00
}
2014-12-12 17:36:29 +01:00
copy_overlay_livecd( ) {
2014-12-16 05:29:46 +01:00
msg2 "Copying overlay-livecd ..."
2014-12-21 01:42:17 +01:00
if [ [ -L overlay-livecd ] ] ; then
2015-02-13 15:17:00 +01:00
cp -a --no-preserve= ownership overlay-livecd/* $1
2014-12-20 23:21:26 +01:00
else
2015-02-13 15:17:00 +01:00
msg2 "Copying custom overlay-livecd ..."
cp -LR overlay-livecd/* $1
2014-12-20 23:21:26 +01:00
fi
2014-12-12 17:36:29 +01:00
}
2014-12-19 04:29:18 +01:00
copy_startup_scripts( ) {
2015-02-13 15:17:00 +01:00
msg2 "Copying startup scripts ..."
cp ${ PKGDATADIR } /scripts/livecd $1
cp ${ PKGDATADIR } /scripts/mhwd-live $1
chmod +x $1 /livecd
chmod +x $1 /mhwd-live
2014-12-12 17:36:29 +01:00
}
2015-03-03 02:38:31 +01:00
write_profile_conf_entries( ) {
local conf = $1 /profile.conf
echo '' >> ${ conf }
echo '# custom image name' >> ${ conf }
echo " custom= ${ custom } " >> ${ conf }
echo '' >> ${ conf }
2015-03-05 10:54:09 +01:00
echo '# iso_name' >> ${ conf }
echo " iso_name= ${ iso_name } " >> ${ conf }
2015-03-03 02:38:31 +01:00
}
2014-12-14 04:27:24 +01:00
copy_livecd_helpers( ) {
2015-02-13 15:17:00 +01:00
msg2 "Copying livecd helpers ..."
[ [ ! -d $1 ] ] && mkdir -p $1
cp ${ LIBDIR } /util-livecd.sh $1
cp ${ LIBDIR } /util-msg.sh $1
cp ${ LIBDIR } /util.sh $1
2015-02-26 20:36:36 +01:00
cp ${ PKGDATADIR } /scripts/kbd-model-map $1
2015-03-01 21:24:53 +01:00
2015-03-02 23:35:15 +01:00
cp ${ profile_conf } $1
2015-03-03 02:38:31 +01:00
write_profile_conf_entries $1
2014-12-11 03:54:02 +01:00
}
2014-12-14 07:10:36 +01:00
copy_cache_lng( ) {
2015-02-13 15:17:00 +01:00
msg2 "Copying lng cache ..."
cp ${ cache_dir_lng } /* ${ work_dir } /lng-image/opt/livecd/lng
2015-05-02 09:33:13 +02:00
msg2 "Trimming lng pkgs ..."
paccache -rv -k1 -c ${ work_dir } /lng-image/opt/livecd/lng
2014-12-14 07:10:36 +01:00
}
2015-01-14 23:14:44 +01:00
copy_cache_xorg( ) {
2015-02-13 15:17:00 +01:00
msg2 "Copying xorg pkgs cache ..."
cp ${ cache_dir_xorg } /* ${ work_dir } /pkgs-image/opt/livecd/pkgs
2015-05-02 09:33:13 +02:00
msg2 "Trimming xorg pkgs ..."
paccache -rv -k1 -c ${ work_dir } /pkgs-image/opt/livecd/pkgs
2014-12-14 07:10:36 +01:00
}
2015-01-15 02:49:21 +01:00
prepare_cachedirs( ) {
2015-02-16 19:07:19 +01:00
prepare_dir " ${ cache_dir_iso } "
prepare_dir " ${ cache_dir_xorg } "
prepare_dir " ${ cache_dir_lng } "
2014-12-14 07:10:36 +01:00
}
2014-12-18 05:07:04 +01:00
clean_cache( ) {
2015-02-23 19:33:11 +01:00
msg2 " Cleaning [ $1 ] ... "
2014-12-18 05:07:04 +01:00
find " $1 " -name '*.pkg.tar.xz' -delete & >/dev/null
2014-12-08 23:50:56 +01:00
}
2015-02-14 10:50:41 +01:00
clean_chroots( ) {
2015-02-23 19:33:11 +01:00
msg "Cleaning up ..."
2015-02-14 10:50:41 +01:00
for image in " $1 " /*-image; do
[ [ -d ${ image } ] ] || continue
if [ [ $( basename " ${ image } " ) != "pkgs-image" ] ] || \
[ [ $( basename " ${ image } " ) != "lng-image" ] ] ; then
2015-02-23 19:33:11 +01:00
msg2 " Deleting chroot ' $( basename " ${ image } " ) '... "
lock 9 " ${ image } .lock " " Locking chroot ' ${ image } ' "
2015-02-14 10:50:41 +01:00
if [ [ " $( stat -f -c %T " ${ image } " ) " = = btrfs ] ] ; then
{ type -P btrfs && btrfs subvolume delete " ${ image } " ; } & >/dev/null
fi
rm -rf --one-file-system " ${ image } "
fi
done
exec 9>& -
rm -rf --one-file-system " $1 "
2014-12-08 23:50:56 +01:00
}
2015-01-29 05:16:15 +01:00
configure_custom_image( ) {
2015-02-13 15:17:00 +01:00
msg " Configuring [ ${ custom } -image] "
configure_plymouth " $1 "
configure_displaymanager " $1 "
configure_services " $1 "
2015-03-11 15:02:54 +01:00
configure_environment " $1 "
2015-02-13 15:17:00 +01:00
msg " Done configuring [ ${ custom } -image] "
2015-01-16 13:52:35 +01:00
}
2014-12-19 16:18:35 +01:00
configure_livecd_image( ) {
2015-02-13 15:17:00 +01:00
msg "Configuring [livecd-image]"
configure_hostname " $1 "
configure_hosts " $1 "
configure_accountsservice " $1 " " ${ username } "
configure_user " $1 "
configure_services_live " $1 "
configure_calamares " $1 "
configure_thus " $1 "
2015-03-01 17:24:27 +01:00
configure_cli " $1 "
2015-02-13 15:17:00 +01:00
msg "Done configuring [livecd-image]"
2014-12-18 04:30:19 +01:00
}
2014-12-12 05:18:17 +01:00
make_repo( ) {
2015-02-13 15:17:00 +01:00
repo-add ${ work_dir } /pkgs-image/opt/livecd/pkgs/gfx-pkgs.db.tar.gz ${ work_dir } /pkgs-image/opt/livecd/pkgs/*pkg*z
2014-12-12 05:18:17 +01:00
}
2014-12-15 23:12:04 +01:00
# $1: work dir
# $2: cache dir
# $3: pkglist
download_to_cache( ) {
2015-02-13 15:17:00 +01:00
pacman -v --config " ${ pacman_conf } " \
--arch " ${ arch } " --root " $1 " \
--cache $2 -Syw $3 --noconfirm
2014-12-15 23:12:04 +01:00
}
2014-12-08 23:50:56 +01:00
# Build ISO
make_iso( ) {
2015-02-13 15:17:00 +01:00
msg "Start [Build ISO]"
touch " ${ work_dir } /iso/.miso "
2015-02-19 01:14:20 +01:00
mkiso ${ iso_args [*] } iso " ${ work_dir } " " ${ cache_dir_iso } / ${ iso_file } " || mkiso_error_handler
2015-02-13 15:17:00 +01:00
chown -R " ${ OWNER } :users " " ${ cache_dir_iso } "
msg "Done [Build ISO]"
2014-12-12 05:18:17 +01:00
}
2015-01-26 21:48:37 +01:00
# $1: file
2015-01-29 00:17:15 +01:00
make_checksum( ) {
2015-02-13 15:17:00 +01:00
cd ${ cache_dir_iso }
2015-03-05 10:54:09 +01:00
msg " Creating [ ${ iso_checksum } sum] ... "
local cs = $( ${ iso_checksum } sum $1 )
msg2 " ${ iso_checksum } sum: ${ cs } "
echo " ${ cs } " > $1 .${ iso_checksum }
msg " Done [ ${ iso_checksum } sum] "
2015-02-13 15:17:00 +01:00
cd ..
2015-01-26 21:48:37 +01:00
}
2015-01-09 16:23:46 +01:00
# $1: new branch
aufs_mount_root_image( ) {
2015-02-13 15:17:00 +01:00
msg2 " mount [root-image] on [ ${ 1 ##*/ } ] "
mount -t aufs -o br = " $1 " :${ work_dir } /root-image= ro none " $1 "
2015-01-09 16:23:46 +01:00
}
# $1: add branch
2015-01-20 20:47:39 +01:00
aufs_append_root_image( ) {
2015-02-13 15:17:00 +01:00
msg2 " append [root-image] on [ ${ 1 ##*/ } ] "
mount -t aufs -o remount,append:${ work_dir } /root-image= ro none " $1 "
2015-01-20 20:47:39 +01:00
}
# $1: add branch
2015-01-29 18:37:25 +01:00
aufs_mount_custom_image( ) {
2015-02-13 15:17:00 +01:00
msg2 " mount [ ${ 1 ##*/ } ] on [ ${ custom } -image] "
mount -t aufs -o br = " $1 " :${ work_dir } /${ custom } -image= ro none " $1 "
2015-01-09 16:23:46 +01:00
}
2015-01-09 22:45:32 +01:00
# $1: del branch
aufs_remove_image( ) {
2015-02-13 15:17:00 +01:00
if mountpoint -q " $1 " ; then
msg2 " unmount ${ 1 ##*/ } "
umount $1
fi
2015-01-09 22:45:32 +01:00
}
2015-01-26 02:09:18 +01:00
umount_image_handler( ) {
2015-02-13 15:17:00 +01:00
aufs_remove_image " ${ work_dir } /livecd-image "
aufs_remove_image " ${ work_dir } / ${ custom } -image "
aufs_remove_image " ${ work_dir } /root-image "
aufs_remove_image " ${ work_dir } /pkgs-image "
aufs_remove_image " ${ work_dir } /lng-image "
aufs_remove_image " ${ work_dir } /boot-image "
2015-01-26 02:09:18 +01:00
}
2015-01-26 22:54:49 +01:00
mkiso_error_handler( ) {
2015-02-13 15:17:00 +01:00
umount_image_handler
die "Exiting..."
2015-01-26 22:54:49 +01:00
}
2014-12-08 23:50:56 +01:00
# Base installation (root-image)
2015-01-13 04:48:04 +01:00
make_image_root( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
msg "Prepare [Base installation] (root-image)"
local path = " ${ work_dir } /root-image "
mkiso ${ create_args [*] } -p " ${ packages } " -i "root-image" create " ${ work_dir } " || mkiso_error_handler
pacman -Qr " ${ path } " > " ${ path } /root-image-pkgs.txt "
2015-02-19 16:57:35 +01:00
configure_lsb " ${ path } "
2015-02-13 15:17:00 +01:00
copy_overlay_root " ${ path } "
: > ${ work_dir } /build.${ FUNCNAME }
msg "Done [Base installation] (root-image)"
2014-12-08 23:50:56 +01:00
fi
2014-12-10 19:06:52 +01:00
}
2015-01-29 05:16:15 +01:00
make_image_custom( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
msg " Prepare [ ${ custom } installation] ( ${ custom } -image) "
local path = " ${ work_dir } / ${ custom } -image "
mkdir -p ${ path }
umount_image_handler
aufs_mount_root_image " ${ path } "
mkiso ${ create_args [*] } -i " ${ custom } -image " -p " ${ packages } " create " ${ work_dir } " || mkiso_error_handler
pacman -Qr " ${ path } " > " ${ path } / ${ custom } -image-pkgs.txt "
2015-03-05 10:54:09 +01:00
cp " ${ path } / ${ custom } -image-pkgs.txt " ${ cache_dir_iso } /${ iso_name } -${ custom } -${ dist_release } -${ arch } -pkgs.txt
2015-02-13 15:17:00 +01:00
[ [ -d ${ custom } -overlay ] ] && copy_overlay_custom
configure_custom_image " ${ path } "
umount_image_handler
2015-03-18 11:39:21 +01:00
find ${ path } -name '.wh.*' -delete & >/dev/null
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
msg " Done [ ${ custom } installation] ( ${ custom } -image) "
fi
2014-12-08 23:50:56 +01:00
}
2015-01-13 04:48:04 +01:00
make_image_livecd( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
msg "Prepare [livecd-image]"
local path = " ${ work_dir } /livecd-image "
mkdir -p ${ path }
umount_image_handler
if [ [ -n " ${ custom } " ] ] ; then
aufs_mount_custom_image " ${ path } "
aufs_append_root_image " ${ path } "
else
aufs_mount_root_image " ${ path } "
fi
mkiso ${ create_args [*] } -i "livecd-image" -p " ${ packages } " create " ${ work_dir } " || mkiso_error_handler
pacman -Qr " ${ path } " > " ${ path } /livecd-image-pkgs.txt "
copy_overlay_livecd " ${ path } "
# copy over setup helpers and config loader
copy_livecd_helpers " ${ path } /opt/livecd "
copy_startup_scripts " ${ path } /usr/bin "
configure_livecd_image " ${ path } "
# Clean up GnuPG keys?
rm -rf " ${ path } /etc/pacman.d/gnupg "
umount_image_handler
2015-03-18 11:39:21 +01:00
find ${ path } -name '.wh.*' -delete & >/dev/null
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
msg "Done [livecd-image]"
2014-12-08 23:50:56 +01:00
fi
2014-12-15 23:12:04 +01:00
}
2015-01-13 04:48:04 +01:00
make_image_xorg( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
msg "Prepare [pkgs-image]"
local path = " ${ work_dir } /pkgs-image "
mkdir -p ${ path } /opt/livecd/pkgs
umount_image_handler
if [ [ -n " ${ custom } " ] ] ; then
aufs_mount_custom_image " ${ path } "
aufs_append_root_image " ${ path } "
else
aufs_mount_root_image " ${ path } "
fi
download_to_cache " ${ path } " " ${ cache_dir_xorg } " " ${ packages_xorg } "
copy_cache_xorg
if [ [ -n " ${ packages_xorg_cleanup } " ] ] ; then
for xorg_clean in ${ packages_xorg_cleanup } ; do
rm ${ path } /opt/livecd/pkgs/${ xorg_clean }
done
fi
cp ${ PKGDATADIR } /pacman-gfx.conf ${ path } /opt/livecd
rm -r ${ path } /var
make_repo " ${ path } /opt/livecd/pkgs/gfx-pkgs " " ${ path } /opt/livecd/pkgs "
configure_xorg_drivers " ${ path } "
umount_image_handler
2015-03-18 11:39:21 +01:00
find ${ path } -name '.wh.*' -delete & >/dev/null
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
msg "Done [pkgs-image]"
2014-12-11 07:36:41 +01:00
fi
2014-12-08 23:50:56 +01:00
}
2015-01-13 04:48:04 +01:00
make_image_lng( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
msg "Prepare [lng-image]"
local path = " ${ work_dir } /lng-image "
mkdir -p ${ path } /opt/livecd/lng
umount_image_handler
if [ [ -n " ${ custom } " ] ] ; then
aufs_mount_custom_image " ${ path } "
aufs_append_root_image " ${ path } "
else
aufs_mount_root_image " ${ path } "
fi
if [ [ -n ${ packages_lng_kde } ] ] ; then
download_to_cache " ${ path } " " ${ cache_dir_lng } " " ${ packages_lng } ${ packages_lng_kde } "
copy_cache_lng
else
download_to_cache " ${ path } " " ${ cache_dir_lng } " " ${ packages_lng } "
copy_cache_lng
fi
if [ [ -n " ${ packages_lng_cleanup } " ] ] ; then
for lng_clean in ${ packages_lng_cleanup } ; do
rm ${ path } /opt/livecd/lng/${ lng_clean }
done
fi
cp ${ PKGDATADIR } /pacman-lng.conf ${ path } /opt/livecd
rm -r ${ path } /var
make_repo ${ path } /opt/livecd/lng/lng-pkgs ${ path } /opt/livecd/lng
umount_image_handler
2015-03-18 11:39:21 +01:00
find ${ path } -name '.wh.*' -delete & >/dev/null
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
msg "Done [lng-image]"
2014-12-08 23:50:56 +01:00
fi
}
2014-12-11 22:46:11 +01:00
2015-01-13 04:48:04 +01:00
make_image_boot( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
2015-03-05 10:54:09 +01:00
msg " Prepare [ ${ iso_name } /boot] "
local path_iso = " ${ work_dir } /iso/ ${ iso_name } /boot "
2015-02-13 15:17:00 +01:00
mkdir -p ${ path_iso } /${ arch }
cp ${ work_dir } /root-image/boot/memtest86+/memtest.bin ${ path_iso } /${ arch } /memtest
2015-03-05 10:54:09 +01:00
cp ${ work_dir } /root-image/boot/vmlinuz* ${ path_iso } /${ arch } /${ iso_name }
2015-02-13 15:17:00 +01:00
local path = " ${ work_dir } /boot-image "
mkdir -p ${ path }
umount_image_handler
if [ [ -n " ${ custom } " ] ] ; then
aufs_mount_custom_image " ${ path } "
aufs_append_root_image " ${ path } "
else
aufs_mount_root_image " ${ path } "
fi
copy_initcpio " ${ path } "
2015-05-04 21:32:04 +02:00
2015-02-13 15:17:00 +01:00
gen_boot_image " ${ path } "
2015-03-05 10:54:09 +01:00
mv ${ path } /boot/${ iso_name } .img ${ path_iso } /${ arch } /${ iso_name } .img
2015-04-17 08:57:55 +02:00
if [ [ -f ${ path } /boot/intel-ucode.img ] ] ; then
cp ${ path } /boot/intel-ucode.img ${ path_iso } /intel_ucode.img
cp ${ path } /usr/share/licenses/intel-ucode/LICENSE ${ path_iso } /intel_ucode.LICENSE
fi
2015-02-13 15:17:00 +01:00
umount_image_handler
rm -R ${ path }
: > ${ work_dir } /build.${ FUNCNAME }
2015-03-05 10:54:09 +01:00
msg " Done [ ${ iso_name } /boot] "
2015-02-13 15:17:00 +01:00
fi
2014-12-08 23:50:56 +01:00
}
# Prepare /EFI
make_efi( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
2015-03-05 10:54:09 +01:00
msg " Prepare [ ${ iso_name } /boot/EFI] "
2015-02-13 15:17:00 +01:00
local path_iso = " ${ work_dir } /iso "
local path_efi = " ${ path_iso } /EFI "
mkdir -p ${ path_efi } /boot
2015-03-04 10:42:15 +01:00
copy_efi_loaders " ${ work_dir } /root-image " " ${ path_efi } /boot "
2015-02-13 15:17:00 +01:00
mkdir -p ${ path_iso } /loader/entries
2015-03-04 00:40:44 +01:00
write_loader_conf " ${ path_iso } /loader "
write_efi_shellv1_conf " ${ path_iso } /loader/entries "
write_efi_shellv2_conf " ${ path_iso } /loader/entries "
write_usb_conf " ${ path_iso } /loader/entries "
write_usb_nonfree_conf " ${ path_iso } /loader/entries "
2015-02-18 04:28:11 +01:00
copy_efi_shells " ${ path_efi } "
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
2015-03-05 10:54:09 +01:00
msg " Done [ ${ iso_name } /boot/EFI] "
2015-02-13 15:17:00 +01:00
fi
2014-12-08 23:50:56 +01:00
}
# Prepare kernel.img::/EFI for "El Torito" EFI boot mode
make_efiboot( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
2015-03-05 10:54:09 +01:00
msg " Prepare [ ${ iso_name } /iso/EFI] "
2015-02-13 15:17:00 +01:00
local path_iso = " ${ work_dir } /iso "
mkdir -p ${ path_iso } /EFI/miso
2015-05-06 21:05:12 +02:00
truncate -s ${ efi_part_size } ${ path_iso } /EFI/miso/${ iso_name } .img
2015-03-05 10:54:09 +01:00
mkfs.vfat -n MISO_EFI ${ path_iso } /EFI/miso/${ iso_name } .img
2015-02-13 15:17:00 +01:00
mkdir -p ${ work_dir } /efiboot
2015-03-05 10:54:09 +01:00
mount ${ path_iso } /EFI/miso/${ iso_name } .img ${ work_dir } /efiboot
2015-02-13 15:17:00 +01:00
local path_efi = " ${ work_dir } /efiboot/EFI "
mkdir -p ${ path_efi } /miso
2015-03-05 10:54:09 +01:00
copy_boot_images " ${ path_iso } / ${ iso_name } /boot " " ${ path_efi } /miso "
2015-02-13 15:17:00 +01:00
mkdir -p ${ path_efi } /boot
2015-03-04 10:42:15 +01:00
copy_efi_loaders " ${ work_dir } /root-image " " ${ path_efi } /boot "
2015-03-04 01:43:47 +01:00
local efi_loader = ${ work_dir } /efiboot/loader
mkdir -p ${ efi_loader } /entries
write_loader_conf " ${ efi_loader } "
write_efi_shellv1_conf " ${ efi_loader } /entries "
write_efi_shellv2_conf " ${ efi_loader } /entries "
write_dvd_conf " ${ efi_loader } /entries "
write_dvd_nonfree_conf " ${ efi_loader } /entries "
2015-03-04 10:42:15 +01:00
copy_efi_shells " ${ path_efi } "
2015-02-13 15:17:00 +01:00
umount ${ work_dir } /efiboot
: > ${ work_dir } /build.${ FUNCNAME }
2015-03-05 10:54:09 +01:00
msg " Done [ ${ iso_name } /iso/EFI] "
2015-02-13 15:17:00 +01:00
fi
2014-12-08 23:50:56 +01:00
}
# Prepare /isolinux
make_isolinux( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
2015-03-05 10:54:09 +01:00
msg " Prepare [ ${ iso_name } /iso/isolinux] "
2015-03-04 13:11:50 +01:00
local path = ${ work_dir } /iso/isolinux
mkdir -p ${ path }
cp -a --no-preserve= ownership isolinux/* ${ path }
write_isolinux_cfg " ${ path } "
2015-03-04 21:38:46 +01:00
write_isolinux_msg " ${ path } "
2015-02-13 15:17:00 +01:00
if [ [ -e isolinux-overlay ] ] ; then
2015-03-04 13:11:50 +01:00
msg2 "isolinux overlay found. Overwriting files ..."
cp -a --no-preserve= ownership isolinux-overlay/* ${ path }
update_isolinux_cfg " ${ path } "
2015-03-04 21:38:46 +01:00
update_isolinux_msg " ${ path } "
2015-02-13 15:17:00 +01:00
fi
2015-03-04 13:11:50 +01:00
copy_isolinux_bin " ${ work_dir } /root-image " " ${ path } "
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
2015-03-05 10:54:09 +01:00
msg " Done [ ${ iso_name } /iso/isolinux] "
2015-02-13 15:17:00 +01:00
fi
2014-12-08 23:50:56 +01:00
}
make_isomounts( ) {
2015-02-13 15:17:00 +01:00
if [ [ ! -e ${ work_dir } /build.${ FUNCNAME } ] ] ; then
msg "Creating [isomounts]"
2015-03-05 10:54:09 +01:00
write_isomounts " ${ work_dir } /iso/ ${ iso_name } /isomounts "
2015-02-13 15:17:00 +01:00
: > ${ work_dir } /build.${ FUNCNAME }
msg "Done creating [isomounts]"
fi
2014-12-08 23:50:56 +01:00
}
2015-01-29 00:17:15 +01:00
# $1: file name
load_pkgs( ) {
2015-02-13 15:17:00 +01:00
msg3 " Loading Packages: [ $1 ] ... "
if [ [ " ${ arch } " = = "i686" ] ] ; then
2015-03-05 10:54:09 +01:00
packages = $( sed "s|#.*||g" " $1 " | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>x86_64.*||g" | sed "s|>i686||g" | sed " s|KERNEL| $kernel |g " | sed ':a;N;$!ba;s/\n/ /g' )
2015-02-13 15:17:00 +01:00
elif [ [ " ${ arch } " = = "x86_64" ] ] ; then
2015-03-05 10:54:09 +01:00
packages = $( sed "s|#.*||g" " $1 " | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>i686.*||g" | sed "s|>x86_64||g" | sed " s|KERNEL| $kernel |g " | sed ':a;N;$!ba;s/\n/ /g' )
2015-02-13 15:17:00 +01:00
fi
2015-01-29 00:17:15 +01:00
}
2015-01-16 13:52:35 +01:00
load_pkgs_xorg( ) {
2015-02-13 15:17:00 +01:00
msg3 "Loading Packages: [Packages-Xorg] ..."
if [ [ " ${ arch } " = = "i686" ] ] ; then
2015-03-05 10:54:09 +01:00
packages_xorg = $( sed "s|#.*||g" Packages-Xorg | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>cleanup.*||g" | sed "s|>x86_64.*||g" | sed "s|>i686||g" | sed "s|>free_x64.*||g" | sed "s|>free_uni||g" | sed "s|>nonfree_x64.*||g" | sed "s|>nonfree_uni||g" | sed " s|KERNEL| $kernel |g " | sed ':a;N;$!ba;s/\n/ /g' )
2015-02-13 15:17:00 +01:00
elif [ [ " ${ arch } " = = "x86_64" ] ] ; then
2015-03-05 10:54:09 +01:00
packages_xorg = $( sed "s|#.*||g" Packages-Xorg | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>cleanup.*||g" | sed "s|>i686.*||g" | sed "s|>x86_64||g" | sed "s|>free_x64||g" | sed "s|>free_uni||g" | sed "s|>nonfree_uni||g" | sed "s|>nonfree_x64||g" | sed " s|KERNEL| $kernel |g " | sed ':a;N;$!ba;s/\n/ /g' )
2015-02-13 15:17:00 +01:00
fi
2015-03-05 10:54:09 +01:00
packages_xorg_cleanup = $( sed "s|#.*||g" Packages-Xorg | grep cleanup | sed "s|>cleanup||g" | sed " s|KERNEL| $kernel |g " | sed ':a;N;$!ba;s/\n/ /g' )
2015-01-16 13:52:35 +01:00
}
2015-01-15 04:38:47 +01:00
2015-01-16 13:52:35 +01:00
load_pkgs_lng( ) {
2015-02-13 15:17:00 +01:00
msg3 "Loading Packages: [Packages-Lng] ..."
if [ [ " ${ arch } " = = "i686" ] ] ; then
packages_lng = $( sed "s|#.*||g" Packages-Lng | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>cleanup.*||g" | sed "s|>x86_64.*||g" | sed "s|>i686||g" | sed "s|>kde.*||g" | sed ':a;N;$!ba;s/\n/ /g' )
elif [ [ " ${ arch } " = = "x86_64" ] ] ; then
packages_lng = $( sed "s|#.*||g" Packages-Lng | sed "s| ||g" | sed "s|>dvd.*||g" | sed "s|>blacklist.*||g" | sed "s|>cleanup.*||g" | sed "s|>i686.*||g" | sed "s|>x86_64||g" | sed "s|>kde.*||g" | sed ':a;N;$!ba;s/\n/ /g' )
fi
packages_lng_cleanup = $( sed "s|#.*||g" Packages-Lng | grep cleanup | sed "s|>cleanup||g" )
packages_lng_kde = $( sed "s|#.*||g" Packages-Lng | grep kde | sed "s|>kde||g" | sed ':a;N;$!ba;s/\n/ /g' )
2015-01-16 13:52:35 +01:00
}
2015-01-15 04:38:47 +01:00
2015-05-06 23:03:08 +02:00
check_chroot_version( ) {
2015-05-03 23:32:21 +02:00
local chroot_version = $( cat ${ work_dir } /root-image/.manjaro-tools)
if [ [ ${ version } != $chroot_version ] ] ; then
clean_first = true
fi
}
2015-05-04 21:32:04 +02:00
check_plymouth( ) {
is_plymouth = false
source mkinitcpio.conf
for h in ${ HOOKS [@] } ; do
if [ [ $h = = 'plymouth' ] ] ; then
is_plymouth = true
fi
done
}
2015-01-29 00:17:15 +01:00
# $1: profile
2015-01-17 19:05:18 +01:00
load_profile( ) {
2015-03-03 01:59:44 +01:00
msg3 " Profile: [ $1 ] "
2015-03-03 02:38:31 +01:00
load_profile_config 'profile.conf'
2015-02-13 15:17:00 +01:00
local files = $( ls Packages*)
for f in ${ files [@] } ; do
case $f in
Packages| Packages-Livecd| Packages-Xorg| Packages-Lng) continue ; ;
*) packages_custom = " $f " ; msg2 " Packages-Custom: $f " ; ;
esac
done
custom = ${ packages_custom #*- }
custom = ${ custom ,, }
2015-03-05 10:54:09 +01:00
iso_file = " ${ iso_name } - ${ custom } - ${ dist_release } - ${ arch } .iso "
2015-02-13 15:17:00 +01:00
if [ [ -f pacman-${ pacman_conf_arch } .conf ] ] ; then
pacman_conf = " pacman- ${ pacman_conf_arch } .conf "
else
pacman_conf = " ${ PKGDATADIR } /pacman- ${ pacman_conf_arch } .conf "
fi
create_args += ( -C ${ pacman_conf } )
work_dir = ${ chroots_iso } /$1 /${ arch }
2015-05-04 21:32:04 +02:00
check_plymouth
2015-05-06 23:03:08 +02:00
[ [ -d ${ work_dir } /root-image ] ] && check_chroot_version
2015-05-03 22:27:40 +02:00
}
2014-12-31 01:02:43 +01:00
compress_images( ) {
2015-02-18 04:28:11 +01:00
local timer = $( get_timer)
2015-02-13 15:17:00 +01:00
make_iso
make_checksum " ${ iso_file } "
2015-02-20 11:57:04 +01:00
msg3 " Time ${ FUNCNAME } : $( elapsed_time ${ timer } ) minutes "
2014-12-31 01:02:43 +01:00
}
2015-05-02 23:04:24 +02:00
clean_pacman_conf( ) {
2015-05-03 05:58:39 +02:00
# set default values
REPOS = ( )
flag = 0
2015-05-02 23:04:24 +02:00
# Get repos from pacman_conf
2015-05-03 05:58:39 +02:00
# sed is being used for removing comments and repo brackets []
2015-05-02 23:04:24 +02:00
REPOS = ( $( grep "\[*\]" " $pacman_conf " | sed -e '/^\s*#/d' -e 's/\[//' -e 's/\]//' ) )
# Set valid repos
if [ [ $arch = x86_64 ] ] ; then
VALID = ( 'options' 'core' 'extra' 'community' 'multilib' )
else
VALID = ( 'options' 'core' 'extra' 'community' )
fi
# Remove extra repos from pacman.conf
for repo in " ${ REPOS [@] } " ; do
if [ [ ! $( echo " ${ VALID [*] } " | grep " $repo " ) ] ] && [ [ ! $( echo " $keep_repo " | grep " $repo " ) ] ] ; then
# Remove custom repo
for file in $work_dir /{ livecd,root,$custom } -image/etc/pacman.conf; do
if [ [ -f $file ] ] ; then
msg2 " Editing $file "
2015-05-03 05:58:39 +02:00
sed -i " /^\[ $repo /,/^Server/d " " $file " && flag = 1 || return 1
2015-05-02 23:04:24 +02:00
fi
done
2015-05-03 05:58:39 +02:00
if [ [ $flag -eq 1 ] ] ; then
msg " Custom repo $repo removed from pacman.conf "
fi
2015-05-02 23:04:24 +02:00
fi
done
}
2015-01-15 02:49:21 +01:00
build_images( ) {
2015-02-18 04:28:11 +01:00
local timer = $( get_timer)
2015-02-13 15:17:00 +01:00
load_pkgs "Packages"
make_image_root
if [ [ -f " ${ packages_custom } " ] ] ; then
load_pkgs " ${ packages_custom } "
make_image_custom
fi
2015-02-14 10:50:41 +01:00
if [ [ -f Packages-Livecd ] ] ; then
load_pkgs "Packages-Livecd"
make_image_livecd
fi
2015-02-13 15:17:00 +01:00
if [ [ -f Packages-Xorg ] ] ; then
load_pkgs_xorg
make_image_xorg
fi
if [ [ -f Packages-Lng ] ] ; then
load_pkgs_lng
make_image_lng
fi
make_image_boot
if [ [ " ${ arch } " = = "x86_64" ] ] ; then
make_efi
make_efiboot
fi
make_isolinux
make_isomounts
2015-02-20 11:57:04 +01:00
msg3 " Time ${ FUNCNAME } : $( elapsed_time ${ timer } ) minutes "
2014-12-31 01:02:43 +01:00
}
2015-01-15 04:38:47 +01:00
2015-05-04 01:15:52 +02:00
check_profile( ) {
2015-05-04 02:09:45 +02:00
local keyfiles = ( 'profile.conf' 'mkinitcpio.conf' 'Packages' 'Packages-Livecd' )
local keydirs = ( 'overlay' 'overlay-livecd' 'isolinux' )
2015-05-04 01:15:52 +02:00
local has_keyfiles = false has_keydirs = false
2015-05-04 02:09:45 +02:00
msg " Checking profile [ $1 ] "
2015-05-04 01:15:52 +02:00
for f in ${ keyfiles [@] } ; do
2015-05-04 01:51:45 +02:00
if [ [ -f $1 /$f ] ] ; then
2015-05-04 01:15:52 +02:00
has_keyfiles = true
2015-05-04 01:51:45 +02:00
else
has_keyfiles = false
break
2015-05-04 01:15:52 +02:00
fi
done
for d in ${ keydirs [@] } ; do
2015-05-04 01:51:45 +02:00
if [ [ -d $1 /$d ] ] ; then
2015-05-04 01:15:52 +02:00
has_keydirs = true
2015-05-04 01:51:45 +02:00
else
has_keydirs = false
break
2015-05-04 01:15:52 +02:00
fi
done
2015-05-04 02:09:45 +02:00
msg2 " has_keyfiles: ${ has_keyfiles } "
msg2 " has_keydirs: ${ has_keydirs } "
2015-05-04 01:15:52 +02:00
if ${ has_keyfiles } && ${ has_keydirs } ; then
2015-05-06 20:21:55 +02:00
msg "Profile sanity check passed."
2015-05-04 01:15:52 +02:00
else
eval $2
fi
}
2015-02-14 10:50:41 +01:00
make_profile( ) {
msg " Start building [ $1 ] "
cd $1
load_profile " $1 "
${ clean_first } && clean_chroots " ${ work_dir } "
${ clean_cache_xorg } && clean_cache " ${ cache_dir_xorg } "
${ clean_cache_lng } && clean_cache " ${ cache_dir_lng } "
if ${ iso_only } ; then
2015-03-04 10:42:15 +01:00
[ [ ! -d ${ work_dir } ] ] && die " Create images: buildiso -p ${ buildset_iso } -i "
2015-02-14 10:50:41 +01:00
compress_images
exit 1
fi
if ${ images_only } ; then
build_images
2015-05-02 23:04:24 +02:00
clean_pacman_conf
2015-03-04 10:42:15 +01:00
warning " Continue compress: buildiso -p ${ buildset_iso } -sc ... "
2015-02-14 10:50:41 +01:00
exit 1
else
build_images
2015-05-02 23:04:24 +02:00
clean_pacman_conf
2015-02-14 10:50:41 +01:00
compress_images
fi
cd ..
2015-02-20 11:57:04 +01:00
msg " Finished building [ $1 ] "
msg3 " Time ${ FUNCNAME } : $( elapsed_time ${ timer_start } ) minutes "
2015-01-15 04:38:47 +01:00
}
build_iso( ) {
2015-02-13 15:17:00 +01:00
if ${ is_buildset } ; then
for prof in $( cat ${ sets_dir_iso } /${ buildset_iso } .set) ; do
2015-05-04 01:15:52 +02:00
check_profile " $prof " "break"
2015-02-14 10:50:41 +01:00
make_profile " $prof "
2015-02-13 15:17:00 +01:00
done
else
2015-05-04 01:15:52 +02:00
check_profile " ${ buildset_iso } " 'die "Profile sanity check failed."'
2015-02-14 10:50:41 +01:00
make_profile " ${ buildset_iso } "
2015-02-13 15:17:00 +01:00
fi
2015-01-15 04:38:47 +01:00
}