2023-07-19 23:24:10 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-07-20 16:10:26 +02:00
|
|
|
#
|
2019-05-16 12:22:03 +02:00
|
|
|
# This script intends to decrease the effort of updating the package.
|
2023-07-19 23:24:10 +02:00
|
|
|
#
|
|
|
|
# Passing "--autoupdate" as first argument triggers automatic Git operations.
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
set -euo pipefail
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
# Check if running Ubuntu
|
|
|
|
grep -q Ubuntu /etc/issue
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
echo "System is not running Ubuntu. Cancelling build."
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-08 20:24:07 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
PACKAGE="intellij-idea-community"
|
2023-05-02 18:31:56 +02:00
|
|
|
DISTRIBUTION="lunar"
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
last_tag=$(git describe --abbrev=0 --tags)
|
|
|
|
old="${last_tag#?}"
|
2023-07-19 23:24:10 +02:00
|
|
|
|
|
|
|
if [ "$1" = "--autoupdate" ]; then
|
|
|
|
new="$2"
|
2023-07-19 23:40:08 +02:00
|
|
|
autoupdate="y"
|
2023-07-19 23:24:10 +02:00
|
|
|
else
|
|
|
|
new="$1"
|
2023-07-19 23:40:08 +02:00
|
|
|
autoupdate="n"
|
2023-07-19 23:24:10 +02:00
|
|
|
fi
|
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
name="$(git config --get user.name)"
|
|
|
|
email="$(git config --get user.email)"
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
git checkout -b version-"$new"
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
mv "$PACKAGE"_"$old" "$PACKAGE"_"$new"
|
|
|
|
mv "$PACKAGE"_"$old".orig.tar.gz "$PACKAGE"_"$new".orig.tar.gz
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
cd "$PACKAGE"_"$new" || exit
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
# Update the debian/changelog file with dch
|
|
|
|
NAME="$name" EMAIL="$email" dch \
|
|
|
|
--newversion "$new"-1 \
|
|
|
|
--distribution "$DISTRIBUTION" \
|
|
|
|
"Upstream version $new"
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
sed -i "s/$old/$new/g" ./debian/preinst
|
|
|
|
sed -i "s/$old/$new/g" ./debian/postinst
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
debuild -us -uc
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
cd ..
|
2016-10-06 11:11:39 +02:00
|
|
|
|
2022-07-20 16:10:26 +02:00
|
|
|
rm "$PACKAGE"_"$old"-*
|
2023-07-19 23:24:10 +02:00
|
|
|
|
2023-07-19 23:40:08 +02:00
|
|
|
if [ "$autoupdate" = "n" ]; then
|
2023-07-19 23:24:10 +02:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2023-07-19 23:40:42 +02:00
|
|
|
git add -A
|
|
|
|
git commit -m "Upstream version $new"
|
|
|
|
|
2023-07-19 23:24:10 +02:00
|
|
|
git switch main
|
|
|
|
git merge --ff-only version-"$new"
|
|
|
|
git push origin main
|
|
|
|
|
2023-07-19 23:41:08 +02:00
|
|
|
git tag -a v"$new" "Upstream version $new"
|
2023-07-19 23:24:10 +02:00
|
|
|
git push --tags origin main
|