common-updater-scripts,directoryListingUpdater: add extraRegex parameter

This commit is contained in:
Francesco Gazzetta 2022-12-10 15:19:50 +01:00
parent c1188a559b
commit 19e4b53b09
2 changed files with 7 additions and 2 deletions

View File

@ -11,9 +11,10 @@
, odd-unstable ? false , odd-unstable ? false
, patchlevel-unstable ? false , patchlevel-unstable ? false
, url ? null , url ? null
, extraRegex ? null
}: }:
genericUpdater { genericUpdater {
inherit pname version attrPath ignoredVersions rev-prefix odd-unstable patchlevel-unstable; inherit pname version attrPath ignoredVersions rev-prefix odd-unstable patchlevel-unstable;
versionLister = "${common-updater-scripts}/bin/list-directory-versions ${lib.optionalString (url != null) "--url=${lib.escapeShellArg url}"}"; versionLister = "${common-updater-scripts}/bin/list-directory-versions ${lib.optionalString (url != null) "--url=${lib.escapeShellArg url}"} ${lib.optionalString (extraRegex != null) "--extra-regex=${lib.escapeShellArg extraRegex}"}";
} }

View File

@ -26,6 +26,8 @@ parser.add_argument(
parser.add_argument("--url", help="url of the page that lists the package versions") parser.add_argument("--url", help="url of the page that lists the package versions")
parser.add_argument("--file", help="file name for writing debugging information") parser.add_argument("--file", help="file name for writing debugging information")
parser.add_argument("--extra-regex", help="additional regex to filter versions with")
if __name__ == "__main__": if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
@ -62,4 +64,6 @@ if __name__ == "__main__":
rf"(.*/)?{args.pname}-([\d.]+?(-[\d\w.-]+?)?)(\.tar)?(\.[^.]*)", link_url rf"(.*/)?{args.pname}-([\d.]+?(-[\d\w.-]+?)?)(\.tar)?(\.[^.]*)", link_url
) )
if match: if match:
print(match.group(2)) version = match.group(2)
if (not args.extra_regex) or re.fullmatch(args.extra_regex, version):
print(version)