| 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 (see rpmbuild-bot.sh)
|
|---|
| 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 | # Note: we have to store original Version and Release tag values in
|
|---|
| 103 | # %main_version and %main_release for later use since we redefine them
|
|---|
| 104 | # within %package and there is a bug in RPM that makes it permanent, see
|
|---|
| 105 | # https://www.redhat.com/archives/rpm-list/2000-October/msg00218.html)
|
|---|
| 106 | echo "
|
|---|
| 107 |
|
|---|
| 108 | %global main_version %version
|
|---|
| 109 | %global main_release %release
|
|---|
| 110 |
|
|---|
| 111 | %package legacy-$abi
|
|---|
| 112 |
|
|---|
| 113 | Version: ${ver%%-*}
|
|---|
| 114 | Release: ${ver#*-}
|
|---|
| 115 | Provides: $name = $ver
|
|---|
| 116 | Obsoletes: $name < $ver
|
|---|
| 117 |
|
|---|
| 118 | Summary: Legacy runtime components (ABI version $abi).
|
|---|
| 119 |
|
|---|
| 120 | %description legacy-$abi
|
|---|
| 121 | This package contains runtime components for ABI version $abi.
|
|---|
| 122 | It is provided for compatibility with legacy applications.
|
|---|
| 123 |
|
|---|
| 124 | %files legacy-$abi
|
|---|
| 125 | %defattr(-,root,root)
|
|---|
| 126 | `cat "$fileslist"`
|
|---|
| 127 |
|
|---|
| 128 | "
|
|---|
| 129 | #Requires: $name = %{main_version}-%{main_release}%{?dist}
|
|---|
| 130 | else # install
|
|---|
| 131 | [ -z "$RPM_BUILD_SUBDIR" ] && die "RPM_BUILD_SUBDIR is not set."
|
|---|
| 132 | # Copy all listed files to RPM_BUILD_ROOT
|
|---|
| 133 | while read -r f ; do
|
|---|
| 134 | [ -f "$RPM_BUILD_ROOT$f" ] && die "File $RPM_BUILD_ROOT$f already exists."
|
|---|
| 135 | cp -p "$filesdir$f" "$RPM_BUILD_ROOT$f" || die "Copying $filesdir$f to $RPM_BUILD_ROOT$f failed."
|
|---|
| 136 | done < "$fileslist"
|
|---|
| 137 | # Now, if there are debug files, copy them too and append to debugfiles.list
|
|---|
| 138 | # (to be picked up by %debug_package magic in brp-strip.os2)
|
|---|
| 139 | dbgfilelist="${rpm_list%.list}.debugfiles.list"
|
|---|
| 140 | if [ -f "$dbgfilelist" ] ; then
|
|---|
| 141 | while read -r f ; do
|
|---|
| 142 | [ -f "$RPM_BUILD_ROOT$f" ] && die "File $RPM_BUILD_ROOT$f already exists."
|
|---|
| 143 | cp -p "$filesdir$f" "$RPM_BUILD_ROOT$f" || die "Copying $filesdir$f to $RPM_BUILD_ROOT$f failed."
|
|---|
| 144 | done < "$dbgfilelist"
|
|---|
| 145 | cat "$dbgfilelist" >> "$RPM_BUILD_SUBDIR/debugfiles.list"
|
|---|
| 146 | fi
|
|---|
| 147 | fi
|
|---|
| 148 | done
|
|---|
| 149 |
|
|---|
| 150 | exit 0
|
|---|