Add librpm-tizen.spec file & Debian packaging.
[tools/librpm-tizen.git] / packaging / librpm-tizen.spec
1 # Use custom autoreq script for filtering out all librpm* stuff
2 # (basically everything that the package would auto-provide) in order to make
3 # the package installable
4 %define _use_internal_dependency_generator 0
5 %define __find_requires bash -c "/usr/lib/rpm/find-requires | grep -v librpm"
6
7 %define rpmlibdir %{_prefix}/lib
8 %define rpmhome %{rpmlibdir}/rpm
9
10 Name:           librpm-tizen
11 Summary:        The RPM libraries for git-buildpackage
12 License:        GPL-2.0+
13 Group:          Development/Tools/Building
14 Version:        4.14.1.1.tizen20230628
15 Release:        0
16 Url:            http://www.rpm.org
17 BuildRequires:  binutils
18 BuildRequires:  bzip2
19 BuildRequires:  file-devel
20 BuildRequires:  findutils
21 BuildRequires:  gcc
22 BuildRequires:  glibc-devel
23 BuildRequires:  gzip
24 BuildRequires:  libacl-devel
25 BuildRequires:  pkgconfig(libcap)
26 BuildRequires:  libelf-devel
27 BuildRequires:  libtool
28 %if 0%{?suse_version}
29 BuildRequires:  pkgconfig(lua)
30 %else
31 BuildRequires:  lua-devel
32 %endif
33 BuildRequires:  make
34 BuildRequires:  pkgconfig(ncurses)
35 BuildRequires:  patch
36 %if 0%{?fedora} || 0%{?centos_ver} || 0%{?centos_version}
37 BuildRequires:  popt-devel
38 %else
39 BuildRequires:  pkgconfig(popt)
40 %endif
41 BuildRequires:  pkgconfig(zlib)
42 BuildRequires:  pkgconfig(nss)
43 BuildRequires:  pkg-config
44 %if 0%{?centos_ver} || 0%{?centos_version}
45 BuildRequires:  python-devel
46 %else
47 BuildRequires:  pkgconfig(python3)
48 %endif
49 # Disable security
50 %if 0
51 BuildRequires:  uthash-devel
52 BuildRequires:  pkgconfig(libxml-2.0)
53 BuildRequires:  pkgconfig(libsmack)
54 %endif
55 BuildRequires:  libarchive-devel
56 %if 0%{?suse_version}
57 BuildRequires:  fdupes
58 %endif
59 %if 0%{?fedora} || 0%{?centos_ver} >= 7
60 BuildRequires:  libdb-devel
61 %else
62 BuildRequires:  db-devel
63 %endif
64 BuildRequires:  pkgconfig(libzstd)
65
66 Source4:       rpm-tizen_macros
67 Source8:       rpmconfigcheck
68 Source13:      find-docs.sh
69 Source22:      device-sec-policy
70 Source23:      find-provides.ksyms
71 Source1001:    rpm.manifest
72 Source0:       rpm-%{version}.tar.gz
73 AutoProv:      No
74
75 Provides:      rpm-tizen = %{version}-tizen20230628
76 #
77 # avoid bootstrapping problem
78 %define _binary_payload w9.bzdio
79 #
80 # Python module name
81 %define python_mod_name rpm_tizen
82
83 %description
84 RPM Package Manager is the main tool for managing the software packages
85 of Tizen.
86
87 RPM can be used to install and remove software packages. With rpm, it
88 is easy to update packages.  RPM keeps track of all these manipulations
89 in a central database.  This way it is possible to get an overview of
90 all installed packages.  RPM also supports database queries.
91
92 This is a special stripped-down version of RPM, only intended to be used by the
93 git-buildpackage tool. This package doesn't interfere with the RPM libraries of
94 the host system and it only contains rpmlib and rpm-python.
95
96 %prep
97 %setup -q -n rpm-%{version}
98 cp %{SOURCE1001} .
99 rm -rf sqlite
100 if [ -s %{_sysconfdir}/rpm/tizen_macros ]; then
101     cp -a %{_sysconfdir}/rpm/tizen_macros %{SOURCE4}
102 fi
103 cp -a %{SOURCE4} tizen_macros
104 rm -f m4/libtool.m4
105 rm -f m4/lt*.m4
106
107 %build
108 CPPFLAGS="$CPPFLAGS `pkg-config --cflags nss`"
109 export CPPFLAGS
110 export CFLAGS="%{optflags} -ffunction-sections -fstack-protector-strong -Wl,-z,relro -D_FORTIFY_SOURCE=2 -fPIE"
111 export LDFLAGS="${LDFLAGS} -pie -Wl,-Bsymbolic-functions -ffunction-sections"
112 %ifarch armv5tel
113 export CFLAGS="-g -O0 -fno-strict-aliasing -ffunction-sections"
114 %endif
115
116 %{?hwasan_build:
117 export CPPFLAGS="$CPPFLAGS -DHWASAN_BUILD"
118 }
119
120 autoreconf -i -f
121
122 %configure \
123     --libdir=%{_libdir}/%{name} \
124     --disable-dependency-tracking \
125     --with-lua \
126     --with-acl \
127     --with-cap \
128     --enable-shared \
129     --enable-python \
130     --with-vendor=tizen \
131     --without-msm \
132     --enable-zstd \
133     --with-external-db \
134     PYTHON_MODULENAME=%{python_mod_name}
135
136 make %{?_smp_mflags}
137
138 %install
139 # Install into a temporary location
140 make install DESTDIR="`pwd`/tmp_install"
141
142 # And only copy the files that we want
143 install -d %{buildroot}%{_libdir}/%{name}
144 install -d %{buildroot}%{python3_sitearch}
145 cp -ax tmp_install/%{_libdir}/%{name}  %{buildroot}%{_libdir}/
146 cp -ax tmp_install/%{python3_sitearch}/%{python_mod_name} %{buildroot}%{python3_sitearch}/
147
148 # Install extra sources
149 install -m644 %{SOURCE4} %{buildroot}%{_libdir}/%{name}/rpm/tizen_macros
150 install -d %{buildroot}%{_libdir}/%{name}/rpm/tizen
151 ln -s ../tizen_macros %{buildroot}%{_libdir}/%{name}/rpm/tizen/macros
152
153 # Delete unwanted development files etc.
154 find %{buildroot} -name "*.la" | xargs rm -f --
155 find %{buildroot}/%{_libdir}/%{name} -name "*.so" | xargs rm -f --
156 rm -rf "%{buildroot}%{_libdir}/%{name}/pkgconfig"
157 rm -rf "%{buildroot}%{_libdir}/%{name}/rpm-plugins"
158
159 # Compile python modules (Fedora does this automatically) and find duplicates
160 %if 0%{?suse_version}
161 %py3_compile %{buildroot}/%{python3_sitearch}/%{python_mod_name}/
162 %py3_compile -O %{buildroot}/%{python3_sitearch}/%{python_mod_name}/
163
164 %fdupes %{buildroot}/%{python3_sitearch}/
165 %endif
166
167 %files
168 %defattr(-,root,root,-)
169 %dir %{_libdir}/%{name}
170 %dir %{python3_sitearch}/%{python_mod_name}/
171 %{_libdir}/%{name}/*.so.*
172 %{_libdir}/%{name}/rpm
173 %{python3_sitearch}/%{python_mod_name}/*