source: spec/trunk/SPECS/os2-rpm/brp-strip-os2@ 1323

Last change on this file since 1323 was 1086, checked in by dmik, 9 years ago

spec: os2-rpm: Release version 0-1.

  • Property svn:eol-style set to native
  • Property svn:mergeinfo set to (toggle deleted branches)
    /rpm/vendor/current/scripts/brp-strip.os24-997
File size: 5.6 KB
Line 
1#!/@unixroot/usr/bin/sh
2
3#
4# Strip debug info and compress OS/2 binaries and DLLs using emxomfstrip and lxlite tools.
5#
6# Usage: brp-strip-os2 RPM_BUILD_SUBDIR [--[no-]compress] [--[no-]debuginfo]
7# [-n|--names <wildcard1[,wildcard2...]>]
8# [-i|--include <wildcard1[,wildcard2...]>]
9# [-x|--exclude <wildcard1[,wildcard2...]>]
10#
11# RPM_BUILD_SUBDIR is a directory where the souce code of the package is
12# unpacked to. A file `debugfiles.list` containing a list of files with debug
13# info is created in this directory when the script is instructed to generate
14# debug info (by default). This file is then used by the %debug_package macro to
15# automatically generate a `debuginfo` sub-package for the given package.
16#
17# The --no-compress and --no-debuginfo flags completely disable lxlite and emxomfstrip
18# invocation, respectively. The -n flag overrides the default list of files that will be
19# compressed and stripped (see FILENAMES below). The -i flag includes additional files
20# in this list, the -x flag allows to exclude specific files from processing (applied
21# after processing the -n and -i flags). The --compress flag makes all subsequent
22# -n/-i/-x flags operate only on the file list passed to lxlite, without affecting the
23# strip operation. The --debuginfo flag makes these flags operate on the emxomfstrip
24# file list, without affecting compression.
25#
26# Note that until debug info stripping is completely disabled with --no-debuginfo,
27# this script will cause emxomstrip to put debug info in separate *.dbg files and will
28# write all resulting file names into a file list which is to be used by the
29# %debug_package macro to generate the debug package.
30#
31
32die()
33{
34 (>&2 echo "$0: ERROR: $1")
35 exit 1
36}
37
38# If using normal root, avoid changing anything.
39if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" -o "$RPM_BUILD_ROOT" = "/@unixroot" ]; then
40 exit 0
41fi
42
43NO_COMPRESS=
44NO_DEBUGINFO=
45
46FILENAMES="*.exe,*.dll,*.pyd"
47FILENAMES_EXCLUDE=
48
49COMPRESS_FILENAMES=
50COMPRESS_FILENAMES_EXCLUDE=
51
52DEBUGINFO_FILENAMES=
53DEBUGINFO_DFILENAMES_EXCLUDE=
54
55RPM_BUILD_SUBDIR="$1"
56[ -n "$RPM_BUILD_SUBDIR" ] || die "RPM_BUILD_SUBDIR is not set."
57shift
58
59dbgext="dbg"
60dbgfilelist="$RPM_BUILD_SUBDIR/debugfiles.list"
61
62var="FILENAMES"
63
64while [ -n "$1" ] ; do
65 case "$1" in
66 --no-compress)
67 NO_COMPRESS=1
68 COMPRESS_FILENAMES=
69 COMPRESS_FILENAMES_EXCLUDE=
70 ;;
71 --no-debuginfo)
72 NO_DEBUGINFO=1
73 DEBUGINFO_FILENAMES=
74 DEBUGINFO_DFILENAMES_EXCLUDE=
75 ;;
76 --compress)
77 NO_COMPRESS=
78 COMPRESS_FILENAMES="$FILENAMES"
79 COMPRESS_FILENAMES_EXCLUDE="$FILENAMES_EXCLUDE"
80 var="COMPRESS_FILENAMES"
81 ;;
82 --debuginfo)
83 NO_DEBUGINFO=
84 DEBUGINFO_FILENAMES="$FILENAMES"
85 DEBUGINFO_DFILENAMES_EXCLUDE="$FILENAMES_EXCLUDE"
86 var="DEBUGINFO_FILENAMES"
87 ;;
88 --names|-n)
89 [ -n "$2" ] && { eval ${var}="\$2" ; shift ; }
90 ;;
91 --include|-i)
92 [ -n "$2" ] && { eval ${var}="\${${var}:+\$${var},}\$2" ; shift ; }
93 ;;
94 --exclude|-x)
95 [ -n "$2" ] && { eval ${var}_EXCLUDE="\${${var}_EXCLUDE:+\$${var}_EXCLUDE,}\$2" ; shift ; }
96 ;;
97 esac
98 shift
99done
100
101# Exit early if nothing to do
102[ -n "$NO_COMPRESS" -a -n "$NO_DEBUGINFO" ] && exit
103[ -z "$FILENAMES" -a -z "$COMPRESS_FILENAMES" -a -z "$DEBUGINFO_FILENAMES" ] && exit
104
105sed_names="sed -e 's/^/-name \"/' -e 's/,/\" -o -name \"/g' -e 's/$/\"/'"
106
107find_name_args=`echo "$FILENAMES" | eval $sed_names`
108
109[ -n "$FILENAMES_EXCLUDE" ] && \
110 find_name_args="\( $find_name_args \) -a ! \( "`echo "$FILENAMES_EXCLUDE" | eval $sed_names`" \)"
111
112if [ -n "$COMPRESS_FILENAMES" ] ; then
113 if [ "$COMPRESS_FILENAMES" != "$FILENAMES" -o "$COMPRESS_FILENAMES_EXCLUDE" != "$FILENAMES_EXCLUDE" ] ; then
114 c_find_name_args=`echo "$COMPRESS_FILENAMES" | eval $sed_names`
115
116 [ -n "$COMPRESS_FILENAMES_EXCLUDE" ] && \
117 c_find_name_args="\( $c_find_name_args \) -a ! \( "`echo "$COMPRESS_FILENAMES_EXCLUDE" | eval $sed_names`" \)"
118 fi
119fi
120
121if [ -n "$DEBUGINFO_FILENAMES" ] ; then
122 if [ "$DEBUGINFO_FILENAMES" != "$FILENAMES" -o "$DEBUGINFO_FILENAMES_EXCLUDE" != "$FILENAMES_EXCLUDE" ] ; then
123 d_find_name_args=`echo "$DEBUGINFO_FILENAMES" | eval $sed_names`
124
125 [ -n "$DEBUGINFO_FILENAMES_EXCLUDE" ] && \
126 d_find_name_args="\( $d_find_name_args \) -a ! \( "`echo "$DEBUGINFO_FILENAMES_EXCLUDE" | eval $sed_names`" \)"
127 fi
128fi
129
130if [ -n "$c_find_name_args" -o -n "$d_find_name_args" ] ; then
131 [ -z "$c_find_name_args" ] && c_find_name_args="$find_name_args"
132 [ -z "$d_find_name_args" ] && d_find_name_args="$find_name_args"
133 if [ "$c_find_name_args" = "$d_find_name_args" ] ; then
134 find_name_args="$c_find_name_args"
135 c_find_name_args=
136 d_find_name_args=
137 else
138 find_name_args=
139 fi
140fi
141
142# Now do the job.
143
144if [ -n "$find_name_args" ] ; then
145 # Single file set (emxomfstrip must come first!)
146 for f in `eval find \"$RPM_BUILD_ROOT\" -type f $find_name_args`; do
147 [ -z "$NO_DEBUGINFO" ] && emxomfstrip -D "${f%.*}.$dbgext" $f
148 [ -z "$NO_COMPRESS" ] && lxlite /ml1 /mf2 /ydd /yxd /b- "$f"
149 done
150else
151 # Two different file sets (emxomfstrip must come first!)
152 if [ -n "$d_find_name_args" ] ; then
153 for f in `eval find \"$RPM_BUILD_ROOT\" -type f $d_find_name_args`; do
154 emxomfstrip -D "${f%.*}.$dbgext" $f
155 done
156 fi
157 if [ -n "$c_find_name_args" ] ; then
158 for f in `eval find \"$RPM_BUILD_ROOT\" -type f $c_find_name_args`; do
159 lxlite /ml1 /mf2 /ydd /yxd /b- "$f"
160 done
161 fi
162fi
163
164[ -z "$NO_DEBUGINFO" ] && \
165 find "$RPM_BUILD_ROOT" -type f -name "*.$dbgext" | sed -e "s|^$RPM_BUILD_ROOT||" > "$dbgfilelist"
166
167exit 0
Note: See TracBrowser for help on using the repository browser.