File mihomo.spec of Package mihomo

%define build_time      `date -u +'%Y-%m-%d'`

Name:           mihomo
Version:        1.19.16
Release:        1
Summary:        The universal proxy platform
License:        GPL-3.0-only
Group:          Productivity/Networking/Web/Proxy
URL:            https://github.com/MetaCubeX/mihomo
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        config.yaml
Source3:        %{name}.service
Source4:        start.sh
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.21
Requires:       bash
Conflicts:      clash-meta

%description
Another Clash Kernel by MetaCubeX, formerly known as Clash.Meta

%prep
%autosetup -a 1

%build
#-mod=readonly 
# -linkmode external 
go build -trimpath -buildmode=pie \
    -ldflags "-s -w \
        -X \"github.com/metacubex/mihomo/constant.Version=v%{version}\" \
        -X \"github.com/metacubex/mihomo/constant.BuildTime=%{build_time}\" " \
    -tags with_gvisor -o %{name}

%install
install -Dm755 %{name} %{buildroot}%{_bindir}/%{name}
install -d %{buildroot}%{_sysconfdir}/%{name}
install -Dm 600 %{S:2} %{buildroot}%{_sysconfdir}/%{name}/config.yaml
install -Dm 644 %{S:3} %{buildroot}%{_unitdir}/%{name}.service
install -Dm 755 %{S:4} %{buildroot}%{_libdir}/%{name}/start

%check
%{buildroot}%{_bindir}/%{name} -v

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%doc README.md
%license LICENSE
%{_bindir}/%{name}
%dir %{_sysconfdir}/%{name}
%config %{_sysconfdir}/%{name}/config.yaml
%{_unitdir}/%{name}.service
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/start

%changelog

openSUSE Build Service is sponsored by