Create a script for copying the repo

This commit is contained in:
Manuel Thalmann 2024-07-07 20:12:46 +02:00
parent b1dc0b2009
commit eef2a1edc6
3 changed files with 17 additions and 11 deletions

View file

@ -10,13 +10,7 @@ profileDir="/mnt/archiso-valhalla";
projectDir="$rootHome/PortValhalla"; projectDir="$rootHome/PortValhalla";
nixDir="$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs"; nixDir="$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs";
mkdir -p "$rootHome"; mkdir -p "$rootHome";
git clone .. "$projectDir"; "${BASH_SOURCE%/*}/../../scripts/copy-repo.sh" "$projectDir";
git -C .. diff HEAD | git -C "$projectDir" apply --allow-empty;
git -C .. ls-files --exclude-standard --others | \
while read file; do
cp "../$file" "$projectDir/$file";
done;
if [ ! -d "$nixCache" ]; then if [ ! -d "$nixCache" ]; then
mkdir -p "$nixCache" mkdir -p "$nixCache"

View file

@ -18,7 +18,7 @@ USER_GROUPS="${USER_GROUPS}";
projectRoot="$(realpath ../../..)"; projectRoot="$(realpath ../../..)";
projectName="$(basename "$projectRoot")"; projectName="$(basename "$projectRoot")";
relativeDir="$(realpath --relative-to "$projectRoot" "$(pwd)")"; relativeDir="$(realpath --relative-to "$projectRoot" "$(pwd)")";
tempRoot="/root/$(basename "$projectName")"; tempRoot="/opt/$(basename "$projectName")";
tempDir="$tempRoot/$relativeDir"; tempDir="$tempRoot/$relativeDir";
loadkeys "$ARCH_KEYMAP"; loadkeys "$ARCH_KEYMAP";
@ -39,7 +39,7 @@ pacstrap -K "$ARCH_MOUNT_ROOT" \
texinfo \ texinfo \
; ;
cp -r "$projectRoot" "${ARCH_MOUNT_ROOT}$tempRoot"; ../../copy-repo.sh "${ARCH_MOUNT_ROOT}$tempRoot";
genfstab -U "$ARCH_MOUNT_ROOT" >> "$ARCH_MOUNT_ROOT/etc/fstab"; genfstab -U "$ARCH_MOUNT_ROOT" >> "$ARCH_MOUNT_ROOT/etc/fstab";
arch-chroot "$ARCH_MOUNT_ROOT" systemctl enable NetworkManager; arch-chroot "$ARCH_MOUNT_ROOT" systemctl enable NetworkManager;
@ -78,6 +78,4 @@ systemd-nspawn -bD "$ARCH_MOUNT_ROOT" -E "ARCH_X11_KEYMAP=${ARCH_X11_KEYMAP}";
systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl disable set-keymap; systemd-nspawn -D "$ARCH_MOUNT_ROOT" systemctl disable set-keymap;
rm "$ARCH_MOUNT_ROOT/etc/systemd/system/set-keymap.service"; rm "$ARCH_MOUNT_ROOT/etc/systemd/system/set-keymap.service";
arch-chroot "$ARCH_MOUNT_ROOT" rm -rf "$tempRoot";
popd > /dev/null; popd > /dev/null;

14
scripts/copy-repo.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
function copyRepo() {
local dir="${BASH_SOURCE%/*}/..";
local target="$1";
git clone "$dir" "$target";
git -C "$dir" diff HEAD | git -C "$target" apply --allow-empty;
git -C "$dir" ls-files --exclude-standard --others | \
while read file; do
cp "$dir/$file" "$target/$file";
done;
}
copyRepo "$@";