2018-02-18 22:03:58 +00:00
|
|
|
#!/bin/sh -e
|
2018-02-17 20:04:57 +00:00
|
|
|
|
2018-07-26 09:56:01 +00:00
|
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
|
|
CUT="gcut"
|
|
|
|
if ! command -v "${CUT}" >/dev/null 2>&1; then
|
|
|
|
CUT="cut"
|
|
|
|
fi
|
2018-07-17 13:22:40 +00:00
|
|
|
fi
|
|
|
|
|
2018-02-19 08:46:08 +00:00
|
|
|
file_changed() {
|
2018-02-20 02:02:42 +00:00
|
|
|
if [ ! -f "$1" ]; then
|
|
|
|
if [ ! -f "$2" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -f "$2" ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
2018-02-19 08:46:08 +00:00
|
|
|
oldfilehash="$(sha1sum "$1" | awk '{print $1}')"
|
|
|
|
newfilehash="$(sha1sum "$2" | awk '{print $1}')"
|
|
|
|
[ "${oldfilehash}" != "${newfilehash}" ]
|
|
|
|
}
|
|
|
|
|
2018-02-17 20:09:46 +00:00
|
|
|
if [ ! -d ~/.local/profile-git ]; then
|
|
|
|
mkdir -p ~/.local/profile-git
|
2018-02-20 01:34:24 +00:00
|
|
|
(
|
|
|
|
cd ~/.local/profile-git
|
|
|
|
git init
|
|
|
|
git remote add origin https://git.icedream.tech/icedream/profile.git
|
|
|
|
)
|
2018-02-17 20:04:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
(
|
2018-02-18 22:33:25 +00:00
|
|
|
|
|
|
|
cd ~/.local/profile-git
|
2018-02-19 08:46:08 +00:00
|
|
|
|
|
|
|
if [ "${_CHECKOUT_DONE:-0}" -lt 1 ]; then
|
|
|
|
echo "Fetching updates for profile..."
|
|
|
|
git fetch -p
|
|
|
|
|
|
|
|
# Synchronizing valid GPG keys
|
|
|
|
echo "Preparing for update verification..."
|
|
|
|
export GNUPGHOME="$HOME/.local/profile-data/gnupg"
|
|
|
|
mkdir -p "${GNUPGHOME}"
|
|
|
|
chmod 700 "${GNUPGHOME}"
|
2018-02-19 09:22:28 +00:00
|
|
|
for key in \
|
2018-02-19 08:46:08 +00:00
|
|
|
B5108C5A158A6608AD3361DA1573F6D8EFE4D0CF \
|
2018-02-19 09:22:28 +00:00
|
|
|
; do
|
|
|
|
if ! gpg --list-keys "${key}" >/dev/null 2>&1; then
|
|
|
|
# key does not exist yet
|
2018-06-18 11:44:40 +00:00
|
|
|
gpg --recv-keys "${key}"
|
2018-02-19 09:22:28 +00:00
|
|
|
fi
|
|
|
|
done
|
2018-02-19 08:46:08 +00:00
|
|
|
|
|
|
|
echo "Verifying updates..."
|
2018-02-20 02:04:06 +00:00
|
|
|
ref="origin/master"
|
|
|
|
diffref="${ref}"
|
|
|
|
if git rev-parse HEAD >/dev/null 2>&1; then
|
|
|
|
diffref="HEAD..${diffref}"
|
|
|
|
fi
|
|
|
|
git rev-list --format=oneline "${diffref}" | while IFS= read -r line; do
|
2018-02-19 08:46:08 +00:00
|
|
|
sha="$(echo "$line" | awk '{print $1}')"
|
2018-07-17 13:22:40 +00:00
|
|
|
title="$(echo "$line" | "${CUT}" -f 1 -d ' ' --complement)"
|
2018-02-19 08:46:08 +00:00
|
|
|
printf " … $title\r "
|
|
|
|
if ! git verify-commit "$sha" >/dev/null 2>&1; then
|
|
|
|
echo "✘"
|
|
|
|
echo "Found incorrectly signed commit, NOT applying. Contact the maintainer on the issue tracker."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "✔"
|
|
|
|
done
|
2018-02-20 02:05:08 +00:00
|
|
|
|
|
|
|
echo "All commits passed, now applying updates..."
|
|
|
|
if git rev-parse HEAD >/dev/null 2>&1; then
|
|
|
|
git rebase "${ref}"
|
|
|
|
else
|
|
|
|
git checkout -f "${ref}"
|
|
|
|
fi
|
|
|
|
git submodule update --init
|
2018-02-19 08:46:08 +00:00
|
|
|
|
|
|
|
if file_changed "${HOME}/bin/update-profile" "home/bin/update-profile"; then
|
|
|
|
# Use new profile update script instead
|
2018-02-19 08:56:15 +00:00
|
|
|
# Putting exit 0 on same line here for security since the old script
|
|
|
|
# will be deleted.
|
2018-02-19 08:58:04 +00:00
|
|
|
echo "Using newer profile update script."
|
2018-02-19 08:59:19 +00:00
|
|
|
export _CHECKOUT_DONE=1
|
|
|
|
exec home/bin/update-profile
|
2018-02-18 22:33:25 +00:00
|
|
|
fi
|
2018-02-19 08:46:08 +00:00
|
|
|
fi
|
2018-02-18 22:33:25 +00:00
|
|
|
|
|
|
|
echo "Running package installation..."
|
|
|
|
cd packages
|
|
|
|
./packages.sh
|
|
|
|
|
|
|
|
echo "Running profile installation..."
|
|
|
|
cd ..
|
2018-02-19 09:18:32 +00:00
|
|
|
if [ -f "${HOME}/bin/update-profile" ]; then
|
|
|
|
mv "${HOME}/bin/update-profile" "${HOME}/bin/update-profile.old"
|
|
|
|
fi
|
2018-02-18 22:33:25 +00:00
|
|
|
./install.sh
|
|
|
|
|
2018-02-17 20:04:57 +00:00
|
|
|
)
|
2018-02-19 08:48:23 +00:00
|
|
|
|
|
|
|
rm -f "${HOME}/bin/update-profile.old"
|