Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions scripts/release/homebrew/docker/formula_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
import bisect
import argparse

TEMPLATE_FILE_NAME='formula_template.txt'
CLI_VERSION=os.environ['CLI_VERSION']
HOMEBREW_UPSTREAM_URL=os.environ['HOMEBREW_UPSTREAM_URL']
HOMEBREW_FORMULAR_LATEST="https://raw.githubusercontent.com/Homebrew/homebrew-core/c882489d4cb39ca004387f0c5ef1a767046c68d6/Formula/azure-cli.rb"
TEMPLATE_FILE_NAME = 'formula_template.txt'
CLI_VERSION = os.environ['CLI_VERSION']
HOMEBREW_UPSTREAM_URL = os.environ['HOMEBREW_UPSTREAM_URL']
HOMEBREW_FORMULAR_LATEST = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/a/azure-cli.rb"
Copy link
Contributor Author

@bebound bebound Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formula was moved to /a in Homebrew/homebrew-core#138921



def main():
print('Generate formula for Azure CLI homebrew release.')

parser = argparse.ArgumentParser(prog='formula_generator.py')
parser.set_defaults(func=generate_formula)
parser.add_argument('-b', dest='build_method', choices=['update_existing', 'use_template'], help='The build method, default is update_existing, the other option is use_template.')
parser.add_argument('-b', dest='build_method', choices=['update_existing', 'use_template'],
help='The build method, default is update_existing, the other option is use_template.')
args = parser.parse_args()
args.func(**vars(args))


def generate_formula(build_method: str, **_):
content = ''
if build_method is None or build_method == 'update_existing':
Expand Down Expand Up @@ -82,7 +84,8 @@ def collect_resources() -> str:

def collect_resources_dict() -> dict:
nodes = make_graph('azure-cli')
filtered_nodes = {nodes[node_name]['name']: nodes[node_name] for node_name in sorted(nodes) if resource_filter(node_name)}
filtered_nodes = {nodes[node_name]['name']: nodes[node_name] for node_name in sorted(nodes) if
resource_filter(node_name)}
return filtered_nodes


Expand Down Expand Up @@ -126,11 +129,6 @@ def update_formula() -> str:
upstream_sha = compute_sha256(HOMEBREW_UPSTREAM_URL)
text = re.sub('sha256 ".*"', 'sha256 "{}"'.format(upstream_sha), text, 1)
text = re.sub('.*revision.*\n', '', text, 1) # remove revision for previous version if exists

# include pip when creating venv, see https://github.com/Homebrew/brew/pull/15792
# this can be removed after Homebrew merges our PR
text = re.sub('system_site_packages: false', 'system_site_packages: false, without_pip: false', text, 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is introduced in #27186, remove it as latest formula contains this change.

pack = None
packs_to_remove = set()
lines = text.split('\n')
Expand All @@ -153,7 +151,7 @@ def update_formula() -> str:
node_index_dict[pack] = idx
elif pack is not None:
if line.startswith(" url"):
#update the url of package
# update the url of package
if pack in nodes.keys():
url_match = re.search(r'url "(.*)"', line)
if url_match is not None and nodes[pack]['url'] != url_match.group(1):
Expand All @@ -162,7 +160,7 @@ def update_formula() -> str:
else:
packs_to_remove.add(pack)
elif line.startswith(" sha256"):
#update the sha256 of package
# update the sha256 of package
if pack in nodes.keys():
lines[idx] = re.sub('sha256 ".*"', 'sha256 "{}"'.format(nodes[pack]['checksum']), line, 1)
del nodes[pack]
Expand Down