File apk-tools.spec of Package apk-tools

%def_without static

%define bname apk
Name: %bname-tools
Version: 2.5.0
Release: 1
Summary: Alpine Package Keeper - package manager for alpine
Group: System/Packages
License: GPL-2.0
URL: http://git.alpinelinux.org/cgit/%name
Source: http://dev.alpinelinux.org/archive/%name/%name-%version.tar.xz

%if_with static
%define static -static
%else
%define static %nil
%endif

BuildRequires: pkg-config
BuildRequires: zlib-devel%static openssl-devel%static libfetch-devel%static
%{?_with_static:BuildRequires: lua-devel-static >= 5.2}
BuildRequires: pkgconfig(lua) >= 5.2

%description
%summary.


%package -n %bname-lua
Summary: Lua module for %bname
Group: System/Packages
Requires: %name = %version-%release
Requires: lua >= 5.2

%description -n %bname-lua
Lua module for %bname.


%if_with static
%package -n %bname-static
Summary: Alpine Package Keeper - static package manager for alpine
Group: System/Packages

%description -n %bname-static
Alpine Package Keeper - static package manager for alpine.
%endif


%prep
%setup -q
sed -i '/^CFLAGS_ALL/s/ -Werror//' Make.rules
sed -i 's|/usr/lib\(/libfetch.a\)|%_libdir\1|' src/Makefile


%build
cat > config.mk <<__EOF__
FULL_VERSION=%version-%release
LUAAPK=YesPlease
export LUAAPK
__EOF__
export CFLAGS="%optflags"
export LUA_PC=lua
make %{?_smp_mflags} SBINDIR=%_sbindir LIBDIR=%_libdir LUA_LIBDIR=%_libdir/lua/5.2 LIBS="$(pkg-config --libs openssl zlib) -lfetch"
%{?_with_static:make %{?_smp_mflags} SBINDIR=%_sbindir LIBDIR=%_libdir LUA_LIBDIR=%_libdir/lua/5.2 LIBS="$(pkg-config --libs openssl zlib) -lfetch" static}


%install
export CFLAGS="%optflags"
export LUA_PC=lua
%make_install SBINDIR=%_sbindir LIBDIR=%_libdir LUA_LIBDIR=%_libdir/lua/5.2 LIBS="$(pkg-config --libs openssl zlib) -lfetch"

install -d -m 0755 %buildroot{%_var/{lib/%bname,cache/misc},%_sysconfdir/%bname/{keys,protected_paths.d}}
rm -rf %buildroot%_datadir

%{?_with_static:install -p -m 0755 src/%bname.static %buildroot/sbin/}


%files
%defattr(-,root,root)
%_sbindir/%bname
%dir %_var/cache/*
%dir %_var/lib/*
%dir %_sysconfdir/%bname
%dir %_sysconfdir/%bname/*


%files -n %bname-lua
%defattr(-,root,root)
%_libdir/lua/*


%if_with static
%files -n %bname-static
%defattr(-,root,root)
%_sbindir/%bname.static
%endif


%changelog
openSUSE Build Service is sponsored by