1
0
forked from artix/artools

Compare commits

..

2 Commits

Author SHA1 Message Date
1a5ea6c4ee buildiso: rm log option; clean up 2019-08-12 22:20:21 +02:00
486acaf47a chroot-run: bind mount /etc/localtime if it exists 2019-08-12 18:41:58 +02:00
6 changed files with 38 additions and 73 deletions

View File

@@ -112,6 +112,10 @@ chroot_extra_mount() {
chroot_add_resolv_conf "$1" chroot_add_resolv_conf "$1"
chroot_mount "/etc/hosts" "$1/etc/hosts" -B chroot_mount "/etc/hosts" "$1/etc/hosts" -B
chroot_mount "${cache_dirs[0]}" "$1${cache_dirs[0]}" -B chroot_mount "${cache_dirs[0]}" "$1${cache_dirs[0]}" -B
if [[ -e /etc/localtime ]];then
[[ -e $1/etc/localtime ]] || touch $1/etc/localtime
chroot_mount "/etc/localtime" "$1/etc/localtime" -B
fi
for cache_dir in ${cache_dirs[@]:1}; do for cache_dir in ${cache_dirs[@]:1}; do
chroot_mount "$cache_dir" "$1${cache_dir}" -Br chroot_mount "$cache_dir" "$1${cache_dir}" -Br

View File

@@ -15,6 +15,21 @@
. @libdir@/artools/util-base.sh . @libdir@/artools/util-base.sh
. @libdir@/artools/util-iso.sh . @libdir@/artools/util-iso.sh
gen_iso_fn(){
local vars=("artix") name
vars+=("${PROFILE}")
vars+=("${INITSYS}")
case "${REPOSITORY}" in
'gremlins'|'goblins') vars+=("${REPOSITORY}") ;;
esac
vars+=("${ISO_VERSION}")
vars+=("${ARCH}")
for n in ${vars[@]};do
name=${name:-}${name:+-}${n}
done
echo $name
}
prepare_build(){ prepare_build(){
timer_start=$(get_timer) timer_start=$(get_timer)
@@ -73,7 +88,9 @@ build(){
lock_close 9 lock_close 9
rm -rf --one-file-system "${work_dir}" rm -rf --one-file-system "${work_dir}"
clean_iso_root "${iso_root}"
msg "Deleting isoroot [%s] ..." "${iso_root##*/}"
rm -rf --one-file-system "${iso_root}"
fi fi
if ${iso_only}; then if ${iso_only}; then
@@ -101,10 +118,9 @@ clean_first=true
pretend=false pretend=false
images_only=false images_only=false
iso_only=false iso_only=false
log=false
persist=false persist=false
basestrap_args=() basestrap_args=(-GMc)
cmd=${0##*/} cmd=${0##*/}
REPOSITORY=${cmd##*-} REPOSITORY=${cmd##*-}
@@ -125,7 +141,6 @@ usage() {
echo ' -x Build images only' echo ' -x Build images only'
echo ' -z Generate iso only' echo ' -z Generate iso only'
echo ' Requires pre built images (-x)' echo ' Requires pre built images (-x)'
echo ' -l Log to file'
echo ' -q Query settings and pretend build' echo ' -q Query settings and pretend build'
echo ' -h This help' echo ' -h This help'
echo '' echo ''
@@ -135,7 +150,7 @@ usage() {
orig_argv=("$0" "$@") orig_argv=("$0" "$@")
opts='p:r:t:i:g:czxmlqh' opts='p:r:t:i:g:czxmqh'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
@@ -148,7 +163,6 @@ while getopts "${opts}" arg; do
x) images_only=true ;; x) images_only=true ;;
z) iso_only=true ;; z) iso_only=true ;;
m) persist=true ;; m) persist=true ;;
l) log=true ;;
q) pretend=true ;; q) pretend=true ;;
h|?) usage 0 ;; h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;; *) echo "invalid argument '${arg}'"; usage 1 ;;

View File

