Added recipes for curl, libidn2, libpsl and libunistring.
This commit is contained in:
70
recipes/psl/recipe.py
Normal file
70
recipes/psl/recipe.py
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
from SCons.Script import *
|
||||
|
||||
_VERSIONS_URL = 'https://api.github.com/repos/rockdaboot/libpsl/releases'
|
||||
_VERSION_PATTERN = re.compile(r'^Release v([0-9]+)\.([0-9]+)\.([0-9]+)$')
|
||||
|
||||
def versions(env: Environment, update: bool = False):
|
||||
versions_file = os.path.join(env['DOWNLOAD_DIR'], 'libpsl_versions.json')
|
||||
if update or not os.path.exists(versions_file):
|
||||
req = requests.get(_VERSIONS_URL)
|
||||
versions_data = json.loads(req.text)
|
||||
result = []
|
||||
for version_data in versions_data:
|
||||
match = _VERSION_PATTERN.match(version_data['name'])
|
||||
if not match:
|
||||
continue
|
||||
result.append((int(match.groups()[0]), int(match.groups()[1]), int(match.groups()[2])))
|
||||
with open(versions_file, 'w') as f:
|
||||
json.dump(result, f)
|
||||
return result
|
||||
else:
|
||||
try:
|
||||
with open(versions_file, 'r') as f:
|
||||
return [tuple(v) for v in json.load(f)]
|
||||
except:
|
||||
print('libpsl_versions.json is empty or broken, redownloading.')
|
||||
return versions(env, update=True)
|
||||
|
||||
def dependencies(env: Environment, version) -> 'dict':
|
||||
return {
|
||||
'idn2': {},
|
||||
'unistring': {}
|
||||
}
|
||||
|
||||
def cook(env: Environment, version) -> dict:
|
||||
url = f'https://github.com/rockdaboot/libpsl/releases/download/{version[0]}.{version[1]}.{version[2]}/libpsl-{version[0]}.{version[1]}.{version[2]}.tar.gz'
|
||||
repo = env.DownloadAndExtract(f'libpsl_{version[0]}.{version[1]}.{version[2]}', url = url, skip_folders = 1)
|
||||
checkout_root = repo['extracted_root']
|
||||
build_result = env.AutotoolsProject(checkout_root)
|
||||
return {
|
||||
'CPPPATH': build_result['CPPPATH'],
|
||||
'LIBS': [env.FindLib('psl', paths=build_result['LIBPATH'])]
|
||||
}
|
||||
|
||||
#def _git_cook(env: Environment, repo: dict) -> dict:
|
||||
# checkout_root = repo['checkout_root']
|
||||
# subprocess.run((os.path.join(checkout_root, 'autogen.sh'),), cwd=checkout_root)
|
||||
# build_result = env.AutotoolsProject(checkout_root)
|
||||
# return {
|
||||
# 'CPPPATH': build_result['CPPPATH'],
|
||||
# 'LIBS': [env.FindLib('psl', paths=build_result['LIBPATH'])]
|
||||
# }
|
||||
#
|
||||
#env.GitRecipe(
|
||||
# globals = globals(),
|
||||
# repo_name = 'psl',
|
||||
# repo_url = 'https://github.com/rockdaboot/libpsl.git',
|
||||
# tag_pattern = re.compile(r'^libpsl-([0-9]+)\.([0-9]+)\.([0-9]+)$'),
|
||||
# tag_fn = lambda version: f'libpsl-{version[0]}.{version[1]}.{version[2]}',
|
||||
# cook_fn = _git_cook,
|
||||
# dependencies = {
|
||||
# 'idn2': {},
|
||||
# 'unistring': {}
|
||||
# }
|
||||
#)
|
||||
Reference in New Issue
Block a user