Skip to content

Commit ad9f92a

Browse files
authored
Merge pull request #260 from git-for-windows/allow-msys2-runtime-to-be-code-signed-again
msys2-runtime: avoid stripping to allow code-signing again
2 parents fecfa95 + 02ac3f8 commit ad9f92a

File tree

1 file changed

+30
-56
lines changed

1 file changed

+30
-56
lines changed

msys2-runtime/PKGBUILD

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
pkgbase=msys2-runtime
55
pkgname=('msys2-runtime' 'msys2-runtime-devel')
66
pkgver=3.6.4
7-
pkgrel=1
7+
pkgrel=2
88
pkgdesc="Cygwin POSIX emulation engine"
99
arch=('x86_64')
1010
url="https://www.cygwin.com/"
1111
license=('GPL')
12-
groups=('base')
12+
msys2_references=(
13+
'cygwin: cygwin'
14+
"cpe: cpe:/a:cygwin:cygwin"
15+
)
1316
makedepends=('cocom'
14-
'texinfo'
1517
'git'
1618
'perl'
1719
'gcc'
18-
'make'
19-
'mingw-w64-cross-crt-git'
20+
'mingw-w64-cross-crt'
2021
'mingw-w64-cross-gcc'
2122
'mingw-w64-cross-zlib'
2223
'zlib-devel'
@@ -173,9 +174,8 @@ prepare() {
173174
winsup/cygwin/msys2_path_conv.h \
174175
winsup/cygwin/include/cygwin/exit_process.h \
175176
winsup/utils/mingw/getprocaddr.c
176-
apply_git_am_with_msg \
177-
\
178-
0001-Fix-msys-library-name-in-import-libraries.patch \
177+
178+
apply_git_am_with_msg 0001-Fix-msys-library-name-in-import-libraries.patch \
179179
0002-Rename-dll-from-cygwin-to-msys.patch \
180180
0003-Add-functionality-for-converting-UNIX-paths-in-argum.patch \
181181
0004-Add-functionality-for-changing-OS-name-via-MSYSTEM-e.patch \
@@ -237,18 +237,14 @@ build() {
237237
OPTIM="-O2"
238238
fi
239239

240-
CFLAGS="$OPTIM -pipe -g0 -Wno-error=deprecated -Wno-error=stringop-truncation -Wno-error=missing-attributes -Wno-error=maybe-uninitialized" #-Wno-error=class-memaccess
241-
CXXFLAGS="$OPTIM -pipe -g0 -Wno-error=deprecated -Wno-error=stringop-truncation -Wno-error=missing-attributes -Wno-error=maybe-uninitialized" #-Wno-error=class-memaccess
240+
# We use `-g0` here to suppress debug symbols, to avoid having to call `strip.exe`
241+
# on the binary files (which would break code-signing those files).
242+
CFLAGS="$OPTIM -pipe -g0"
243+
CXXFLAGS="$OPTIM -pipe -g0"
242244

243245
# otherwise it asks git which appends "-dirty" because of our uncommited patches
244246
CFLAGS+=" -DCYGPORT_RELEASE_INFO=${pkgver}"
245247

246-
# XXX: cygwin still uses gcc v11 so we get new warnings with v13,
247-
# resulting in errors. We can't selectively disable warnigns since our
248-
# cross compiler is also too old and doesn't understand the new
249-
# warning flags, so we need to disable all errors for now.
250-
export CXXFLAGS="-Wno-error -Wno-narrowing"
251-
252248
(cd "${srcdir}/msys2-runtime/winsup" && ./autogen.sh)
253249

254250
"${srcdir}"/msys2-runtime/configure \
@@ -258,33 +254,27 @@ build() {
258254
--sysconfdir=/etc \
259255
"${extra_config[@]}"
260256
LC_ALL=C make
261-
262-
if test -n "$SIGNTOOL"
263-
then
264-
eval "$SIGNTOOL" \
265-
${PWD}/${CHOST}/winsup/cygwin/new-msys-2.0.dll \
266-
${PWD}/${CHOST}/winsup/utils/*.exe ${PWD}/${CHOST}/winsup/utils/mingw/*.exe
267-
fi
268-
269257
LC_ALL=C make -j1 DESTDIR="${srcdir}"/dest install
270258

271-
#pushd ${CHOST}/winsup/cygwin > /dev/null
272-
#LANG=C make libmsys2_s.a
273-
#cp libmsys2_s.a "${srcdir}"/dest/usr/${CHOST}/lib/
274-
#popd > /dev/null
275-
276259
rm -rf "${srcdir}"/dest/etc
260+
261+
# split debug info from msys-2.0.dll
262+
cd "${srcdir}"/dest
263+
objcopy --add-gnu-debuglink=/dev/null --only-keep-debug usr/bin/msys-2.0.dll usr/bin/msys-2.0.dbg
264+
objcopy --strip-debug --strip-unneeded --add-gnu-debuglink=usr/bin/msys-2.0.dbg usr/bin/msys-2.0.dll usr/bin/msys-2.0.dll.new
265+
mv -f usr/bin/msys-2.0.dll.new usr/bin/msys-2.0.dll
277266
}
278267

279268
package_msys2-runtime() {
280269
pkgdesc="Posix emulation engine for Windows"
281-
groups=('base')
282-
conflicts=('catgets' 'libcatgets' 'msys2-runtime-3.4')
283-
replaces=('catgets' 'libcatgets' 'msys2-runtime-3.4')
270+
options=('!strip')
271+
conflicts=('catgets' 'libcatgets' 'msys2-runtime-3.6')
272+
replaces=('catgets' 'libcatgets' 'msys2-runtime-3.6')
284273

285274
mkdir -p "${pkgdir}"/usr
286275
cp -rf "${srcdir}"/dest/usr/bin "${pkgdir}"/usr/
287276
cp -rf "${srcdir}"/dest/usr/libexec "${pkgdir}"/usr/
277+
rm -f "${pkgdir}"/usr/bin/msys-2.0.dbg
288278
rm -f "${pkgdir}"/usr/bin/cyglsa-config
289279
rm -f "${pkgdir}"/usr/bin/cyglsa.dll
290280
rm -f "${pkgdir}"/usr/bin/cyglsa64.dll
@@ -294,38 +284,22 @@ package_msys2-runtime() {
294284

295285
package_msys2-runtime-devel() {
296286
pkgdesc="MSYS2 headers and libraries"
297-
groups=('msys2-devel')
298287
depends=("msys2-runtime=${pkgver}")
299-
conflicts=('libcatgets-devel' 'msys2-runtime-3.4-devel')
300-
replaces=('libcatgets-devel' 'msys2-runtime-3.4-devel')
288+
conflicts=('libcatgets-devel' 'msys2-runtime-3.6-devel')
289+
replaces=('libcatgets-devel' 'msys2-runtime-3.6-devel')
290+
# strip breaks the split debug info. msys2/msys2-pacman#52
291+
options=('!strip')
301292

302293
mkdir -p "${pkgdir}"/usr/bin
294+
cp -f "${srcdir}"/dest/usr/bin/msys-2.0.dbg "${pkgdir}"/usr/bin/
303295
cp -rLf "${srcdir}"/dest/usr/${CHOST}/include "${pkgdir}"/usr/
304296
rm -f "${pkgdir}"/usr/include/iconv.h
305297
rm -f "${pkgdir}"/usr/include/unctrl.h
306298
# provided by libtirpc
307299
rm -fr "${pkgdir}"/usr/include/rpc/
308300

309301
cp -rLf "${srcdir}"/dest/usr/${CHOST}/lib "${pkgdir}"/usr/
310-
}
311302

312-
# return 0
313-
# To hack on this:
314-
# cd /c/repo-MSYS2/msys2-runtime/
315-
# pushd src/build-i686-pc-msys
316-
# LANG=C make && make -j1 DESTDIR=/c/repo-MSYS2/msys2-runtime/src/dest install
317-
# popd
318-
# makepkg -sRLf
319-
# pacman -U msys2-runtime*.xz
320-
321-
# Quicker:
322-
# open cmd.exe
323-
# set "PATH=C:\\msys32\\usr\\bin;%PATH%"
324-
# E:
325-
# pushd E:\m2\repo-MSYS2\msys2-runtime\src\build-i686-pc-msys\i686-pc-msys\winsup\cygwin
326-
# C:/msys32/usr/bin/bash -c "LANG=C && make"
327-
# copy /y new-msys-2.0.dll C:\msys32\usr\bin\msys-2.0.dll
328-
# popd
329-
# C:
330-
# C:/msys32/usr/bin/strace ls / > C:/strace.txt 2>&1
331-
#
303+
# compatibility with Cygwin toolchains
304+
cp "${srcdir}"/dest/usr/${CHOST}/lib/libmsys-2.0.a "${pkgdir}"/usr/lib/libcygwin.a
305+
}

0 commit comments

Comments
 (0)