Fixing up few issues, adding resolv.conf linking to chroot script

This commit is contained in:
ngn 2024-01-18 15:51:19 +03:00
parent f849284043
commit a8b0feb57d
3 changed files with 24 additions and 31 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
# matter-base | Matterlinux Release Archive Script
# matter-base | Matterlinux Release Archive Build Script
# Copyright (C) 2023 Matterlinux
# This program is free software: you can redistribute it and/or modify
@ -120,9 +120,6 @@ EOF
127.0.0.1 localhost
::1 localhost
EOF
cp /etc/mp/cfg etc/mp/cfg
#cp ~/.gnupg/pubring.kbx root/.gnupg/pubring.kbx
popd > /dev/null
export MP_ROOT="$TARGET" MP_YES=1

View File

@ -31,6 +31,12 @@ error() {
####################
## util functions ##
####################
linkresolv(){
if [ ! -f "$TARGET/etc/resolv.conf" ]; then
ln -sf /run/systemd/resolve/resolv.conf "$TARGET/etc/resolv.conf"
fi
}
chrt() {
mount -t proc proc "$TARGET/proc"
mount -t sysfs sysfs "$TARGET/sys"
@ -40,7 +46,8 @@ chrt() {
mount -o bind /dev "$TARGET/dev"
mount -t devpts none "$TARGET/dev/pts"
mount -t tmpfs tmpfs "$TARGET/run"
mount --bind /run "$TARGET/run"
linkresolv
if [ -h $TARGET/dev/shm ]; then
mkdir -p $TARGET/$(readlink $TARGET/dev/shm)
@ -48,6 +55,7 @@ chrt() {
mount -t tmpfs -o nosuid,nodev tmpfs "$TARGET/dev/shm"
fi
local prompt='\['$BOLD'\['$RED'(chroot)\['$RESET'\['$BOLD' \u@\h:\w#\['$RESET' '
chroot "$TARGET" /usr/bin/env -i \
HOME=/root \

View File

@ -73,18 +73,10 @@ check_retc() {
if [ $? -ne 0 ]; then
errorne "$1"
clean_tmpdir
exit 1
fi
}
setup_dns() {
info "Setting up DNS"
echo "nameserver 1.1.1.1" >> "$TMPDIR/etc/resolv.conf"
}
clean_dns(){
rm "$TMPDIR/etc/resolv.conf"
}
clean_tmpdir(){
if [ -d $TMPDIR ]; then
info "Cleaning up temp directory"
@ -186,20 +178,18 @@ for p2 in "${PKGS2[@]}"; do
fi
done
setup_dns
info "Adding public keys"
matter-chroot "$TMPDIR" gpg --receive-keys $keys_str
check_retc "Failed to add public keys"
info "Adding public keys"
matter-chroot "$TMPDIR" gpg --receive-keys $keys_str
check_retc "Failed to add public keys"
if [ ! -z "${PKGS1}" ]; then
if [ ! -z "${PKGS1}" ]; then
info "Installing extra packages (1)"
matter-chroot "$TMPDIR" mp-sync
check_retc "Sync failed"
matter-chroot "$TMPDIR" MP_YES=1 mp-install $pkgs1_str
check_retc "Install failed"
fi
clean_dns
fi
info "Running build script"
echo "source /iso.sh && build" > "$TMPDIR/stager.sh"
@ -218,10 +208,8 @@ popd > /dev/null
if [ ! -z "${PKGS2}" ]; then
info "Installing extra packages (2)"
setup_dns
matter-chroot "$TMPDIR" MP_YES=1 mp-install $pkgs2_str
check_ret "Install failed"
clean_dns
fi
info "Copying over the bootdir"