llvmPackages_git: Abort updates if no new version is available
No need to fetch the source tarball in this case.
This commit is contained in:
parent
34e5bf44fb
commit
5bda21e362
1 changed files with 18 additions and 2 deletions
|
@ -7,12 +7,16 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
from codecs import iterdecode
|
from codecs import iterdecode
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.request import urlopen, Request
|
from urllib.request import urlopen, Request
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_NIX = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'git/default.nix')
|
||||||
|
|
||||||
|
|
||||||
def get_latest_chromium_build():
|
def get_latest_chromium_build():
|
||||||
HISTORY_URL = 'https://omahaproxy.appspot.com/history?os=linux'
|
HISTORY_URL = 'https://omahaproxy.appspot.com/history?os=linux'
|
||||||
print(f'GET {HISTORY_URL}')
|
print(f'GET {HISTORY_URL}')
|
||||||
|
@ -39,6 +43,16 @@ def get_commit(ref):
|
||||||
return json.loads(http_response.read().decode())
|
return json.loads(http_response.read().decode())
|
||||||
|
|
||||||
|
|
||||||
|
def get_current_revision():
|
||||||
|
"""Get the current revision of llvmPackages_git."""
|
||||||
|
with open(DEFAULT_NIX) as f:
|
||||||
|
for line in f:
|
||||||
|
rev = re.search(r'^ rev = "(.*)";', line)
|
||||||
|
if rev:
|
||||||
|
return rev.group(1)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def nix_prefetch_url(url, algo='sha256'):
|
def nix_prefetch_url(url, algo='sha256'):
|
||||||
"""Prefetches the content of the given URL."""
|
"""Prefetches the content of the given URL."""
|
||||||
print(f'nix-prefetch-url {url}')
|
print(f'nix-prefetch-url {url}')
|
||||||
|
@ -55,13 +69,15 @@ clang_revision = re.search(r"^CLANG_REVISION = '(.+)'$", clang_update_script, re
|
||||||
clang_commit_short = re.search(r"llvmorg-[0-9]+-init-[0-9]+-g([0-9a-f]{8})", clang_revision).group(1)
|
clang_commit_short = re.search(r"llvmorg-[0-9]+-init-[0-9]+-g([0-9a-f]{8})", clang_revision).group(1)
|
||||||
release_version = re.search(r"^RELEASE_VERSION = '(.+)'$", clang_update_script, re.MULTILINE).group(1)
|
release_version = re.search(r"^RELEASE_VERSION = '(.+)'$", clang_update_script, re.MULTILINE).group(1)
|
||||||
commit = get_commit(clang_commit_short)
|
commit = get_commit(clang_commit_short)
|
||||||
|
if get_current_revision() == commit["sha"]:
|
||||||
|
print('No new update available.')
|
||||||
|
sys.exit(0)
|
||||||
date = datetime.fromisoformat(commit['commit']['committer']['date'].rstrip('Z')).date().isoformat()
|
date = datetime.fromisoformat(commit['commit']['committer']['date'].rstrip('Z')).date().isoformat()
|
||||||
version = f'unstable-{date}'
|
version = f'unstable-{date}'
|
||||||
print('Prefetching source tarball...')
|
print('Prefetching source tarball...')
|
||||||
hash = nix_prefetch_url(f'https://github.com/llvm/llvm-project/archive/{commit["sha"]}.tar.gz')
|
hash = nix_prefetch_url(f'https://github.com/llvm/llvm-project/archive/{commit["sha"]}.tar.gz')
|
||||||
print('Updating default.nix...')
|
print('Updating default.nix...')
|
||||||
default_nix = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'git/default.nix')
|
with fileinput.FileInput(DEFAULT_NIX, inplace=True) as f:
|
||||||
with fileinput.FileInput(default_nix, inplace=True) as f:
|
|
||||||
for line in f:
|
for line in f:
|
||||||
result = re.sub(r'^ release_version = ".+";', f' release_version = "{release_version}";', line)
|
result = re.sub(r'^ release_version = ".+";', f' release_version = "{release_version}";', line)
|
||||||
result = re.sub(r'^ rev = ".*";', f' rev = "{commit["sha"]}";', result)
|
result = re.sub(r'^ rev = ".*";', f' rev = "{commit["sha"]}";', result)
|
||||||
|
|
Loading…
Reference in a new issue