mirror of
https://abf.rosa.ru/djam/glibc.git
synced 2025-02-23 15:02:47 +00:00
53 lines
1.8 KiB
Bash
Executable file
53 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -efu
|
|
set -o pipefail
|
|
|
|
# get current commit (version)
|
|
old_commit="$(grep '^%define commit ' glibc.spec | awk '{print $NF}')"
|
|
[ -n "$old_commit" ]
|
|
# or: rpmspec --define "_sourcedir $PWD" -q --srpm --qf '%{version}' glibc.spec
|
|
version="$(grep '^Version:' glibc.spec | awk '{print $NF}')"
|
|
[ -n "$version" ]
|
|
|
|
# get latest available commit (version)
|
|
new_commit="$(git ls-remote git://sourceware.org/git/glibc.git release/2.33/master | awk '{print $1}')"
|
|
[ -n "$new_commit" ]
|
|
if [ "$old_commit" = "$new_commit" ]; then
|
|
echo "There are no updates"
|
|
exit 0
|
|
fi
|
|
|
|
tmp="$(mktemp -d)"
|
|
trap 'rm -fr "$tmp"' EXIT
|
|
|
|
# download the latest version
|
|
git clone --depth=1 https://sourceware.org/git/glibc.git -b release/"$version"/master "$tmp"/glibc-"$new_commit"
|
|
if [ "$(cd "$tmp"/glibc-"$new_commit" && git rev-parse HEAD)" != "$new_commit" ]; then
|
|
echo "Repository has probably changed in the middle, rerun this script"
|
|
exit 1
|
|
fi
|
|
|
|
# pack it
|
|
XZ_OPT="-6 --threads=0 -v" tar cJf glibc-"$new_commit".tar.xz -C "$tmp" glibc-"$new_commit"
|
|
|
|
# Bump RPM release
|
|
# 3.git%{commit_short}.1 -> 4.git%{commit_short}.1
|
|
# 3.git%{commit_short}.2 -> 4.git%{commit_short}.1
|
|
old_release="$(grep '^Release:' glibc.spec | awk '{print $NF}')"
|
|
[ -n "$old_release" ]
|
|
IFS=. read -r -a release <<< "$old_release"
|
|
# increase first number
|
|
num1=$((${release[0]}+1))
|
|
# decrease last number to 1
|
|
num2=1
|
|
new_release="${num1}.${release[1]}.${num2}"
|
|
sed -i'' -E glibc.spec \
|
|
-e "s,^%define commit .+,%define commit ${new_commit}," \
|
|
-e "s,^Release:.+,Release:\t${new_release},"
|
|
# upload glibc-$new_commit.tar.xz to file-store.rosalinux.ru
|
|
abf put -n
|
|
sed -i'' .abf.yml -e "/^ glibc-${old_commit}/d"
|
|
PAGER= GIT_PAGER= git diff
|
|
# copypastable commit message
|
|
echo "upd to snapshot $(echo "$new_commit" | head -c5) of v$version"
|