-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsync-rpi-xcs.sh
executable file
·38 lines (33 loc) · 1021 Bytes
/
sync-rpi-xcs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Default ssh-host?
host="$1"
if [ -z "$1" ]; then
echo "Please provide target system to which you want to sync."
echo " e.g: $0 rpizero-local-root"
exit 0
fi
# sync
rsync -auHWv $host:{/usr,/lib} $XC_RPI_ROOTFS
# wait a bit so the VM is able to update its internal file system with the updates
sleep 3
# Updates are pushed into a "cmd", which is eventually evaluated/executed
CMD=""
# Directory with faulty symlinks
TARGET_DIR="usr/lib/arm-linux-gnueabihf"
# Fetch broken symlinks
RELINK=$(file $XC_RPI_ROOTFS/$TARGET_DIR/* | grep "broken symbolic" | awk '{print $1""$NF}' )
# Fix each symlink
for i in $RELINK ; do
IFS=':' # split line by ':'
# split entry in "src" en "dst" path
read -a LN_SPLIT <<< "${i}"
LN_SRC="${LN_SPLIT[0]}"
LN_DST="${LN_SPLIT[1]}"
# add target root to "dst" and clear double slashes
LN_DST=$(echo "$XC_RPI_ROOTFS/$LN_DST" | sed "s/\/\//\//g")
echo "$LN_SRC >> $LN_DST"
# update link
CMD="$CMD ln -sf $LN_DST $LN_SRC;"
done
# fix links in vm
eval $CMD