1 | | #!/usr/bin/sh |
| 1 | #!/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 [--[no-]compress] [--[no-]debuginfo] |
| 7 | # [-n|--names <wildcard1[,wildcard2...]>] |
| 8 | # [-i|--include <wildcard1[,wildcard2...]>] |
| 9 | # [-x|--exclude <wildcard1[,wildcard2...]>] |
| 10 | # |
| 11 | # The --no-compress and --no-debuginfo flags completely disable lxlite and emxomfstrip |
| 12 | # invocation, respectively. The -n flag overrides the default list of files that will be |
| 13 | # compressed and stripped (see FILENAMES below). The -i flag includes additional files |
| 14 | # in this list, the -x flag allows to exclude specific files from processing (applied |
| 15 | # after processing the -n and -i flags). The --compress flag makes all subsequent |
| 16 | # -n/-i/-x flags operate only on the file list passed to lxlite, without affecting the |
| 17 | # strip operation. The --debuginfo flag makes these flags operate on the emxomfstrip |
| 18 | # file list, without affecting compression. |
| 19 | # |
| 20 | # Note that until debug info stripping is completely disabled with --no-debuginfo, |
| 21 | # this script will cause emxomstrip to put debug info in separate *.dbg files and will |
| 22 | # write all resulting file names into a file list which is to be used by the |
| 23 | # %debug_package macro to generate the debug package. |
| 24 | # |
| 25 | |
| 57 | DEBUGINFO_FILENAMES= |
| 58 | DEBUGINFO_DFILENAMES_EXCLUDE= |
| 59 | ;; |
| 60 | --compress) |
| 61 | NO_COMPRESS= |
| 62 | COMPRESS_FILENAMES="$FILENAMES" |
| 63 | COMPRESS_FILENAMES_EXCLUDE="$FILENAMES_EXCLUDE" |
| 64 | var="COMPRESS_FILENAMES" |
| 65 | ;; |
| 66 | --debuginfo) |
| 67 | NO_DEBUGINFO= |
| 68 | DEBUGINFO_FILENAMES="$FILENAMES" |
| 69 | DEBUGINFO_DFILENAMES_EXCLUDE="$FILENAMES_EXCLUDE" |
| 70 | var="DEBUGINFO_FILENAMES" |
| 71 | ;; |
| 72 | --names|-n) |
| 73 | [ -n "$2" ] && { eval ${var}="\$2" ; shift ; } |
| 74 | ;; |
| 75 | --include|-i) |
| 76 | [ -n "$2" ] && { eval ${var}="\${${var}:+\$${var},}\$2" ; shift ; } |
| 77 | ;; |
| 78 | --exclude|-x) |
| 79 | [ -n "$2" ] && { eval ${var}_EXCLUDE="\${${var}_EXCLUDE:+\$${var}_EXCLUDE,}\$2" ; shift ; } |
25 | | # Strip and pack OS/2 binaries and DLLs |
26 | | for f in `find $RPM_BUILD_ROOT -type f -name "*.exe" -o -name "*.dll"`; do |
27 | | [ -z "$NO_DEBUGINFO" ] && emxomfstrip -D "${f%.*}.dbg" $f |
28 | | [ -z "$NO_COMPRESS" ] && lxlite /ml1 /mf2 /ydd /yxd /b- "$f" |
29 | | done |
| 89 | sed_names="sed -e 's/^/-name \"/' -e 's/,/\" -o -name \"/g' -e 's/$/\"/'" |
| 90 | |
| 91 | find_name_args=`echo "$FILENAMES" | eval $sed_names` |
| 92 | |
| 93 | [ -n "$FILENAMES_EXCLUDE" ] && \ |
| 94 | find_name_args="\( $find_name_args \) -a ! \( "`echo "$FILENAMES_EXCLUDE" | eval $sed_names`" \)" |
| 95 | |
| 96 | if [ -n "$COMPRESS_FILENAMES" ] ; then |
| 97 | if [ "$COMPRESS_FILENAMES" != "$FILENAMES" -o "$COMPRESS_FILENAMES_EXCLUDE" != "$FILENAMES_EXCLUDE" ] ; then |
| 98 | c_find_name_args=`echo "$COMPRESS_FILENAMES" | eval $sed_names` |
| 99 | |
| 100 | [ -n "$COMPRESS_FILENAMES_EXCLUDE" ] && \ |
| 101 | c_find_name_args="\( $c_find_name_args \) -a ! \( "`echo "$COMPRESS_FILENAMES_EXCLUDE" | eval $sed_names`" \)" |
| 102 | fi |
| 103 | fi |
| 104 | |
| 105 | if [ -n "$DEBUGINFO_FILENAMES" ] ; then |
| 106 | if [ "$DEBUGINFO_FILENAMES" != "$FILENAMES" -o "$DEBUGINFO_FILENAMES_EXCLUDE" != "$FILENAMES_EXCLUDE" ] ; then |
| 107 | d_find_name_args=`echo "$DEBUGINFO_FILENAMES" | eval $sed_names` |
| 108 | |
| 109 | [ -n "$DEBUGINFO_FILENAMES_EXCLUDE" ] && \ |
| 110 | d_find_name_args="\( $d_find_name_args \) -a ! \( "`echo "$DEBUGINFO_FILENAMES_EXCLUDE" | eval $sed_names`" \)" |
| 111 | fi |
| 112 | fi |
| 113 | |
| 114 | if [ -n "$c_find_name_args" -o -n "$d_find_name_args" ] ; then |
| 115 | [ -z "$c_find_name_args" ] && c_find_name_args="$find_name_args" |
| 116 | [ -z "$d_find_name_args" ] && d_find_name_args="$find_name_args" |
| 117 | if [ "$c_find_name_args" = "$d_find_name_args" ] ; then |
| 118 | find_name_args="$c_find_name_args" |
| 119 | c_find_name_args= |
| 120 | d_find_name_args= |
| 121 | else |
| 122 | find_name_args= |
| 123 | fi |
| 124 | fi |
| 125 | |
| 126 | # Now do the job. |
| 127 | |
| 128 | if [ -n "$find_name_args" ] ; then |
| 129 | # Single file set (emxomfstrip must come first!) |
| 130 | for f in `eval find \"$RPM_BUILD_ROOT\" -type f $find_name_args`; do |
| 131 | [ -z "$NO_DEBUGINFO" ] && emxomfstrip -D "${f%.*}.$dbgext" $f |
| 132 | [ -z "$NO_COMPRESS" ] && lxlite /ml1 /mf2 /ydd /yxd /b- "$f" |
| 133 | done |
| 134 | else |
| 135 | # Two different file sets (emxomfstrip must come first!) |
| 136 | if [ -n "$d_find_name_args" ] ; then |
| 137 | for f in `eval find \"$RPM_BUILD_ROOT\" -type f $d_find_name_args`; do |
| 138 | emxomfstrip -D "${f%.*}.$dbgext" $f |
| 139 | done |
| 140 | fi |
| 141 | if [ -n "$c_find_name_args" ] ; then |
| 142 | for f in `eval find \"$RPM_BUILD_ROOT\" -type f $c_find_name_args`; do |
| 143 | lxlite /ml1 /mf2 /ydd /yxd /b- "$f" |
| 144 | done |
| 145 | fi |
| 146 | fi |
| 147 | |
| 148 | [ -z "$NO_DEBUGINFO" ] && \ |
| 149 | find "$RPM_BUILD_ROOT" -type f -name "*.$dbgext" | sed -e "s|^$RPM_BUILD_ROOT||" > "./$dbgfilelist" |
| 150 | |
| 151 | exit 0 |