-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsquash
More file actions
executable file
·112 lines (110 loc) · 3.29 KB
/
Copy pathpsquash
File metadata and controls
executable file
·112 lines (110 loc) · 3.29 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#dont double compress git compressed stuff
export GIT='-action uncompressed@subpathname(*/.git/objects/pack)'
#lz4
export COMPMETHOD="-comp zstd -all-root"
export PORTDIR="/usr/portage"
#export EIXDIR="/var/cache/eix/"
export EIXDIR="/var/cache/distfiles"
EMAIL="${1}"
if ! mountpoint "${PORTDIR}"; then
echo "Portage git not mounted! Aborting!"
exit -1
fi
while pgrep emerge >/dev/null; do
echo "Emerge running. Waiting..."
pidwait emerge
done
if [ "$UID" -ne 0 ]; then
exec sudo "${0}" "${@}"
fi
set -eu
if [ -e "${PORTDIR}.mount/portage.new.sfs" ]; then
rm "${PORTDIR}.mount/portage.new.sfs"
fi
pushd /usr/portage
git pull
popd
repack() {
systemctl stop smbd >/dev/null
echo "waiting for /usr/portage to be not in use"
while lsof /usr/portage && ! read -t 5 -p 'IN use: press enter to bypass'; do sleep 1s; done #wait for it to not be in use!
mksquashfs "${PORTDIR}" "${PORTDIR}.mount/portage.new.sfs" ${GIT} ${COMPMETHOD}
#rc-service -s nfs stop
echo ${PORTDIR}
if mountpoint "${PORTDIR}"; then
umount -l "${PORTDIR}"
fi
echo "umounted"
if mountpoint "${PORTDIR}.mount/ro"; then
umount "${PORTDIR}.mount/ro"
fi
echo "unmounted secondary"
#echo "new squash created, press any key"
#read -n 1
#if [ -e "${PORTDIR}.mount/changes/" ]; then
# rm -R "${PORTDIR}.mount/changes/"
# install -o root -g root -d "${PORTDIR}.mount/changes"
#fi
if mountpoint "${PORTDIR}.mount/tmpfs/" ; then
umount "${PORTDIR}.mount/tmpfs/"
mount "${PORTDIR}.mount/tmpfs/"
mkdir -p "${PORTDIR}.mount/tmpfs/changes"
mkdir -p "${PORTDIR}.mount/tmpfs/workdir"
fi
echo "recreated changes"
#if [ -e "${PORTDIR}.mount/workdir/work/" ]; then
# rm -R "${PORTDIR}.mount/workdir/work/"
# install -o root -g root -d "${PORTDIR}.mount/workdir/work"
#fi
#echo "changes cleared, press any key"
#read -n 1
if [ -e "${PORTDIR}.mount/portage.sfs" ]; then
rm "${PORTDIR}.mount/portage.sfs"
fi
echo "old squashfs removed"
mv "${PORTDIR}.mount/portage.new.sfs" "${PORTDIR}.mount/portage.sfs"
if [ -e "${PORTDIR}/metadata" ] ; then
rm -R "${PORTDIR}"
install -o portage -g portage -d "${PORTDIR}"
fi
mount "${PORTDIR}.mount/ro"
mount "${PORTDIR}"
echo "Remounted"
systemctl start smbd
}
if [ $(du -s "${PORTDIR}".mount/tmpfs | awk '{print $1}') -ge 20000 ]; then
repack
fi
emerge --sync
if [ -e "${EIXDIR}/portage.eix" ]; then
mv -f "${EIXDIR}/portage.eix" "${EIXDIR}/previous.eix"
# emerge --sync
eix-update
eix-diff "${EIXDIR}/previous.eix" "${EIXDIR}/portage.eix"
fi
# Regen cache for overlay
sudo -u kyle bash -c "
pushd /home/kyle/repos/phoenix591 &&
rm -R metadata/md5-cache &&
git rm -r metadata/md5-cache &&
git stash push -u &&
pmaint regen --use-local-desc --pkg-desc-index -t 2 phoenix591 &&
git add -A metadata/md5-cache metadata/pkg_desc_index profiles/use.local.desc &&
if ! git diff --staged --quiet; then
git commit -m 'Cache regenerated'
fi
git checkout stash^{/.*} -- . &&
git reset &&
git stash drop &&
git push
pmaint regen --use-local-desc --pkg-desc-index -t 2 phoenix591"
#rc-service -S nfs start
#cp "${EIXDIR}"/portage.eix "${PORTDIR}"
set +u
if [ ! -z "${EMAIL}" ]; then
/usr/local/bin/postsync.sh "${EMAIL}"
fi
sudo -u kyle pkgcheck cache -ur phoenix591
sudo -u kyle bash -c "cd ~/guru && git fetch && git reset --hard origin/dev"
sudo -u kyle pkgcheck cache -ur guru