@ -119,13 +119,25 @@ def parse_patch_url(patch_url: str) -> T.Tuple[str, str]:
else :
else :
raise WrapException ( f ' Invalid wrapdb URL { patch_url } ' )
raise WrapException ( f ' Invalid wrapdb URL { patch_url } ' )
def get_current_version ( wrapfile : str ) - > T . Tuple [ str , str , str , str , str ] :
def get_current_version ( wrapfile : str ) - > T . Tuple [ str , str , str , str , T . Optional [ str ] ] :
cp = configparser . ConfigParser ( interpolation = None )
cp = configparser . ConfigParser ( interpolation = None )
cp . read ( wrapfile )
cp . read ( wrapfile )
wrap_data = cp [ ' wrap-file ' ]
try :
patch_url = wrap_data [ ' patch_url ' ]
wrap_data = cp [ ' wrap-file ' ]
branch , revision = parse_patch_url ( patch_url )
except KeyError :
return branch , revision , wrap_data [ ' directory ' ] , wrap_data [ ' source_filename ' ] , wrap_data [ ' patch_filename ' ]
raise WrapException ( f ' Not a wrap-file, cannot have come from the wrapdb ' )
try :
patch_url = wrap_data [ ' patch_url ' ]
except KeyError :
# We assume a wrap without a patch_url is probably just an pointer to upstream's
# build files. The version should be in the tarball filename, even if it isn't
# purely guaranteed. The wrapdb revision should be 1 because it just needs uploading once.
branch = mesonlib . search_version ( wrap_data [ ' source_filename ' ] )
revision , patch_filename = ' 1 ' , None
else :
branch , revision = parse_patch_url ( patch_url )
patch_filename = wrap_data [ ' patch_filename ' ]
return branch , revision , wrap_data [ ' directory ' ] , wrap_data [ ' source_filename ' ] , patch_filename
def update_wrap_file ( wrapfile : str , name : str , new_version : str , new_revision : str ) - > None :
def update_wrap_file ( wrapfile : str , name : str , new_version : str , new_revision : str ) - > None :
url = urlopen ( f ' https://wrapdb.mesonbuild.com/v2/ { name } _ { new_version } - { new_revision } / { name } .wrap ' )
url = urlopen ( f ' https://wrapdb.mesonbuild.com/v2/ { name } _ { new_version } - { new_revision } / { name } .wrap ' )
@ -150,10 +162,11 @@ def update(options: 'argparse.Namespace') -> None:
os . unlink ( os . path . join ( ' subprojects/packagecache ' , src_file ) )
os . unlink ( os . path . join ( ' subprojects/packagecache ' , src_file ) )
except FileNotFoundError :
except FileNotFoundError :
pass
pass
try :
if patch_file is not None :
os . unlink ( os . path . join ( ' subprojects/packagecache ' , patch_file ) )
try :
except FileNotFoundError :
os . unlink ( os . path . join ( ' subprojects/packagecache ' , patch_file ) )
pass
except FileNotFoundError :
pass
print ( f ' Updated { name } version { new_branch } revision { new_revision } ' )
print ( f ' Updated { name } version { new_branch } revision { new_revision } ' )
def info ( options : ' argparse.Namespace ' ) - > None :
def info ( options : ' argparse.Namespace ' ) - > None :