Skip to content

Commit

Permalink
Enhancements to package.py (#383)
Browse files Browse the repository at this point in the history
* Add architecture ID to the generated package files

* Use Chromium build timestamp (if present) for archive file members

* Use new file-exclusion feature of filescfg_generator() instead of
  deleting files from the build outputs

Also drop the bit from the GitHub automation that renames the package
files to include the architecture ID, as it is no longer needed, and
update build.py with new function arguments from the base u-c repo.
  • Loading branch information
iskunk authored Oct 10, 2024
1 parent a355549 commit 46b0e3b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
10 changes: 1 addition & 9 deletions .github/actions/stage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ async function run() {
const globber = await glob.create('C:\\ungoogled-chromium-windows\\build\\ungoogled-chromium*',
{matchDirectories: false});
let packageList = await globber.glob();
packageList = await Promise.all(packageList.map(async x => {
const part1 = x.substring(0, x.length - 4);
const part2 = x86 ? '_x86' : '_x64';
const part3 = x.substring(x.length - 4, x.length);
const newPath = part1 + part2 + part3;
await io.mv(x, newPath);
return newPath;
}));
for (let i = 0; i < 5; ++i) {
try {
await artifactClient.uploadArtifact(x86 ? 'chromium-x86' : 'chromium', packageList,
Expand Down Expand Up @@ -80,4 +72,4 @@ async function run() {
}
}

run().catch(err => core.setFailed(err.message));
run().catch(err => core.setFailed(err.message));
12 changes: 6 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,16 @@ def main():
# Download chromium tarball
get_logger().info('Downloading chromium tarball...')
download_info = downloads.DownloadInfo([_ROOT_DIR / 'ungoogled-chromium' / 'downloads.ini'])
downloads.retrieve_downloads(download_info, downloads_cache, True, args.disable_ssl_verification)
downloads.retrieve_downloads(download_info, downloads_cache, None, True, args.disable_ssl_verification)
try:
downloads.check_downloads(download_info, downloads_cache)
downloads.check_downloads(download_info, downloads_cache, None)
except downloads.HashMismatchError as exc:
get_logger().error('File checksum does not match: %s', exc)
exit(1)

# Unpack chromium tarball
get_logger().info('Unpacking chromium tarball...')
downloads.unpack_downloads(download_info, downloads_cache, source_tree, None, extractors)
downloads.unpack_downloads(download_info, downloads_cache, None, source_tree, False, None, extractors)
else:
# Clone sources
subprocess.run([sys.executable, str(Path('ungoogled-chromium', 'utils', 'clone.py')), '-o', 'build\\src', '-p', 'win32' if args.x86 else 'win64'], check=True)
Expand All @@ -198,9 +198,9 @@ def main():
# Retrieve windows downloads
get_logger().info('Downloading required files...')
download_info_win = downloads.DownloadInfo([_ROOT_DIR / 'downloads.ini'])
downloads.retrieve_downloads(download_info_win, downloads_cache, True, args.disable_ssl_verification)
downloads.retrieve_downloads(download_info_win, downloads_cache, None, True, args.disable_ssl_verification)
try:
downloads.check_downloads(download_info_win, downloads_cache)
downloads.check_downloads(download_info_win, downloads_cache, None)
except downloads.HashMismatchError as exc:
get_logger().error('File checksum does not match: %s', exc)
exit(1)
Expand All @@ -217,7 +217,7 @@ def main():

# Unpack downloads
get_logger().info('Unpacking downloads...')
downloads.unpack_downloads(download_info_win, downloads_cache, source_tree, None, extractors)
downloads.unpack_downloads(download_info_win, downloads_cache, None, source_tree, False, None, extractors)

# Apply patches
# First, ungoogled-chromium-patches
Expand Down
47 changes: 35 additions & 12 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def _get_packaging_revision():
revision_path = Path(__file__).resolve().parent / 'revision.txt'
return revision_path.read_text(encoding=ENCODING).strip()

_cached_target_cpu = None

def _get_target_cpu(build_outputs):
global _cached_target_cpu
if not _cached_target_cpu:
with open(build_outputs / 'args.gn', 'r') as f:
args_gn_text = f.read()
for cpu in ('x64', 'x86'):
if f'target_cpu="{cpu}"' in args_gn_text:
_cached_target_cpu = cpu
break
assert _cached_target_cpu
return _cached_target_cpu

def main():
"""Entrypoint"""

Expand All @@ -45,26 +59,35 @@ def main():
'Default (from platform.architecture()): %(default)s'))
args = parser.parse_args()

build_outputs = Path('build/src/out/Default')

shutil.copyfile('build/src/out/Default/mini_installer.exe',
'build/ungoogled-chromium_{}-{}.{}_installer.exe'.format(
get_chromium_version(), _get_release_revision(), _get_packaging_revision()))
'build/ungoogled-chromium_{}-{}.{}_installer_{}.exe'.format(
get_chromium_version(), _get_release_revision(),
_get_packaging_revision(), _get_target_cpu(build_outputs)))

# We need to remove these files, or they'll end up in the zip files that will be generated.
os.remove('build/src/out/Default/mini_installer.exe')
os.remove('build/src/out/Default/mini_installer_exe_version.rc')
os.remove('build/src/out/Default/setup.exe')
timestamp = None
try:
os.remove('build/src/out/Default/chrome.packed.7z')
with open('build/src/build/util/LASTCHANGE.committime', 'r') as ct:
timestamp = int(ct.read())
except FileNotFoundError:
pass

build_outputs = Path('build/src/out/Default')
output = Path('build/ungoogled-chromium_{}-{}.{}_windows.zip'.format(
get_chromium_version(), _get_release_revision(), _get_packaging_revision()))
output = Path('build/ungoogled-chromium_{}-{}.{}_windows_{}.zip'.format(
get_chromium_version(), _get_release_revision(),
_get_packaging_revision(), _get_target_cpu(build_outputs)))

excluded_files = set([
Path('mini_installer.exe'),
Path('mini_installer_exe_version.rc'),
Path('setup.exe'),
Path('chrome.packed.7z'),
])
files_generator = filescfg.filescfg_generator(
Path('build/src/chrome/tools/build/win/FILES.cfg'), build_outputs, args.cpu_arch)
filescfg.create_archive(files_generator, tuple(), build_outputs, output)
Path('build/src/chrome/tools/build/win/FILES.cfg'),
build_outputs, args.cpu_arch, excluded_files)
filescfg.create_archive(
files_generator, tuple(), build_outputs, output, timestamp)

if __name__ == '__main__':
main()

0 comments on commit 46b0e3b

Please sign in to comment.