pretiffy package, automate updating

This commit is contained in:
Mikhail Novosyolov 2024-08-09 00:41:25 +03:00
parent 12b1bf87d3
commit 0103c0c02a
3 changed files with 70 additions and 14 deletions

View file

@ -1,3 +1,3 @@
sources:
spoofdpi-0.10.6-go-mod-vendor.tar.xz: b8fa625ca82ef9a46dd6fd737d4d9cd71389f1fe
spoofdpi-0.10.6.tar.gz: 7b2f2163102b6ac23cfb55eea37629cd9873e0e9
vendor.tar.gz: 21ce99a98eb6b6b8ad97fb7a62a38c26aca77432

View file

@ -1,26 +1,29 @@
%global oname SpoofDPI
%global debug_package %nil
%global gomodulesmode %nil
# use bundled golang modules (from Source1)
%global gomodulesmode GO111MODULE=off
%global goipath github.com/xvzc/SpoofDPI
Summary: A simple and fast software designed to bypass Deep Packet Inspection
Name: spoofdpi
Version: 0.10.6
Release: 2
Release: 1
License: Apache-2.0
Group: Networking/Other
Url: https://github.com/xvzc/SpoofDPI
Source0: https://github.com/xvzc/SpoofDPI/archive/refs/tags/v%{version}.tar.gz?/%{name}-%{version}.tar.gz
Source1: spoof-dpi.service
# use 'go mod vendor' command and archive vendor directory
Source2: vendor.tar.gz
# created by ./upd.sh
Source2: spoofdpi-%{version}-go-mod-vendor.tar.xz
BuildRequires: golang
Provides: SpoofDPI = %{EVRD}
Provides: spoof-dpi = %{EVRD}
%gometa
%description
A simple and fast software designed to bypass Deep Packet Inspection
%files
%license LICENSE*
%doc *.md
%{_bindir}/spoof-dpi
%{_userunitdir}/spoof-dpi.service
@ -33,17 +36,16 @@ A simple and fast software designed to bypass Deep Packet Inspection
#----------------------------------------------------------------------------
%prep
%autosetup -p1 -n %{oname}-%{version} -a2
%goprep
%autopatch -p1
tar -C .. -xf %{SOURCE2}
%build
mkdir -p src/github.com/xvzc
ln -s ../../../ src/github.com/xvzc/SpoofDPI
export GOPATH=$(pwd):%{gopath}
%gobuild -o ./bin/spoof-dpi ./cmd/spoof-dpi
%gobuild -o %{gobuilddir}/bin/spoof-dpi %{goipath}/cmd/spoof-dpi
%install
install -d %{buildroot}/%{_bindir}/
install -m 0755 bin/spoof-dpi %{buildroot}/%{_bindir}/
install -m 0755 %{gobuilddir}/bin/spoof-dpi %{buildroot}/%{_bindir}/
install -d %{buildroot}/%{_userunitdir}
install -m 0644 %{SOURCE1} %{buildroot}/%{_userunitdir}

54
upd.sh Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Script to partly automate updating this package
# Based on upd.sh from abf.io/import/ha_cluster_exporter
# sudo dnf install /usr/bin/rpmbuild /usr/bin/spectool /usr/bin/rpmspec /usr/bin/git /usr/bin/curl /usr/bin/abf /usr/bin/jq /usr/bin/sed /usr/bin/tar /usr/bin/xz
set -x
set -e
set -f
set -u
spec="$PWD"/spoofdpi.spec
dir0="$PWD"
old_version="$(rpmspec -q --srpm --qf '%{version}' "$spec")"
latest_version="$(curl --silent "https://api.github.com/repos/xvzc/SpoofDPI/releases/latest" | jq '.tag_name' | sed -e 's,",,g' -e 's,^v,,')"
[ -n "$latest_version" ]
if [ "$old_version" = "$latest_version" ]; then
echo "No updates"
exit 0
fi
sed -E -i'' "$spec" \
-e "s,^Version:.+,Version:\t${latest_version}," \
-e "s,^Release:.+,Release:\t1," \
--
source0="$(rpmspec --parse "$spec" | grep -i ^Source0: | awk -F '/' '{print $NF}')"
spectool --get-files --source 0 "$spec"
[ -f "$source0" ]
patches_ok=0
tmp="$(mktemp --tmpdir=/tmp -d)"
trap 'if [ "$patches_ok" = 1 ]; then rm -fr "$tmp"; fi' EXIT
pushd "$tmp"
tar -xf "$dir0"/"$source0"
pushd SpoofDPI-"$latest_version"
go mod vendor
popd
XZ_OPT="-T0 -v" tar cJf spoofdpi-"$latest_version"-go-mod-vendor.tar.xz SpoofDPI-"$latest_version"/vendor
mv spoofdpi-"$latest_version"-go-mod-vendor.tar.xz "$dir0"
popd
rm -f .abf.yml
abf put -n
# check appliability of patches
rpmbuild --define "_sourcedir $PWD" --define "_builddir $tmp" -bp "$spec" && patches_ok=1
PAGER='' git diff
# can be copypasted for a commit message
echo "upd: $old_version -> $latest_version"
if [ "$patches_ok" = 0 ]; then
echo "PATCHES require attention!"
fi