-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·54 lines (44 loc) · 1.36 KB
/
setup.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: Copyright © 2020-2023 Serpent OS Developers
#
# SPDX-License-Identifier: Zlib
#
set -e
DeprecatedFiles=("scripts/update_format.sh", "LICENSE")
LinkFiles=(".editorconfig" "dscanner.ini")
NukedAny=0
function failMsg()
{
echo -e "$*"
exit 1
}
[[ -z $(git status --untracked-files=no --porcelain .) ]] || failMsg "Ensure git tree is clean before running this script"
test -e .git || failMsg "Please run from the root of a Serpent OS git project"
# Deprecate old scripts
for depr in ${DeprecatedFiles[@]}; do
if [[ -e "${depr}" ]]; then
echo "Removing deprecated asset: ${depr}"
git rm "${depr}"
NukedAny=1
fi
done
if [[ "${NukedAny}" == "1" ]]; then
echo "Committing changes..."
git commit -S -s -m "serpent-style: Remove deprecated assets"
fi
# Forcibly link the files in
for link in ${LinkFiles[@]}; do
ln -svf "serpent-style/${link}" "."
done
# Add REUSE-compatible license directory
mkdir -pv ./LICENSES/
cp -vf serpent-style/LICENSES/MPL-2.0.txt ./LICENSES/
git add LICENSES/
# Link pre-commit hook in (using -r avoids dangling symlink)
if [[ ! -d .git/hooks ]]; then
install -D -d -m 00755 .git/hooks
fi
ln -rsvf serpent-style/git-pre-commit-hook.sh .git/hooks/pre-commit
git status
echo -e "\nPlease 'git add' any new links/files added by serpent-style/ and commit them.\n"