@@ -159,15 +159,6 @@ load_config(){
return 0 return 0
} }
user_own(){
local flag=$2
chown ${flag} "${OWNER}:$(id --group ${OWNER})" "$1"
}
user_run(){
su ${OWNER} -c "$@"
}
load_user_info(){ load_user_info(){
OWNER=${SUDO_USER:-$USER} OWNER=${SUDO_USER:-$USER}

View File

@@ -29,11 +29,11 @@ prepare_initramfs(){
fi fi
if [[ -n ${GPG_KEY} ]]; then if [[ -n ${GPG_KEY} ]]; then
user_run "gpg --export ${GPG_KEY} >${USERCONFDIR}/artools/gpgkey" su ${OWNER} -c "gpg --export ${GPG_KEY} >/tmp/GPG_KEY"
exec 17<>${USERCONFDIR}/artools/GPG_KEY exec 17<>/tmp/GPG_KEY
fi fi
local _kernel=$(cat $mnt/usr/lib/modules/*/version) local _kernel=$(cat $mnt/usr/lib/modules/*/version)
ARTIX_GNUPG_FD=${GPG_KEY:+17} chroot-run $mnt \ ARTIX_GNUPG_FD=${GPG_KEY:+17} artools-chroot $mnt \
/usr/bin/mkinitcpio -k ${_kernel} \ /usr/bin/mkinitcpio -k ${_kernel} \
-c /etc/mkinitcpio-artix.conf \ -c /etc/mkinitcpio-artix.conf \
-g /boot/initramfs.img -g /boot/initramfs.img
@@ -41,8 +41,8 @@ prepare_initramfs(){
if [[ -n ${GPG_KEY} ]]; then if [[ -n ${GPG_KEY} ]]; then
exec 17<&- exec 17<&-
fi fi
if [[ -f ${USERCONFDIR}/artools/GPG_KEY ]]; then if [[ -f /tmp/GPG_KEY ]]; then
rm ${USERCONFDIR}/artools/GPG_KEY rm /tmp/GPG_KEY
fi fi
} }
@@ -64,8 +64,9 @@ configure_grub(){
} }
prepare_grub(){ prepare_grub(){
local platform=i386-pc img='core.img' grub=$3/boot/grub efi=$3/efi/boot \ local platform=i386-pc img='core.img' prefix=/boot/grub
lib=$1/usr/lib/grub prefix=/boot/grub theme=$2/usr/share/grub local lib=$1/usr/lib/grub theme=$2/usr/share/grub
local grub=$3/boot/grub efi=$3/efi/boot
prepare_dir ${grub}/${platform} prepare_dir ${grub}/${platform}

View File

@@ -12,33 +12,12 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
gen_iso_fn(){
local vars=("artix") name
vars+=("${PROFILE}")
vars+=("${INITSYS}")
case "${REPOSITORY}" in
'gremlins'|'goblins') vars+=("${REPOSITORY}") ;;
esac
vars+=("${ISO_VERSION}")
vars+=("${ARCH}")
for n in ${vars[@]};do
name=${name:-}${name:+-}${n}
done
echo $name
}
clean_iso_root(){
local dest="$1"
msg "Deleting isoroot [%s] ..." "${dest##*/}"
rm -rf --one-file-system "$dest"
}
make_sig () { make_sig () {
local idir="$1" file="$2" local idir="$1" file="$2"
msg2 "Creating signature file..." msg2 "Creating signature file..."
cd "$idir" cd "$idir"
user_own "$idir" chown "${OWNER}:$(id --group ${OWNER})" "$idir"
user_run "gpg --detach-sign --default-key ${GPG_KEY} $file.sfs" su ${OWNER} -c "gpg --detach-sign --default-key ${GPG_KEY} $file.sfs"
chown -R root "$idir" chown -R root "$idir"
cd ${OLDPWD} cd ${OLDPWD}
} }

View File

@@ -27,20 +27,6 @@ error_function() {
exit 2 exit 2
} }
# $1: function
run_log(){
local func="$1" log_dir='/var/log/artools'
[[ ! -d $log_dir ]] && mkdir -p $log_dir
local logfile=${log_dir}/$(gen_iso_fn).$func.log
logpipe=$(mktemp -u "/tmp/$func.pipe.XXXXXXXX")
mkfifo "$logpipe"
tee "$logfile" < "$logpipe" &
local teepid=$!
$func &> "$logpipe"
wait $teepid
rm "$logpipe"
}
run_safe() { run_safe() {
local restoretrap func="$1" local restoretrap func="$1"
set -e set -e
@@ -48,11 +34,7 @@ run_safe() {
restoretrap=$(trap -p ERR) restoretrap=$(trap -p ERR)
trap 'error_function $func' ERR trap 'error_function $func' ERR
if ${log};then "$func"
run_log "$func"
else
"$func"
fi
eval $restoretrap eval $restoretrap
set +E set +E
@@ -132,11 +114,6 @@ clean_up_image(){
if [[ -d $path ]];then if [[ -d $path ]];then
find "$path" -mindepth 1 -delete &> /dev/null find "$path" -mindepth 1 -delete &> /dev/null
fi fi
# if [[ ${mnt##*/} == 'livefs' ]];then
# rm -rf "$mnt/etc/pacman.d/gnupg"
# fi
find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete find "$mnt" -name *.pacnew -name *.pacsave -name *.pacorig -delete
if [[ -f "$mnt/boot/grub/grub.cfg" ]]; then if [[ -f "$mnt/boot/grub/grub.cfg" ]]; then
rm $mnt/boot/grub/grub.cfg rm $mnt/boot/grub/grub.cfg
@@ -153,8 +130,7 @@ make_rootfs() {
prepare_dir "${rootfs}" prepare_dir "${rootfs}"
basestrap -GMc "${basestrap_args[@]}" "${rootfs}" "${packages[@]}" basestrap "${basestrap_args[@]}" "${rootfs}" "${packages[@]}"
echo "${CHROOTVERSION}" > "${rootfs}/.artools"
copy_overlay "${ROOT_OVERLAY}" "${rootfs}" copy_overlay "${ROOT_OVERLAY}" "${rootfs}"
@@ -175,7 +151,7 @@ make_livefs() {
mount_overlay "${livefs}" "${work_dir}" mount_overlay "${livefs}" "${work_dir}"
basestrap -GMc "${basestrap_args[@]}" "${livefs}" "${packages[@]}" basestrap "${basestrap_args[@]}" "${livefs}" "${packages[@]}"
copy_overlay "${LIVE_OVERLAY}" "${livefs}" copy_overlay "${LIVE_OVERLAY}" "${livefs}"
@@ -234,7 +210,7 @@ make_grub(){
compress_images(){ compress_images(){
local timer=$(get_timer) local timer=$(get_timer)
run_safe "make_iso" run_safe "make_iso"
user_own "${iso_dir}" "-R" chown -R "${OWNER}:$(id --group ${OWNER})" "${iso_dir}"
show_elapsed_time "${FUNCNAME}" "${timer}" show_elapsed_time "${FUNCNAME}" "${timer}"
} }