1 | #!/@unixroot/usr/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Helper script for %legacy_runtime_packages macro. This macro allows to
|
---|
5 | # automatically create legacy sub-packages with runtime components needed for
|
---|
6 | # compatibility with legacy applications.
|
---|
7 | #
|
---|
8 | # This script assumes the following drectory layout:
|
---|
9 | #
|
---|
10 | # RPM_SOURCE_DIR/PACKAGE-legacy
|
---|
11 | # ABI_X
|
---|
12 | # ARCH_X
|
---|
13 | # FILES
|
---|
14 | # ARCH_X.list
|
---|
15 | # ARCH_X.files.list
|
---|
16 | # ARCH_X.dbugfiles.list
|
---|
17 | # ARCH_Y
|
---|
18 | # FILES
|
---|
19 | # ARCH_Y.list
|
---|
20 | # ARCH_Y.files.list
|
---|
21 | # ARCH_Y.dbugfiles.list
|
---|
22 | # ...
|
---|
23 | # ABI_Y
|
---|
24 | # ...
|
---|
25 | # abi.list
|
---|
26 | #
|
---|
27 | # where PACKAGE is the main package name, ABI_* is the ABI version of the legacy
|
---|
28 | # runtime, ARCH_* is a target platform for which this runtime was compiled and
|
---|
29 | # FILES is a list of runtime components to install. ARCH_*.list is an index
|
---|
30 | # file that contains a line `TS|RPM|NAME|VER` where TS is the timestamp of the
|
---|
31 | # RPM file where FILES are extracted from, NAME is the name of the respective
|
---|
32 | # (sub-)package and VER is its full version. ARCH_*.files.list is a list of all
|
---|
33 | # FILES to include (one per line). ARCH_*.debugfiles.list is a list of
|
---|
34 | # respective debug info files. The abi.list file contains a space-separated list
|
---|
35 | # of all ABI_* values to create legacy packages for. If the PACKAGE's target
|
---|
36 | # platform matches one of ARCH_* values, then the respective set of files is
|
---|
37 | # placed to a sub-package called ABI_*, otherwise the first ARCH_* (in FS order)
|
---|
38 | # will be picked up.
|
---|
39 | #
|
---|
40 | # The %legacy_runtime_packages macro, when instantiated in a PACKAGE.spec file,
|
---|
41 | # will cause rpmbuild to automatically generate the given number of legacy
|
---|
42 | # sub-packages as described above. These sub-packages will have Priovides set
|
---|
43 | # to NAME = VER and Obsoletes to NAME <= VER so that they will be picked up
|
---|
44 | # by the dependency resolver for legacy applications that still depend on a
|
---|
45 | # NAME = VER package and also they will replace an existing installation of
|
---|
46 | # NAME = VER (this only makes sense for casese when NAME, i.e. the old runmtime
|
---|
47 | # package name, doesn't match the PACKAGE's main name and there are no
|
---|
48 | # explicit dependencies between them set with Requires).
|
---|
49 | #
|
---|
50 | # The above layout is nomrally created by the rpmbuild-bot.sh script (see
|
---|
51 | # http://trac.netlabs.org/rpm/browser/rpmbuild-bot) by pulling the respective
|
---|
52 | # components from older RPM files but may be also created by hand if needed.
|
---|
53 | #
|
---|
54 |
|
---|
55 | COMMAND="$1"
|
---|
56 |
|
---|
57 | die()
|
---|
58 | {
|
---|
59 | (>&2 echo "$0: ERROR: $1")
|
---|
60 | exit 1
|
---|
61 | }
|
---|
62 |
|
---|
63 | if [ "$COMMAND" = "package" ] ; then
|
---|
64 | RPM_PACKAGE_NAME="$2"
|
---|
65 | RPM_SOURCE_DIR="$3"
|
---|
66 | RPM_TARGET_CPU="$4"
|
---|
67 | RPM_BUILD_ROOT="$5"
|
---|
68 | elif [ "$COMMAND" = "install" ] ; then
|
---|
69 | RPM_TARGET_CPU="$2"
|
---|
70 | RPM_BUILD_SUBDIR="$3"
|
---|
71 | else
|
---|
72 | die "Command '$COMMAND' is invalid."
|
---|
73 | fi
|
---|
74 |
|
---|
75 | [ -z "$RPM_PACKAGE_NAME" -o -z "$RPM_SOURCE_DIR" -o -z "$RPM_TARGET_CPU" -o -z "$RPM_BUILD_ROOT" ] && \
|
---|
76 | die "Invalid environment/arguments ($*)."
|
---|
77 |
|
---|
78 | abi_base="$RPM_SOURCE_DIR/$RPM_PACKAGE_NAME-legacy"
|
---|
79 |
|
---|
80 | read abi_list < "$abi_base/abi.list"
|
---|
81 | [ -n "$abi_list" ] || die "Legacy ABI versions are not found."
|
---|
82 |
|
---|
83 | for abi in $abi_list ; do
|
---|
84 | #locate the RPM list file for the given arch
|
---|
85 | rpm_list="$abi_base/$abi/$RPM_TARGET_CPU.list"
|
---|
86 | if [ ! -f "$rpm_list" ] ; then
|
---|
87 | # try to use the first found arch when no exact match
|
---|
88 | read -r arch <<EOF
|
---|
89 | `find "$abi_base/$abi" -mindepth 1 -maxdepth 1 -type d`
|
---|
90 | EOF
|
---|
91 | [ -n "$arch" ] && rpm_list="$arch.list"
|
---|
92 | fi
|
---|
93 | # get properties
|
---|
94 | IFS='|' read ts rpm name ver < "$rpm_list"
|
---|
95 | [ -z "$name" -o -z "$ver" ] && die "Name or version field is missing in $rpm_list."
|
---|
96 | # get the file list
|
---|
97 | filesdir="${rpm_list%.list}"
|
---|
98 | fileslist="${rpm_list%.list}.files.list"
|
---|
99 | [ -f "$fileslist" ] || die "File $fileslist not found."
|
---|
100 | # process commands
|
---|
101 | if [ "$COMMAND" = "package" ] ; then
|
---|
102 | echo "
|
---|
103 | %package legacy-$abi
|
---|
104 |
|
---|
105 | Version: ${ver%%-*}
|
---|
106 | Release: ${ver#*-}%{?dist}
|
---|
107 | Provides: $name = $ver
|
---|
108 | Obsoletes: $name <= $ver
|
---|
109 |
|
---|
110 | Summary: Legacy runtime components (ABI version $abi).
|
---|
111 |
|
---|
112 | %description legacy-$abi
|
---|
113 | This package contains runtime components for ABI version $abi.
|
---|
114 | It is provided for compatibility with legacy applications.
|
---|
115 |
|
---|
116 | %files legacy-$abi
|
---|
117 | %defattr(-,root,root)
|
---|
118 | `cat "$fileslist"`
|
---|
119 |
|
---|
120 | "
|
---|
121 | else # install
|
---|
122 | [ -z "$RPM_BUILD_SUBDIR" ] && die "RPM_BUILD_SUBDIR is not set."
|
---|
123 | # Copy all listed files to RPM_BUILD_ROOT
|
---|
124 | while read -r f ; do
|
---|
125 | [ -f "$RPM_BUILD_ROOT$f" ] && die "File $RPM_BUILD_ROOT$f already exists."
|
---|
126 | cp -p "$filesdir$f" "$RPM_BUILD_ROOT$f" || die "Copying $filesdir$f to $RPM_BUILD_ROOT$f failed."
|
---|
127 | done < "$fileslist"
|
---|
128 | # Now, if there are debug files, copy them too and append to debugfiles.list
|
---|
129 | # (to be picked up by %debug_package magic in brp-strip.os2)
|
---|
130 | dbgfilelist="${rpm_list%.list}.debugfiles.list"
|
---|
131 | if [ -f "$dbgfilelist" ] ; then
|
---|
132 | while read -r f ; do
|
---|
133 | [ -f "$RPM_BUILD_ROOT$f" ] && die "File $RPM_BUILD_ROOT$f already exists."
|
---|
134 | cp -p "$filesdir$f" "$RPM_BUILD_ROOT$f" || die "Copying $filesdir$f to $RPM_BUILD_ROOT$f failed."
|
---|
135 | done < "$dbgfilelist"
|
---|
136 | cat "$dbgfilelist" >> "$RPM_BUILD_SUBDIR/debugfiles.list"
|
---|
137 | fi
|
---|
138 | fi
|
---|
139 | done
|
---|
140 |
|
---|
141 | exit 0
|
---|