| 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 |
|
|---|
| 32 | die()
|
|---|
| 33 | {
|
|---|
| 34 | (>&2 echo "$0: ERROR: $1")
|
|---|
| 35 | exit 1
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | # If using normal root, avoid changing anything.
|
|---|
| 39 | if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" -o "$RPM_BUILD_ROOT" = "/@unixroot" ]; then
|
|---|
| 40 | exit 0
|
|---|
| 41 | fi
|
|---|
| 42 |
|
|---|
| 43 | NO_COMPRESS=
|
|---|
| 44 | NO_DEBUGINFO=
|
|---|
| 45 |
|
|---|
| 46 | FILENAMES="*.exe,*.dll,*.pyd"
|
|---|
| 47 | FILENAMES_EXCLUDE=
|
|---|
| 48 |
|
|---|
| 49 | COMPRESS_FILENAMES=
|
|---|
| 50 | COMPRESS_FILENAMES_EXCLUDE=
|
|---|
| 51 |
|
|---|
| 52 | DEBUGINFO_FILENAMES=
|
|---|
| 53 | DEBUGINFO_DFILENAMES_EXCLUDE=
|
|---|
| 54 |
|
|---|
| 55 | RPM_BUILD_SUBDIR="$1"
|
|---|
| 56 | [ -n "$RPM_BUILD_SUBDIR" ] || die "RPM_BUILD_SUBDIR is not set."
|
|---|
| 57 | shift
|
|---|
| 58 |
|
|---|
| 59 | dbgext="dbg"
|
|---|
| 60 | dbgfilelist="$RPM_BUILD_SUBDIR/debugfiles.list"
|
|---|
| 61 |
|
|---|
| 62 | var="FILENAMES"
|
|---|
| 63 |
|
|---|
| 64 | while [ -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
|
|---|
| 99 | done
|
|---|
| 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 |
|
|---|
| 105 | sed_names="sed -e 's/^/-name \"/' -e 's/,/\" -o -name \"/g' -e 's/$/\"/'"
|
|---|
| 106 |
|
|---|
| 107 | find_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 |
|
|---|
| 112 | if [ -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
|
|---|
| 119 | fi
|
|---|
| 120 |
|
|---|
| 121 | if [ -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
|
|---|
| 128 | fi
|
|---|
| 129 |
|
|---|
| 130 | if [ -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
|
|---|
| 140 | fi
|
|---|
| 141 |
|
|---|
| 142 | # Now do the job.
|
|---|
| 143 |
|
|---|
| 144 | if [ -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
|
|---|
| 150 | else
|
|---|
| 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
|
|---|
| 162 | fi
|
|---|
| 163 |
|
|---|
| 164 | [ -z "$NO_DEBUGINFO" ] && \
|
|---|
| 165 | find "$RPM_BUILD_ROOT" -type f -name "*.$dbgext" | sed -e "s|^$RPM_BUILD_ROOT||" > "$dbgfilelist"
|
|---|
| 166 |
|
|---|
| 167 | exit 0
|
|---|