File apx.spec of Package apx
#
# spec file for package apx
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: apx
Version: 2.4.5
Release: 0
Summary: Package manager with support for multiple sources
License: GPL-3.0-only
URL: https://github.com/Vanilla-OS/apx
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
Source2: vanilla-apx-configs.tar.zst
BuildRequires: bash-completion
BuildRequires: fish
BuildRequires: go >= 1.22
BuildRequires: zsh
BuildRequires: podman
BuildRequires: distrobox
Requires: distrobox
Requires: (podman or docker)
%description
Apx (/à·peks/) is the default package manager in Vanilla OS. It is a wrapper
around multiple package managers to install packages and run commands inside a
managed container.
%package -n %{name}-bash-completion
Summary: Bash Completion for %{name}
Group: System/Shells
Requires: %{name} = %{version}
Requires: bash-completion
Supplements: (%{name} and bash-completion)
BuildArch: noarch
%description -n %{name}-bash-completion
Bash command line completion support for %{name}.
%package -n %{name}-fish-completion
Summary: Fish Completion for %{name}
Group: System/Shells
Requires: %{name} = %{version}
Supplements: (%{name} and fish)
BuildArch: noarch
%description -n %{name}-fish-completion
Fish command line completion support for %{name}.
%package -n %{name}-zsh-completion
Summary: Zsh Completion for %{name}
Group: System/Shells
Requires: %{name} = %{version}
Supplements: (%{name} and zsh)
BuildArch: noarch
%description -n %{name}-zsh-completion
zsh command line completion support for %{name}.
%prep
%autosetup -p 1 -a 1
tar xvf %{SOURCE2}
%build
sed -i '/^var Version/ s/development/v%{version}/' main.go
go build \
-mod=vendor \
-buildmode=pie \
-tags netgo \
-o bin/%{name}
%install
# Install the binary.
install -D -m 0755 bin/%{name} %{buildroot}/%{_bindir}/%{name}
# configuration in /etc/apx/
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{name}/
# configuration in /usr/share/apx/
install -d -m 0755 %{buildroot}%{_datadir}/%{name}/
install -d -m 0755 %{buildroot}%{_datadir}/%{name}/distrobox/
install -D -m 0644 config/apx.json %{buildroot}%{_datadir}/%{name}/%{name}.json
sed -i 's|/usr/share/apx/distrobox/distrobox|/usr/bin/distrobox|' %{buildroot}%{_datadir}/%{name}/%{name}.json
# system-wide configuration
install -d -m 0755 %{buildroot}%{_datadir}/%{name}/package-managers/
install -D -m 0644 vanilla-apx-configs/package-managers/* %{buildroot}%{_datadir}/%{name}/package-managers/
install -d -m 0755 %{buildroot}%{_datadir}/%{name}/stacks/
install -D -m 0644 vanilla-apx-configs/stacks/* %{buildroot}%{_datadir}/%{name}/stacks/
# avoid errors when creating the completion files
mkdir -p ~/.config
touch ~/.config/apx
# workaround for Leap 15.x
# https://github.com/Vanilla-OS/apx/issues/424
export LANG=C.UTF-8
# create the bash completion file
mkdir -p %{buildroot}%{_datarootdir}/bash-completion/completions/
%{buildroot}/%{_bindir}/%{name} completion bash > %{buildroot}%{_datarootdir}/bash-completion/completions/%{name}
# create the fish completion file
mkdir -p %{buildroot}%{_datarootdir}/fish/vendor_completions.d/
%{buildroot}/%{_bindir}/%{name} completion fish > %{buildroot}%{_datarootdir}/fish/vendor_completions.d/%{name}.fish
# create the zsh completion file
mkdir -p %{buildroot}%{_datarootdir}/zsh/site-functions/
%{buildroot}/%{_bindir}/%{name} completion zsh > %{buildroot}%{_datarootdir}/zsh/site-functions/_%{name}
# manpages
install -d -m 0755 %{buildroot}%{_mandir}/man1/
install -D -m 0644 man/man1/* %{buildroot}%{_mandir}/man1/
%files
%doc README.md
%license COPYING.md
%{_bindir}/%{name}
%dir %{_sysconfdir}/%{name}
%ghost %config(noreplace) %{_sysconfdir}/%{name}/%{name}.json
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/%{name}.json
%{_datadir}/%{name}/package-managers/
%{_datadir}/%{name}/stacks/
%{_mandir}/man1/*
%files -n %{name}-bash-completion
%{_datarootdir}/bash-completion/completions/%{name}
%files -n %{name}-fish-completion
%{_datarootdir}/fish/vendor_completions.d/%{name}.fish
%files -n %{name}-zsh-completion
%{_datarootdir}/zsh/site-functions/_%{name}
%changelog