forked from george-hopkins/hsfmodem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnxtmodem.spec.in
413 lines (355 loc) · 11.2 KB
/
cnxtmodem.spec.in
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#
# Copyright (c) 2003-2010 Linuxant inc.
#
# NOTE: The use and distribution of this software is governed by the terms in
# the file LICENSE, which is included in the package. You must read this and
# agree to these terms before using or distributing this software.
#
%if "%{_target_distro}" == "custom"
%define _target_kernel %(eval uname -r)
%endif
# set _target_kernel to generic if it wasn't defined on the command-line
%if %{expand:%{?_target_kernel:0}%{!?_target_kernel:1}}
%define _target_kernel generic
%endif
%if %{expand:%{?_build_doc:0}%{!?_build_doc:1}}
%define _build_doc 0
%endif
%if %{expand:%{?_requires:0}%{!?_requires:1}}
%define _requires none
%endif
%if "%{_target_kernel}" == "generic"
%define ver @CNXTLINUXVERSION@
%define rel @CNXTLINUXRPM_REL@
%define automrecomp 1
%else
%define ver @CNXTLINUXVERSION@_k%(eval echo %{_target_kernel} | sed 's/-/_/g')
%define rel @CNXTLINUXRPM_REL@%{_target_distro}
%define automrecomp 0
%endif
%define cnxtdriver @CNXTDRIVER@
%define cnxtdrvdsc @CNXTDRVDSC@ driver
%define cnxttarget @CNXTTARGET@
%define scr_support @SCR_SUPPORT@
%define dmp_support @DMP_SUPPORT@
%define blam_support @BLAM_SUPPORT@
# Note that this is NOT a relocatable package
%define cnxtetcdir @CNXTETCDIR@
%define cnxtlibdir @CNXTLIBDIR@
# Even though newer versions of RPM provide definitions for these,
# we must still accomodate the older ones
%define prefix /usr
%define etcdir /etc
%define libdir %{prefix}/lib
%define sbindir %{prefix}/sbin
%define bindir %{prefix}/bin
Summary: %{cnxtdrvdsc}
Name: %{cnxttarget}modem
ExclusiveOS: Linux
%if "%{_target_kernel}" == "generic"
%if "%{cnxtdriver}" == "hsf"
ExclusiveArch: athlon i686 i586 i386 x86_64
%endif
%if "%{cnxtdriver}" == "hcf"
%if "%{_target_cpu}" == "ppc"
ExclusiveArch: ppc
%else
ExclusiveArch: athlon i686 i586 i486 i386
%endif
%endif
%else
%if "%{_target_distro}" != "custom"
ExclusiveArch: %{_target_cpu}
%endif
%endif
Version: %ver
Release: %rel
Vendor: Linuxant
License: Copyright (c) 2003-2010 Linuxant inc. All rights reserved.
Group: System Environment/Kernel
Source: %{cnxttarget}modem-@[email protected]
%if %{_build_doc}
Source2: 100498D_RM_HxF_Released.pdf
%endif
URL: http://www.linuxant.com/drivers/%{cnxtdriver}
BuildRoot: %{_tmppath}/%{cnxttarget}modem-%{PACKAGE_VERSION}-root
Packager: Linuxant
Requires: pciutils
%if %{automrecomp}
#Requires: kernel-source
Requires: gcc
%endif
%if "%{cnxtdriver}" == "hsf"
Requires: perl
%endif
%if "%{cnxtdriver}" == "hsf" || "%{cnxtdriver}" == "hcf"
Conflicts: %{cnxtdriver}linmodem
%endif
%if "%{_requires}" != "none"
Requires: %{_requires}
%endif
Autoreq: 0
%if %{_build_doc}
%package doc
Group: Documentation
Summary: Documentation for %{cnxtdrvdsc}
BuildArch: noarch
ExclusiveArch: noarch
%endif
%description
%{cnxtdrvdsc}
@LICENSE_FILE@
%if %{_build_doc}
%description doc
This package contains the documentation for the %{cnxtdrvdsc}.
%endif
%prep
%setup -q -n %{cnxttarget}modem-@CNXTLINUXVERSION@
%build
%if %{_build_doc}
if [ -f %{SOURCE2} ]; then cp %{SOURCE2} .; else true; fi
%else
make --quiet --no-print-directory all
%endif
%if "%{_target_kernel}" == "generic"
%else
MODS_DIR=binaries/linux-%{_target_kernel}
UNAMER=`uname -r`
# Figure out if we should add -SMP at the end of CNXT_MODS_DIR. We should only add it if the
# kernel was compiled with SMP and the word SMP doesn't appear in the kernel version. This
# is expected by dldrconfig.
case "%{_target_kernel}" in
*[Ss][Mm][Pp]*)
SMPSUFFIX=""
;;
*)
SMPSUFFIX="-SMP"
;;
esac
case "%{_target_distro}" in
rh | fdr | fs)
CONFIGFILE="%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel}.%{_target_cpu}/.config"
;;
custom)
CONFIGFILE="/lib/modules/${UNAMER}/build/.config"
;;
*)
CONFIGFILE="%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel}/.config"
;;
esac
if [ -e "${CONFIGFILE}" ] && grep -q '^CONFIG_SMP=y$' "${CONFIGFILE}"; then
MODS_DIR="${MODS_DIR}${SMPSUFFIX}"
fi
%if "%{_target_distro}" == "rh"
(
if cd modules; then
case "%{_target_kernel}" in
*.[Ee][Ll]*)
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel}.%{_target_cpu} DISTRO_CFLAGS="-D__MODULE_KERNEL_%{_target_cpu}=1" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
;;
*)
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="-D__BOOT_KERNEL_H_ -D__BOOT_KERNEL_ENTERPRISE=0 -D__BOOT_KERNEL_SMP=0 -D__BOOT_KERNEL_UP=1 -D__MODULE_KERNEL_%{_target_cpu}=1" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
;;
esac
fi
) || exit $?
%endif
%if "%{_target_distro}" == "fdr"
(
if cd modules; then
case "%{_target_kernel}" in
2.4*)
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="-D__BOOT_KERNEL_H_ -D__BOOT_KERNEL_ENTERPRISE=0 -D__BOOT_KERNEL_SMP=0 -D__BOOT_KERNEL_UP=1 -D__MODULE_KERNEL_%{_target_cpu}=1" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
;;
*)
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel}.%{_target_cpu} DISTRO_CFLAGS="" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
;;
esac
fi
) || exit $?
%endif
%if "%{_target_distro}" == "fs"
(
if cd modules; then
case "%{_target_kernel}" in
2.4*)
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="-D__BOOT_KERNEL_H_ -D__BOOT_KERNEL_ENTERPRISE=0 -D__BOOT_KERNEL_SMP=0 -D__BOOT_KERNEL_UP=1 -D__MODULE_KERNEL_%{_target_cpu}=1" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
;;
*)
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel}.%{_target_cpu} DISTRO_CFLAGS="" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
;;
esac
fi
) || exit $?
%endif
%if "%{_target_distro}" == "mdk"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="-D__BOOT_KERNEL_H_ -D__BOOT_KERNEL_ENTERPRISE=0 -D__BOOT_KERNEL_SMP=0 -D__BOOT_KERNEL_UP=1 -D__MODULE_KERNEL_%{_target_cpu}=1" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%if "%{_target_distro}" == "mdv"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%if "%{_target_distro}" == "suse"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%if "%{_target_distro}" == "jds"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%if "%{_target_distro}" == "turbo"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="-D__BOOT_KERNEL_H_ -D__BOOT_KERNEL_SMP=0 -D__BOOT_KERNEL_SMP64G=0 -D__BOOT_KERNEL_UP=1 -D__BOOT_KERNEL_BOOT=0 -D__MODULE_KERNEL_%{_target_cpu}=1" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%if "%{_target_distro}" == "redflag"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=%{_distro_kernels}/%{_target_distro}/linux-%{_target_kernel} DISTRO_CFLAGS="" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%if "%{_target_distro}" == "custom"
(
if cd modules; then
make --quiet --no-print-directory CNXT_KERNELSRC=/lib/modules/${UNAMER}/build DISTRO_CFLAGS="" CNXT_MODS_DIR="${MODS_DIR}" clean all modules_install || exit $?
fi
) || exit $?
%endif
%endif
%install
rm -rf $RPM_BUILD_ROOT
make --quiet --no-print-directory all
make --quiet --no-print-directory ROOT=$RPM_BUILD_ROOT install
if [ -d $RPM_BUILD_ROOT%{cnxtetcdir}/nvm ]; then
( cd $RPM_BUILD_ROOT%{cnxtetcdir}/nvm && cd .. && tar czf nvm.tar.gz nvm && rm -rf nvm/*)
fi
echo "RPM" > "$RPM_BUILD_ROOT/%{cnxtetcdir}/package"
%if "%{_target_kernel}" != "generic"
find "$RPM_BUILD_ROOT/%{cnxtlibdir}" \( -name '*.[chO]' -o -name 'Makefile' -o -name '*.mak' -o -name '*.sh' \) -exec rm -f {} \;
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(0555, root, root, 755)
%{sbindir}/%{cnxttarget}config
%{sbindir}/%{cnxttarget}stop
%{sbindir}/%{cnxttarget}modconflicts
%{cnxtlibdir}/rc%{cnxttarget}
%if "%{cnxtdriver}" == "hsf" || "%{cnxtdriver}" == "dgc"
%{sbindir}/%{cnxttarget}dcpd
%endif
%if %{scr_support}
%{sbindir}/%{cnxttarget}scr
%{bindir}/qtmodemon
%endif
%if %{dmp_support}
%{sbindir}/%{cnxttarget}dmp
%endif
%if %{blam_support}
%{sbindir}/%{cnxttarget}diag
%endif
%defattr(0444, root, root, 755)
%dir %{cnxtetcdir}
%dir %{cnxtetcdir}/log
%if "%{cnxtdriver}" != "dgc"
%dir %{cnxtetcdir}/nvm
%{cnxtetcdir}/nvm.tar.gz
%endif
%{cnxtetcdir}/package
%dir %{cnxtlibdir}
%doc %{cnxtlibdir}/LICENSE
%dir %{cnxtlibdir}/modules
%dir %{cnxtlibdir}/modules/GPL
%doc %{cnxtlibdir}/modules/GPL/COPYING
%{cnxtlibdir}/modules/binaries
%if %{automrecomp}
%config %{cnxtlibdir}/config.mak
%{cnxtlibdir}/modules/imported
%attr(755, root, root) %{cnxtlibdir}/modules/*.sh
%{cnxtlibdir}/modules/Makefile
%{cnxtlibdir}/modules/*.c
%if "%{cnxtdriver}" != "dgc"
%{cnxtlibdir}/modules/GPL/*.c
%endif
%{cnxtlibdir}/modules/GPL/*.h
%if "%{cnxtdriver}" == "hsf"
%dir %{cnxtlibdir}/modules/GPL/hda
%{cnxtlibdir}/modules/GPL/hda/*.c
%{cnxtlibdir}/modules/GPL/hda/*.h
%{cnxtlibdir}/modules/GPL/hda/Makefile
%endif
%dir %{cnxtlibdir}/modules/include
%{cnxtlibdir}/modules/include/*.h
%endif
%doc BUGS CHANGES INSTALL LICENSE README
%if "%{cnxtdriver}" != "dgc"
%doc FAQ CREDITS
%endif
%pre
if [ "$1" = 1 ]; then
if [ -e "%{cnxtetcdir}" ]; then
echo "Removing old %{cnxtetcdir}"
rm -rf "%{cnxtetcdir}"
fi
if [ -e "%{cnxtlibdir}" ]; then
echo "Removing old %{cnxtlibdir}"
rm -rf "%{cnxtlibdir}"
fi
fi
exit 0
%post
if [ -f %{cnxtetcdir}/nvm.tar.gz ]; then
( cd %{cnxtetcdir} && tar xzf nvm.tar.gz )
fi
#%if ! %{automrecomp}
CNXT_AUTOCONFIG=true
#%endif
if [ -n "${CNXT_AUTOCONFIG}" -a -z "${CNXT_NOAUTOCONFIG}" ]; then
%{sbindir}/%{cnxttarget}config --auto
ret=$?
if [ "${ret}" -eq 123 ]; then
ret=0
fi
if [ "${ret}" -eq 124 -a -n "${CNXT_NOWRONGKERNELFAIL}" ]; then
ret=0
fi
exit ${ret}
else
echo "To complete the installation and configuration of your modem,"
echo "please run \"%{cnxttarget}config\" (or \"%{sbindir}/%{cnxttarget}config\")"
exit 0
fi
%preun
%{sbindir}/%{cnxttarget}stop
if [ "$1" = 0 ]; then
if [ -z "${CNXT_NOAUTOCONFIG}" ]; then
%{sbindir}/%{cnxttarget}config --remove
fi
if [ -f %{cnxtetcdir}/nvm.tar.gz ]; then
( cd %{cnxtetcdir} && rm -rf `tar tzf %{cnxtetcdir}/nvm.tar.gz | egrep '^nvm/[^/]+/?$'` )
fi
else
exit 0
fi
%if %{_build_doc}
%files doc
%doc *.pdf
%endif
# This must be last since the file CHANGES is automatically appended
%changelog