# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/.
import datetime import json import os import shutil import subprocess import tarfile import tempfile import zipfile from email.utils import format_datetime from pathlib import Path from string import Template
import mozfile import mozpack.path as mozpath from mozilla_version.gecko import GeckoVersion
from mozbuild.repackaging.application_ini import get_application_ini_values from mozbuild.repackaging.desktop_file import generate_browser_desktop_entry_file_text
class NoDebPackageFound(Exception): """Raised when no .deb is found after calling dpkg-buildpackage"""
def __init__(self, deb_file_path) -> None:
super().__init__(
f"No {deb_file_path} package found after calling dpkg-buildpackage"
)
class HgServerError(Exception): """Raised when Hg responds with an error code that is not 404 (i.e. when there is an outage)"""
# Maps our CI/release pipeline's architecture names (e.g., "x86_64") # into architectures ("amd64") compatible with Debian's dpkg-buildpackage tool. # This is the target architecture we are building the .deb package for.
_DEB_ARCH = { "all": "all", "x86": "i386", "x86_64": "amd64", "aarch64": "arm64",
}
# Defines the sysroot (build host's) architecture for each target architecture in the pipeline. # It defines the architecture dpkg-buildpackage runs on.
_DEB_SYSROOT_ARCH = { "all": "amd64", "x86": "i386", "x86_64": "amd64", "aarch64": "amd64",
}
# Assigns the Debian distribution version for the sysroot based on the target architecture. # It defines the Debian distribution dpkg-buildpackage runs on.
_DEB_SYSROOT_DIST = { "all": "jessie", "x86": "jessie", "x86_64": "jessie", "aarch64": "buster",
}
def repackage_deb(
log,
infile,
output,
template_dir,
arch,
version,
build_number,
release_product,
release_type,
fluent_localization,
fluent_resource_loader,
): ifnot tarfile.is_tarfile(infile): raise Exception("Input file %s is not a valid tarfile." % infile)
app_name = application_ini_data["name"] with open(
mozpath.join(source_dir, app_name.lower(), "is-packaged-app"), "w"
) as f:
f.write("This is a packaged app.\n")
def _extract_application_ini_data(input_tar_file): with tempfile.TemporaryDirectory() as d: with tarfile.open(input_tar_file) as tar:
application_ini_files = [
tar_info for tar_info in tar.getmembers() if tar_info.name.endswith("/application.ini")
] if len(application_ini_files) == 0: raise ValueError(
f"Cannot find any application.ini file in archive {input_tar_file}"
) if len(application_ini_files) > 1: raise ValueError(
f"Too many application.ini files found in archive {input_tar_file}. "
f"Found: {application_ini_files}"
)
template_dir_filenames = os.listdir(input_template_dir)
template_filenames = [
mozpath.basename(filename) for filename in template_dir_filenames if filename.endswith(".in") and filename notin exclude_file_names
]
os.makedirs(mozpath.join(source_dir, "debian"), exist_ok=True)
for file_name in template_filenames: with open(mozpath.join(input_template_dir, file_name)) as f:
template = Template(f.read()) with open(mozpath.join(source_dir, "debian", Path(file_name).stem), "w") as f:
f.write(template.substitute(build_variables))
# Check to see if a distribution.ini file is already supplied in the debian templates directory # If not, continue to download default Firefox distribution.ini from GitHub if os.path.exists(distribution_ini_path):
os.makedirs(
mozpath.join(source_dir, app_name.lower(), "distribution"), exist_ok=True
)
shutil.move(
distribution_ini_path,
mozpath.join(source_dir, app_name.lower(), "distribution"),
)
return
with tempfile.TemporaryDirectory() as git_clone_dir:
subprocess.check_call(
[ "git", "clone", "https://github.com/mozilla-partners/deb.git",
git_clone_dir,
],
)
shutil.copytree(
mozpath.join(git_clone_dir, "desktop/deb/distribution"),
mozpath.join(source_dir, app_name.lower(), "distribution"),
)
# Check to see if a .desktop file is already supplied in the debian templates directory # If not, continue to generate default Firefox .desktop file if os.path.exists(desktop_entry_template_path):
shutil.move(
desktop_entry_template_path,
mozpath.join(source_dir, "debian", desktop_entry_file_filename),
)
def _get_command(arch):
deb_arch = _DEB_ARCH[arch]
command = [ "dpkg-buildpackage", # TODO: Use long options once we stop supporting Debian Jesse. They're more # explicit. # # Long options were added in dpkg 1.18.8 which is part of Debian Stretch. # # https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?h=1.18.x&id=293bd243a19149165fc4fd8830b16a51d471a5e9 # https://packages.debian.org/stretch/dpkg-dev "-us", # --unsigned-source "-uc", # --unsigned-changes "-b", # --build=binary
]
if deb_arch != "all":
command.append(f"--host-arch={deb_arch}")
def _get_chroot_path(arch): # At the moment the Firefox build baseline for i386 and amd64 is jessie and the baseline for arm64 is buster. # These baselines are defined in taskcluster/scripts/misc/build-sysroot.sh # The debian-repackage image defined in taskcluster/docker/debian-repackage/Dockerfile # bootstraps /srv/jessie-i386, /srv/jessie-amd64, and /srv/buster-amd64 roots. # We use these roots to run the repackage step and generate shared # library dependencies that match the Firefox build baseline.
deb_sysroot_dist = _DEB_SYSROOT_DIST[arch]
deb_sysroot_arch = _DEB_SYSROOT_ARCH[arch] return f"/srv/{deb_sysroot_dist}-{deb_sysroot_arch}"
_MANIFEST_FILE_NAME = "manifest.json"
def _extract_langpack_metadata(input_xpi_file): with tempfile.TemporaryDirectory() as d: with zipfile.ZipFile(input_xpi_file) as zip:
zip.extract(_MANIFEST_FILE_NAME, path=d)
with open(mozpath.join(d, _MANIFEST_FILE_NAME)) as f: return json.load(f)
Messung V0.5
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.