https://git.reactos.org/?p=reactos.git;a=commitdiff;h=53cc92613fbfc315409c7…
commit 53cc92613fbfc315409c7d93cc8f5fab83e47a34
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Fri Sep 15 16:15:26 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 18 22:21:41 2023 +0100
[WINESYNC] Support improvements for staging patches (#5898)
- Simplify patch directory usage;
- Fix the path shown in the warning message.
The staging patch path in the warning message didn't show the correct
sub-directory where the patch resides.
---
sdk/tools/winesync/winesync.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index 72860f98ce1..36646086217 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -137,7 +137,8 @@ class wine_sync:
if in_staging:
# see if we already applied this patch
patch_file_name = f'{staging_patch_index:04}-{string_to_valid_file_name(wine_commit.message.splitlines()[0])}.diff'
- patch_path = os.path.join(self.reactos_src, self.staged_patch_dir, patch_file_name)
+ patch_dir = os.path.join(self.reactos_src, self.staged_patch_dir)
+ patch_path = os.path.join(patch_dir, patch_file_name)
if os.path.isfile(patch_path):
print(f'Skipping patch as {patch_path} already exists')
return True, ''
@@ -234,8 +235,8 @@ class wine_sync:
else:
# Add the staging patch
# do not save the wine commit ID in <module>.cfg, as it's a local one for staging patches
- if not os.path.isdir(os.path.join(self.reactos_src, self.staged_patch_dir)):
- os.mkdir(os.path.join(self.reactos_src, self.staged_patch_dir))
+ if not os.path.isdir(patch_dir):
+ os.mkdir(patch_dir)
with open(patch_path, 'w') as file_output:
file_output.write(complete_patch)
self.reactos_index.add(posixpath.join(self.staged_patch_dir, patch_file_name))
@@ -264,11 +265,12 @@ class wine_sync:
f'You can see the details of the wine commit here:\n' \
f' https://source.winehq.org/git/wine.git/commit/{str(wine_commit.id)}\n'
else:
+ patch_file_path = posixpath.join(self.staged_patch_dir, patch_file_name)
warning_message += f'\n' \
f'Do not forget to run\n' \
- f' git diff HEAD^ \':(exclude)sdk/tools/winesync/{patch_file_name}\' > sdk/tools/winesync/{patch_file_name}\n' \
+ f' git diff HEAD^ \':(exclude){patch_file_path}\' > {patch_file_path}\n' \
f'after your correction and then\n' \
- f' git add sdk/tools/winesync/{patch_file_name}\n' \
+ f' git add {patch_file_path}\n' \
f'before running "git commit --amend"'
return True, warning_message
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1d92196d2afbe210328e1…
commit 1d92196d2afbe210328e1147229da62b121ccb5f
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Sep 12 13:21:36 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 18 22:21:39 2023 +0100
[WINESYNC] Use the same 'winesync' author as for all the other commits the script generates.
This now correctly sets the commit author as 'winesync' (before it was
the committer's developer name) for the following types of commits:
`[WINESYNC]: revert wine-staging patchset for <MODULE_NAME>`
and
`[WINESYNC]: <MODULE_NAME> is now in sync with wine-staging <WINE_TAG>`
---
sdk/tools/winesync/winesync.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index 63cafd60a2b..7335a8a37ac 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -46,6 +46,9 @@ class wine_sync:
self.wine_staging_repo = pygit2.Repository(self.wine_staging_src)
self.reactos_repo = pygit2.Repository(self.reactos_src)
+ # the standard author signature we will use
+ self.winesync_author_signature = pygit2.Signature('winesync', 'ros-dev(a)reactos.org')
+
# read the index from the reactos tree
self.reactos_index = self.reactos_repo.index
self.reactos_index.read()
@@ -245,8 +248,9 @@ class wine_sync:
else:
commit_msg += f'wine commit id {str(wine_commit.id)} by {wine_commit.author.name} <{wine_commit.author.email}>'
- self.reactos_repo.create_commit('HEAD',
- pygit2.Signature('winesync', 'ros-dev(a)reactos.org'),
+ self.reactos_repo.create_commit(
+ 'HEAD',
+ self.winesync_author_signature,
self.reactos_repo.default_signature,
commit_msg,
self.reactos_index.write_tree(),
@@ -310,7 +314,7 @@ class wine_sync:
self.reactos_repo.create_commit(
'HEAD',
- self.reactos_repo.default_signature,
+ self.winesync_author_signature,
self.reactos_repo.default_signature,
f'[WINESYNC]: revert wine-staging patchset for {self.module}',
self.reactos_index.write_tree(),
@@ -376,7 +380,7 @@ class wine_sync:
self.reactos_index.write()
self.reactos_repo.create_commit(
'HEAD',
- self.reactos_repo.default_signature,
+ self.winesync_author_signature,
self.reactos_repo.default_signature,
f'[WINESYNC]: {self.module} is now in sync with wine-staging {wine_tag}',
self.reactos_index.write_tree(),
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f8569465ce3979f3ab47b…
commit f8569465ce3979f3ab47b46fe50de7b6ffa0de1e
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Sep 6 12:57:15 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 18 22:21:38 2023 +0100
[WINESYNC] Make the wine-staging tag optional, in which case Wine-Staging is not used.
---
sdk/tools/winesync/winesync.py | 49 ++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index 2e769afaf49..63cafd60a2b 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -58,7 +58,11 @@ class wine_sync:
self.staged_patch_dir = posixpath.join('sdk', 'tools', 'winesync', self.module + '_staging')
def create_or_checkout_wine_branch(self, wine_tag, wine_staging_tag):
- wine_branch_name = 'winesync-' + wine_tag + '-' + wine_staging_tag
+ # build the wine branch name
+ wine_branch_name = 'winesync-' + wine_tag
+ if wine_staging_tag:
+ wine_branch_name += '-' + wine_staging_tag
+
branch = self.wine_repo.lookup_branch(wine_branch_name)
if branch is None:
# get our target commits
@@ -68,29 +72,32 @@ class wine_sync:
if isinstance(wine_target_commit, pygit2.Commit):
wine_target_commit = wine_target_commit.id
- wine_staging_target_commit = self.wine_staging_repo.revparse_single(wine_staging_tag)
- if isinstance(wine_staging_target_commit, pygit2.Tag):
- wine_staging_target_commit = wine_staging_target_commit.target
- if isinstance(wine_staging_target_commit, pygit2.Commit):
- wine_staging_target_commit = wine_staging_target_commit.id
+ # do the same for the wine-staging tree
+ if wine_staging_tag:
+ wine_staging_target_commit = self.wine_staging_repo.revparse_single(wine_staging_tag)
+ if isinstance(wine_staging_target_commit, pygit2.Tag):
+ wine_staging_target_commit = wine_staging_target_commit.target
+ if isinstance(wine_staging_target_commit, pygit2.Commit):
+ wine_staging_target_commit = wine_staging_target_commit.id
self.wine_repo.branches.local.create(wine_branch_name, self.wine_repo.revparse_single('HEAD'))
self.wine_repo.checkout(self.wine_repo.lookup_branch(wine_branch_name))
self.wine_repo.reset(wine_target_commit, pygit2.GIT_RESET_HARD)
# do the same for the wine-staging tree
- self.wine_staging_repo.branches.local.create(wine_branch_name, self.wine_staging_repo.revparse_single('HEAD'))
- self.wine_staging_repo.checkout(self.wine_staging_repo.lookup_branch(wine_branch_name))
- self.wine_staging_repo.reset(wine_staging_target_commit, pygit2.GIT_RESET_HARD)
-
- # run the wine-staging script
- if subprocess.call(['python', self.wine_staging_src + '/staging/patchinstall.py', 'DESTDIR=' + self.wine_src, '--all', '--backend=git-am']):
- # the new script failed (it doesn't exist?), try the old one
- subprocess.call(['bash', '-c', self.wine_staging_src + '/patches/patchinstall.sh DESTDIR=' + self.wine_src + ' --all --backend=git-am'])
-
- # delete the branch we created
- self.wine_staging_repo.checkout(self.wine_staging_repo.lookup_branch('master'))
- self.wine_staging_repo.branches.delete(wine_branch_name)
+ if wine_staging_tag:
+ self.wine_staging_repo.branches.local.create(wine_branch_name, self.wine_staging_repo.revparse_single('HEAD'))
+ self.wine_staging_repo.checkout(self.wine_staging_repo.lookup_branch(wine_branch_name))
+ self.wine_staging_repo.reset(wine_staging_target_commit, pygit2.GIT_RESET_HARD)
+
+ # run the wine-staging script
+ if subprocess.call(['python', self.wine_staging_src + '/staging/patchinstall.py', 'DESTDIR=' + self.wine_src, '--all', '--backend=git-am']):
+ # the new script failed (it doesn't exist?), try the old one
+ subprocess.call(['bash', '-c', self.wine_staging_src + '/patches/patchinstall.sh DESTDIR=' + self.wine_src + ' --all --backend=git-am'])
+
+ # delete the branch we created
+ self.wine_staging_repo.checkout(self.wine_staging_repo.lookup_branch('master'))
+ self.wine_staging_repo.branches.delete(wine_branch_name)
else:
self.wine_repo.checkout(self.wine_repo.lookup_branch(wine_branch_name))
@@ -379,9 +386,9 @@ class wine_sync:
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('module', help='The module you want to sync. <module>.cfg must exist in the current directory')
- parser.add_argument('wine_tag', help='The wine tag or commit id to sync to')
- parser.add_argument('wine_staging_tag', help='The wine staging tag or commit id to pick wine staged patches from')
+ parser.add_argument('module', help='The module you want to sync. <module>.cfg must exist in the current directory.')
+ parser.add_argument('wine_tag', help='The wine tag or commit id to sync to.')
+ parser.add_argument('wine_staging_tag', nargs='?', default=None, help='The optional wine staging tag or commit id to pick wine staged patches from.')
args = parser.parse_args()
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7f8d2d14b76807b0d4231…
commit 7f8d2d14b76807b0d42311283f44098e41733504
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Sep 5 22:06:30 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 18 22:21:37 2023 +0100
[WINESYNC] Elegantly handle empty 'files' and 'directories' lists.
Expand on Timo's commit 4b5a55516.
We may encounter cases where either the 'directories' or 'files' lists
in the .cfg YAML files are empty, and we don't want the script to throw
an exception in that case.
Furthermore, explicitly check for such empty lists when calling PyGit2
index.add_all(...) function, because if it's called on a None or empty
list, _all_ untracked files in the selected git repository get added,
which is not what we want there.
---
sdk/tools/winesync/winesync.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index 680b4cfc4d6..2e769afaf49 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -99,7 +99,7 @@ class wine_sync:
# Helper function for resolving wine tree path to reactos one
# Note: it doesn't care about the fact that the file actually exists or not
def wine_to_reactos_path(self, wine_path):
- if wine_path in self.module_cfg['files']:
+ if self.module_cfg['files'] and (wine_path in self.module_cfg['files']):
# we have a direct mapping
return self.module_cfg['files'][wine_path]
@@ -107,11 +107,8 @@ class wine_sync:
# root files should have a direct mapping
return None
- if self.module_cfg['directories'] is None:
- return None
-
wine_dir, wine_file = os.path.split(wine_path)
- if wine_dir in self.module_cfg['directories']:
+ if self.module_cfg['directories'] and (wine_dir in self.module_cfg['directories']):
# we have a mapping for the directory
return posixpath.join(self.module_cfg['directories'][wine_dir], wine_file)
@@ -295,8 +292,13 @@ class wine_sync:
if not has_patches:
return True
- self.reactos_index.add_all([f for f in self.module_cfg['files'].values()])
- self.reactos_index.add_all([f'{d}/*.*' for d in self.module_cfg['directories'].values()])
+ # Note: these path lists may be empty or None, in which case
+ # we should not call index.add_all(), otherwise we would add
+ # any untracked file present in the repository.
+ if self.module_cfg['files']:
+ self.reactos_index.add_all([f for f in self.module_cfg['files'].values()])
+ if self.module_cfg['directories']:
+ self.reactos_index.add_all([f'{d}/*.*' for d in self.module_cfg['directories'].values()])
self.reactos_index.write()
self.reactos_repo.create_commit(
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=67ca439d06a8ad7f00cb4…
commit 67ca439d06a8ad7f00cb42ea839c3cadcbec0ea1
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Tue Sep 5 17:59:33 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 18 22:21:36 2023 +0100
[WINESYNC] Allow using the "new" Wine-Staging patchinstall.py script.
Wine-Staging switched to staging/patchinstall.py , removing the
deprecated patches/patchinstall.sh in Feb.16, 2023 commit
https://github.com/wine-staging/wine-staging/commit/c1b4af92f74d7bd330003d3…
just before the v8.2 release.
In order to maintain interoperability between older and newer
Wine-Staging versions, try to run first the new script; if it fails,
fall back to the older script.
---
sdk/tools/winesync/winesync.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index 652e4233e23..680b4cfc4d6 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -84,7 +84,9 @@ class wine_sync:
self.wine_staging_repo.reset(wine_staging_target_commit, pygit2.GIT_RESET_HARD)
# run the wine-staging script
- subprocess.call(['bash', '-c', self.wine_staging_src + '/patches/patchinstall.sh DESTDIR=' + self.wine_src + ' --all --backend=git-am'])
+ if subprocess.call(['python', self.wine_staging_src + '/staging/patchinstall.py', 'DESTDIR=' + self.wine_src, '--all', '--backend=git-am']):
+ # the new script failed (it doesn't exist?), try the old one
+ subprocess.call(['bash', '-c', self.wine_staging_src + '/patches/patchinstall.sh DESTDIR=' + self.wine_src + ' --all --backend=git-am'])
# delete the branch we created
self.wine_staging_repo.checkout(self.wine_staging_repo.lookup_branch('master'))
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=454901ab0b485b4d28aee…
commit 454901ab0b485b4d28aee169cacd2762e8e1324a
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Sep 7 18:09:32 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Dec 18 22:21:35 2023 +0100
[WINESYNC] Explicitly use posix paths for git file manipulations.
Whenever using git, be it on Windows CMD, git-bash on Windows, or in
*nix systems, git appears to always use posix-like paths internally.
So, enforce them with posixpath when building/concatenating paths that
are going to be passed to pygit2 functions.
Otherwise, exceptions like the following one happens:
```
File "./winesync.py", line 296, in revert_staged_patchset
self.reactos_index.remove(os.path.join(self.staged_patch_dir, patch_file_name))
[... skipped ...]
OSError: index does not contain sdk\tools\winesync\setupapi_staging\0002-wine-staging-4.0-setupapi_winetest.patch at stage 0
```
(The git index actually contains the specified path, but in "posix" form
with slash-separators.)
On *nix platforms, these changes should not matter.
---
sdk/tools/winesync/winesync.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/sdk/tools/winesync/winesync.py b/sdk/tools/winesync/winesync.py
index a517fa6bb12..652e4233e23 100644
--- a/sdk/tools/winesync/winesync.py
+++ b/sdk/tools/winesync/winesync.py
@@ -2,6 +2,7 @@
import sys
import os
+import posixpath
import string
import argparse
import subprocess
@@ -54,7 +55,7 @@ class wine_sync:
with open(module + '.cfg', 'r') as file_input:
self.module_cfg = yaml.safe_load(file_input)
- self.staged_patch_dir = os.path.join('sdk', 'tools', 'winesync', self.module + '_staging')
+ self.staged_patch_dir = posixpath.join('sdk', 'tools', 'winesync', self.module + '_staging')
def create_or_checkout_wine_branch(self, wine_tag, wine_staging_tag):
wine_branch_name = 'winesync-' + wine_tag + '-' + wine_staging_tag
@@ -110,7 +111,7 @@ class wine_sync:
wine_dir, wine_file = os.path.split(wine_path)
if wine_dir in self.module_cfg['directories']:
# we have a mapping for the directory
- return os.path.join(self.module_cfg['directories'][wine_dir], wine_file)
+ return posixpath.join(self.module_cfg['directories'][wine_dir], wine_file)
# no match
return None
@@ -228,7 +229,7 @@ class wine_sync:
os.mkdir(os.path.join(self.reactos_src, self.staged_patch_dir))
with open(patch_path, 'w') as file_output:
file_output.write(complete_patch)
- self.reactos_index.add(os.path.join(self.staged_patch_dir, patch_file_name))
+ self.reactos_index.add(posixpath.join(self.staged_patch_dir, patch_file_name))
self.reactos_index.write()
@@ -264,7 +265,7 @@ class wine_sync:
def revert_staged_patchset(self):
# revert all of this in one commit
- staged_patch_dir_path = os.path.join(self.reactos_src, self.staged_patch_dir)
+ staged_patch_dir_path = posixpath.join(self.reactos_src, self.staged_patch_dir)
if not os.path.isdir(staged_patch_dir_path):
return True
@@ -285,7 +286,7 @@ class wine_sync:
print('Please check, remove the offending patch with git rm, and relaunch this script')
return False
- self.reactos_index.remove(os.path.join(self.staged_patch_dir, patch_file_name))
+ self.reactos_index.remove(posixpath.join(self.staged_patch_dir, patch_file_name))
self.reactos_index.write()
os.remove(patch_path)