Compare commits

...

4 Commits

Author SHA1 Message Date
6700e1a2e6 Merge branch 'deploy' of artix/artools into master 2019-08-19 14:57:15 +02:00
f874c8c399 buildpkg: add a rebuild option
deploypkg: add option to pass filenames
2019-08-18 21:47:27 +02:00
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
8 changed files with 121 additions and 87 deletions

View File

@@ -112,6 +112,10 @@ chroot_extra_mount() {
chroot_add_resolv_conf "$1"
chroot_mount "/etc/hosts" "$1/etc/hosts" -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
chroot_mount "$cache_dir" "$1${cache_dir}" -Br

View File

@@ -15,6 +15,21 @@
. @libdir@/artools/util-base.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(){
timer_start=$(get_timer)
@@ -73,7 +88,9 @@ build(){
lock_close 9
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
if ${iso_only}; then
@@ -101,10 +118,9 @@ clean_first=true
pretend=false
images_only=false
iso_only=false
log=false
persist=false
basestrap_args=()
basestrap_args=(-GMc)
cmd=${0##*/}
REPOSITORY=${cmd##*-}
@@ -125,7 +141,6 @@ usage() {
echo ' -x Build images only'
echo ' -z Generate iso only'
echo ' Requires pre built images (-x)'
echo ' -l Log to file'
echo ' -q Query settings and pretend build'
echo ' -h This help'
echo ''
@@ -135,7 +150,7 @@ usage() {
orig_argv=("$0" "$@")
opts='p:r:t:i:g:czxmlqh'
opts='p:r:t:i:g:czxmqh'
while getopts "${opts}" arg; do
case "${arg}" in
@@ -148,7 +163,6 @@ while getopts "${opts}" arg; do
x) images_only=true ;;
z) iso_only=true ;;
m) persist=true ;;
l) log=true ;;
q) pretend=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;

View File

@@ -20,6 +20,7 @@ load_user_info
load_config "${USERCONFDIR}/artools/artools.conf" || load_config "${SYSCONFDIR}/artools.conf"
create_first=false
rebuild=false
mkchrootpkg_args=(-c -n)
@@ -27,22 +28,11 @@ cmd=${0##*/}
repo=${cmd#*-}
base_devel=('base-devel')
case ${repo} in
system|world|galaxy) repo='default' ;;
lib32*) base_devel+=('multilib-devel') ;;
galaxy-gremlins|galaxy-goblins) repo=${repo#*-} ;;
esac
pacman_conf="${DATADIR}/pacman-${repo}.conf"
[[ -f ${USERCONFDIR}/artools/pacman-${repo}.conf ]] && pacman_conf="${USERCONFDIR}/artools/pacman-${repo}.conf"
makepkg_conf="${DATADIR}/makepkg.conf"
[[ -f ${USERCONFDIR}/artools/makepkg.conf ]] && makepkg_conf="${USERCONFDIR}/artools/makepkg.conf"
usage() {
echo "Usage: ${0##*/} [options] -- [mkchrootpkg_args]"
echo " -r <dir> Create chroots in this directory"
echo ' -c Recreate the chroot before building'
echo ' -m Major rebuild'
echo ' -h This help'
echo ''
echo "Default mkchrootpkg_args args: ${mkchrootpkg_args[*]}"
@@ -52,17 +42,34 @@ usage() {
orig_argv=("$0" "$@")
opts='hcr:'
opts='hcmr:'
while getopts "${opts}" arg; do
case "${arg}" in
r) CHROOTS_PKG="$OPTARG" ;;
c) create_first=true ;;
m) rebuild=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '%s'" "${arg}"; usage 1 ;;
esac
done
if ${rebuild};then
repo='default'
else
case ${repo} in
system|world|galaxy) repo='default' ;;
lib32*) base_devel+=('multilib-devel') ;;
galaxy-gremlins|galaxy-goblins) repo=${repo#*-} ;;
esac
fi
pacman_conf="${DATADIR}/pacman-${repo}.conf"
[[ -f ${USERCONFDIR}/artools/pacman-${repo}.conf ]] && pacman_conf="${USERCONFDIR}/artools/pacman-${repo}.conf"
makepkg_conf="${DATADIR}/makepkg.conf"
[[ -f ${USERCONFDIR}/artools/makepkg.conf ]] && makepkg_conf="${USERCONFDIR}/artools/makepkg.conf"
check_root SOURCE_DATE_EPOCH
mkchrootpkg_args+=("${@:$OPTIND}")

View File

@@ -15,6 +15,62 @@
. @libdir@/artools/util-base.sh
. @libdir@/artools/util-pkg.sh
find_cached_pkgfile() {
local searchdirs=("$PKGDEST" "$PWD") results=()
local pkg="$1"
for dir in "${searchdirs[@]}"; do
[[ -d $dir ]] || continue
results+=$(find "$dir" -type f -name "$pkg")
done
case ${#results[*]} in
0)
return 1
;;
1)
printf '%s\n' "${results[0]}"
return 0
;;
*)
error 'Multiple packages found:'
printf '\t%s\n' "${results[@]}" >&2
return 1
;;
esac
}
update_repo2(){
local repo="$1"
local repo_path=${REPOS_ROOT}/$repo/os/${ARCH} packages=()
for name in ${passfiles[@]}; do
if pkgfile=$(find_cached_pkgfile "$name");then
info "Found: %s" "$name"
if ${add_pkg};then
local action='add'
packages+=("$name")
# checkpkg "${pkgfile}" || return 2
if ${sign_pkg};then
[[ -e ${pkgfile}.sig ]] && rm ${pkgfile}.sig
signfile ${pkgfile}
fi
ln -sf ${pkgfile}{,.sig} $repo_path/
elif ${del_pkg};then
local action='remove'
packages+=("$name")
[[ -e $repo_path/$name ]] && rm $repo_path/$name
[[ -e $repo_path/$name.sig ]] && rm $repo_path/$name.sig
fi
fi
done
cd $repo_path
if [[ -n $action ]]; then
repo-$action -R $repo.${PKGDBEXT} ${packages[@]}
${linksdb} && links-$action $repo.${LINKSDBEXT} ${packages[@]}
fi
return 0
}
update_repo(){
local repo="$1" pkgfile ver
local repo_path=${REPOS_ROOT}/$repo/os/${ARCH} packages=()
@@ -100,6 +156,12 @@ done
shift $(($OPTIND - 1))
passfiles="$@"
prepare_dir "${REPOS_ROOT}"
update_repo "${dest_repo}"
if [[ -n ${passfiles[@]} ]]; then
update_repo2 "${dest_repo}"
else
update_repo "${dest_repo}"
fi

View File

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

View File

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

View File

@@ -12,33 +12,12 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# 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 () {
local idir="$1" file="$2"
msg2 "Creating signature file..."
cd "$idir"
user_own "$idir"
user_run "gpg --detach-sign --default-key ${GPG_KEY} $file.sfs"
chown "${OWNER}:$(id --group ${OWNER})" "$idir"
su ${OWNER} -c "gpg --detach-sign --default-key ${GPG_KEY} $file.sfs"
chown -R root "$idir"
cd ${OLDPWD}
}

View File

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