-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path03-tuxedo-update-version.sh
executable file
·123 lines (98 loc) · 5.14 KB
/
03-tuxedo-update-version.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
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
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
set -ex
MAINLINE_KERNEL_VERSION=6.5
UBUNTU_VERSION=22.04
UBUNTU_KERNEL_BRANCH=hwe-6.5
for arg in "$@"; do
shift
case "$arg" in
'--help') HELP=true ;;
'--dry') DRY=true ;;
'--abi') ABI=true ;;
'--build') BUILD=true ;;
esac
done
if [[ ${HELP} ]]; then
echo "Usage: $0 [--help] [--dry] [--abi|--build]"
exit
fi
echo "===Starting version update.==="
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "${SCRIPT}")
cd "${SCRIPTPATH}"
echo "===Fetching newest tags from upstream.==="
TUXEDO_KERNEL_BRANCH=tuxedo-${MAINLINE_KERNEL_VERSION}
TUXEDO_KERNEL_BRANCH_FULL=${TUXEDO_KERNEL_BRANCH}-${UBUNTU_VERSION}
if git remote | grep tuxedo; then
git remote set-url tuxedo https://gitlab.com/tuxedocomputers/development/packages/linux.git
else
git remote add tuxedo https://gitlab.com/tuxedocomputers/development/packages/linux.git
fi
git fetch tuxedo ${TUXEDO_KERNEL_BRANCH_FULL} --tags --prune --force
echo "===Gather version informations.==="
UBUNTU_MAINLINE_VERSION=${MAINLINE_KERNEL_VERSION}.0
NEWEST_TUXEDO_TAG=$(git describe tuxedo/${TUXEDO_KERNEL_BRANCH_FULL} --tags --match "Ubuntu-${TUXEDO_KERNEL_BRANCH}-*" --abbrev=0)
NEWEST_TUXEDO_ABI_AND_BUILD=${NEWEST_TUXEDO_TAG#Ubuntu-"${TUXEDO_KERNEL_BRANCH}"-"${UBUNTU_MAINLINE_VERSION}"-}
NEWEST_TUXEDO_ABI=${NEWEST_TUXEDO_ABI_AND_BUILD%%.*}
NEWEST_TUXEDO_ABI_NUMBER=$((NEWEST_TUXEDO_ABI/1000))
CURRENT_TUXEDO_VERSION_NUMBER=$(grep --perl-regexp --only-matching --max-count 1 "(?<=^linux-${TUXEDO_KERNEL_BRANCH} \().*(?=\))" debian.${TUXEDO_KERNEL_BRANCH}/changelog)
CURRENT_TUXEDO_ABI_AND_BUILD=${CURRENT_TUXEDO_VERSION_NUMBER#"${UBUNTU_MAINLINE_VERSION}"-}
CURRENT_TUXEDO_ABI=${CURRENT_TUXEDO_ABI_AND_BUILD%%.*}
CURRENT_TUXEDO_ABI_NUMBER=$((CURRENT_TUXEDO_ABI/1000))
CURRENT_TUXEDO_BUILD_NUMBER=${CURRENT_TUXEDO_VERSION_NUMBER##*tux}
if [[ "${UBUNTU_KERNEL_BRANCH}" == "master" ]]; then
NEXT_BASE_TAG=$(git describe --tags --match "Ubuntu-${UBUNTU_MAINLINE_VERSION}-*" --abbrev=0)
else
NEXT_BASE_TAG=$(git describe --tags --match "Ubuntu-${UBUNTU_KERNEL_BRANCH}-${UBUNTU_MAINLINE_VERSION}-*" --abbrev=0)
fi
NEXT_BASE_TAG_NUMBER=${UBUNTU_MAINLINE_VERSION}-${NEXT_BASE_TAG##*-"${UBUNTU_MAINLINE_VERSION}"-}
NEXT_BASE_VERSION_NUMBER=${NEXT_BASE_TAG_NUMBER//_/\~}
NEXT_BASE_ABI_AND_BUILD=${NEXT_BASE_VERSION_NUMBER#"${UBUNTU_MAINLINE_VERSION}"-}
NEXT_BASE_ABI_NUMBER=${NEXT_BASE_ABI_AND_BUILD%%.*}
NEXT_BASE_BUILD=${NEXT_BASE_ABI_AND_BUILD#*.}
if [[ ${ABI} ]]; then
NEXT_TUXEDO_ABI_NUMBER=$((NEWEST_TUXEDO_ABI_NUMBER+1))
NEXT_TUXEDO_BUILD_NUMBER=1
elif [[ ${BUILD} ]]; then
NEXT_TUXEDO_ABI_NUMBER=${CURRENT_TUXEDO_ABI_NUMBER}
NEXT_TUXEDO_BUILD_NUMBER=$((CURRENT_TUXEDO_BUILD_NUMBER+1))
else
NEXT_TUXEDO_ABI_NUMBER=${CURRENT_TUXEDO_ABI_NUMBER}
NEXT_TUXEDO_BUILD_NUMBER=1
fi
NEXT_TUXEDO_VERSION_NUMBER=${UBUNTU_MAINLINE_VERSION}-$((NEXT_TUXEDO_ABI_NUMBER*1000+NEXT_BASE_ABI_NUMBER)).${NEXT_BASE_BUILD}tux${NEXT_TUXEDO_BUILD_NUMBER}
NEXT_TUXEDO_TAG_NUMBER=${NEXT_TUXEDO_VERSION_NUMBER//\~/_}
NEXT_TUXEDO_TAG=Ubuntu-${TUXEDO_KERNEL_BRANCH}-${NEXT_TUXEDO_TAG_NUMBER}
echo "===Update changelog.==="
if [[ ${DRY} ]]; then
echo "Dry run. Would execute:"
echo " cp debian.${UBUNTU_KERNEL_BRANCH}/changelog debian/changelog"
echo " gbp dch --new-version=\"${NEXT_TUXEDO_VERSION_NUMBER}\" --release --since \"${NEXT_BASE_TAG}\" --ignore-branch --spawn-editor=never"
echo " if [[ \"$UBUNTU_KERNEL_BRANCH\" == \"master\" ]]; then"
echo " awk --include inplace \"NR!=1{print}NR==1{count+=gsub(\\\"^linux \\\",\\\"linux-${TUXEDO_KERNEL_BRANCH} \\\");print}END{if(count!=1)exit 1}\" debian/changelog"
echo " else"
echo " awk --include inplace \"NR!=1{print}NR==1{count+=gsub(\\\"^linux-${UBUNTU_KERNEL_BRANCH} \\\",\\\"linux-${TUXEDO_KERNEL_BRANCH} \\\");print}END{if(count!=1)exit 1}\" debian/changelog"
echo " fi"
echo " mv debian/changelog debian.${TUXEDO_KERNEL_BRANCH}/changelog"
else
cp debian.${UBUNTU_KERNEL_BRANCH}/changelog debian/changelog
gbp dch --new-version="${NEXT_TUXEDO_VERSION_NUMBER}" --release --since "${NEXT_BASE_TAG}" --ignore-branch --spawn-editor=never
if [[ "$UBUNTU_KERNEL_BRANCH" == "master" ]]; then
awk --include inplace "NR!=1{print}NR==1{count+=gsub(\"^linux \",\"linux-${TUXEDO_KERNEL_BRANCH} \");print}END{if(count!=1)exit 1}" debian/changelog
else
awk --include inplace "NR!=1{print}NR==1{count+=gsub(\"^linux-${UBUNTU_KERNEL_BRANCH} \",\"linux-${TUXEDO_KERNEL_BRANCH} \");print}END{if(count!=1)exit 1}" debian/changelog
fi
mv debian/changelog debian.${TUXEDO_KERNEL_BRANCH}/changelog
fi
echo "===Commit and tag.==="
if [[ ${DRY} ]]; then
echo "Dry run. Would execute:"
echo " git add debian.${TUXEDO_KERNEL_BRANCH}"
echo " git commit --signoff --message \"TUXEDO: ${NEXT_TUXEDO_TAG//_/\~}\" --message \"Gbp-Dch: ignore\""
echo " git tag --sign --message \"${NEXT_TUXEDO_TAG//_/\~}\" \"${NEXT_TUXEDO_TAG}\""
else
git add debian.${TUXEDO_KERNEL_BRANCH}
git commit --signoff --message "TUXEDO: ${NEXT_TUXEDO_TAG//_/\~}" --message "Gbp-Dch: ignore"
git tag --sign --message "${NEXT_TUXEDO_TAG//_/\~}" "${NEXT_TUXEDO_TAG}"
fi
echo "===Done.==="