# Generated by go2rpm 1.16.0
%bcond check 1
%bcond bootstrap 0

# https://github.com/evilsocket/opensnitch
%global goipath         github.com/evilsocket/opensnitch
Version:                1.8.0

%gometa -f

%global common_description %{expand:
OpenSnitch is a GNU/Linux interactive application firewall inspired by Little
Snitch.}

%global golicenses      LICENSE ui/LICENSE\\\
                        ui/opensnitch/res/themes/dark/icons/LICENSE
%global godocs          README.md ebpf_prog/README ui/requirements.txt\\\
                        ui/i18n/README.md example example example\\\
                        utils/packaging/daemon/deb/debian/changelog\\\
                        utils/packaging/ui/deb/debian/changelog

Name:           opensnitch
Release:        1%{?dist}
Summary:        OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch

License:        GPL-3.0-only AND LGPL-2.1-or-later
URL:            %{gourl}
Source:         %{gosource}
BuildRequires:  gcc-c++
BuildRequires:  python3-devel
BuildRequires:  python-rpm-macros
BuildRequires:  python3dist(pip)
BuildRequires:  python3dist(setuptools) >= 61.0
BuildRequires:  python3dist(wheel) >= 0.37.1
BuildRequires:  python3dist(pyqt5)
BuildRequires:  /usr/bin/lrelease-qt5
BuildRequires:  protobuf-compiler
BuildRequires:  pkgconfig(libnetfilter_queue)
BuildRequires:  qt6-linguist

%description %{common_description}

%gopkg


%prep
%goprep -A

export GOBIN=$(go env GOPATH | sed -E 's/:.+$//')/bin
echo $GOBIN > %_builddir/gobin
go install github.com/golang/protobuf/protoc-gen-go@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0

sed -i 's/@pip3 /@python3 -m pip /' ui/Makefile

%build
pushd ui
%make_build deps
popd

export GOBIN=$(cat %_builddir/gobin)
export PATH=$GOBIN:$PATH
pushd proto
%make_build
popd

pushd ui
%make_build
%pyproject_wheel
popd

%global gomodulesmode GO111MODULE=on
pushd daemon
%gobuild -o ../opensnitchd .
popd


%install
%gopkginstall
install -Dm755 opensnitchd -t %buildroot%_bindir

pushd ui
%pyproject_install
%pyproject_save_files %name
popd

rm -rf %buildroot%python3_sitelib/tests/
cp -r %buildroot%python3_sitelib%_usr/ %buildroot%_usr/ --preserve=all --no-target-directory
rm -rf %buildroot%python3_sitelib%_usr

%files -f %{pyproject_files}
%license LICENSE
%doc README.md
%_bindir/opensnitch-ui
%_bindir/opensnitchd
%_datadir/applications/opensnitch_ui.desktop
%_iconsdir/hicolor/48x48/apps/opensnitch-ui.png
%_iconsdir/hicolor/64x64/apps/opensnitch-ui.png
%_iconsdir/hicolor/scalable/apps/opensnitch-ui.svg
%_datadir/kservices5/kcm_opensnitch.desktop
%_metainfodir/io.github.evilsocket.opensnitch.appdata.xml
%_scalableiconsdir/opensnitch-ui.svg

%gopkgfiles

%changelog
* Mon Mar 16 2026 Owen Zimmerman <owen@fyralabs.com>
- Fix build, clean up spec
