summaryrefslogtreecommitdiffstats
path: root/t/data/SPECS/ordering-scriptlets/a_1.spec
blob: 749df99b2dfde461c97118aceb9d93f7cd98a708 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# fix warnings:
%define debug_package %{nil}

Summary: x
Name: a
Version: 1
Release: 1
License: x
Provides: /bin/a
#BuildRequires: gcc
# Fix testsuite on eg: mga2 if static build fails and libc got included:
Provides: rtld(GNU_HASH)
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^libc.so|^ld
%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}^libc.so|^ld

%prep
%setup -c -T
# This is a simple static "shell" for scriptlets.
# Thus it must be w/o deps (static) or with self contained deps (included):
cat <<EOF > a.c 
#include <stdio.h>
int main(int argc, char **argv) { 
   FILE *f = fopen(argv[1], "r");
   int c; 
   while ((c = getc(f)) > 0) putchar(c); 
   putchar('\n');
   return 0;
}
EOF

%build
# Try a static build with fallback to dynamic if no static libs/headers
# (in which case we will pull the the wanted libs in %%install):
cc -Wall -static -o a a.c || cc -Wall -o a a.c

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/bin/
cp a $RPM_BUILD_ROOT/bin/a

# Install the wanted libs if not static:
ldd a | sed -e 's/^[ \t]*//' -e 's/.* => //' -e 's/ .*//' > list
grep '/' list | (cd / ; cpio -pumdL %buildroot)
find %buildroot

%clean
rm -rf $RPM_BUILD_ROOT

%description
x

%files
%defattr(-,root,root)
/*