From 048c46d35f81117f3cb259ed77944ba882c6de52 Mon Sep 17 00:00:00 2001 From: LD-RW Date: Fri, 10 Apr 2026 22:39:14 +0300 Subject: [PATCH] ci: fix python3 one-liner file truncation bug in pacman.conf rewrite The previous version called open(f,'w') before open(f).read() in the same expression. Python evaluates the object (open for writing) first, which truncates the file to zero before the read happens -- resulting in an empty pacman.conf and a broken build. Fix: read into a variable first, then write back. Also use ^/$ anchors with re.MULTILINE so the pattern matches only lines that START with SigLevel, leaving LocalFileSigLevel untouched. Tested locally against a mock pacman.conf with the exact MSYS2 AppVeyor format. --- .appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index e63d0930..19e49246 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -39,10 +39,10 @@ install: - set PATH=c:\msys64\%MSYSTEM%\bin;c:\msys64\usr\bin;%PATH% - if defined MSVC call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %MSVC% - if defined MSVC pacman --noconfirm -Rsc mingw-w64-%CPU%-gcc gcc - - bash -c "python3 -c \"import re; f='/etc/pacman.conf'; open(f,'w').write(re.sub(r'SigLevel\s*=\s*\S.*', 'SigLevel = Never', open(f).read()))\"" + - bash -c "python3 -c \"import re; f='/etc/pacman.conf'; c=open(f).read(); open(f,'w').write(re.sub(r'^SigLevel\s*=.*$', 'SigLevel = Never', c, flags=re.MULTILINE))\"" - pacman --noconfirm -Syuu - pacman --noconfirm -S msys2-keyring - - bash -c "python3 -c \"import re; f='/etc/pacman.conf'; open(f,'w').write(re.sub(r'SigLevel\s*=\s*Never', 'SigLevel = Required DatabaseOptional', open(f).read()))\"" + - bash -c "python3 -c \"import re; f='/etc/pacman.conf'; c=open(f).read(); open(f,'w').write(re.sub(r'^SigLevel\s*=.*$', 'SigLevel = Required DatabaseOptional', c, flags=re.MULTILINE))\"" - pacman --noconfirm -Syuu - pacman --noconfirm -S autoconf