Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom naming and repository #359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion emu/containers/emulator_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class EmulatorContainer(DockerContainer):
NO_METRICS_MESSAGE = "No metrics are collected when running this container."

def __init__(
self, emulator, system_image_container, repository=None, metrics=False, extra=""
self, emulator, system_image_container, repository=None, metrics=False, extra="", name=None
):
self.emulator_zip = AndroidReleaseZip(emulator)
self.system_image_container = system_image_container
self.metrics = metrics
self.name = name

if type(extra) is list:
extra = " ".join([f'"{s}"' for s in extra])
Expand Down Expand Up @@ -100,6 +101,9 @@ def write(self, dest):
self.emulator_zip.extract(os.path.join(dest, "emu"))

def image_name(self):
if self.name:
return self.name

name = "{}-{}-{}".format(
self.props["ro.build.version.sdk"],
self.props["qemu.short_tag"],
Expand Down
5 changes: 4 additions & 1 deletion emu/emu_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_docker_image(args):
continue

emu_docker = EmulatorContainer(
emulator, sys_docker, args.repo, cfg.collect_metrics(), args.extra
emulator, sys_docker, args.repo, cfg.collect_metrics(), args.extra, args.name
)
emu_docker.build(Path(args.dest) / "emulator")

Expand Down Expand Up @@ -255,6 +255,9 @@ def main():
create_parser.add_argument(
"--sys", action="store_true", help="Process system image layer only."
)
create_parser.add_argument(
"--name", help="Name to give image when pushed.", default=None
)
create_parser.set_defaults(func=create_docker_image)

create_inter = subparsers.add_parser(
Expand Down
19 changes: 11 additions & 8 deletions emu/emu_downloads_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
from emu.utils import download
from emu.docker_config import DockerConfig

ANDROID_REPOSITORY = os.environ.get("ANDROID_REPOSITORY", "https://dl.google.com/")

SYSIMG_REPOS = [
"https://dl.google.com/android/repository/sys-img/android/sys-img2-1.xml",
"https://dl.google.com/android/repository/sys-img/google_apis/sys-img2-1.xml",
"https://dl.google.com/android/repository/sys-img/google_apis_playstore/sys-img2-1.xml",
"https://dl.google.com/android/repository/sys-img/google_atd/sys-img2-1.xml",
"https://dl.google.com/android/repository/sys-img/android-tv/sys-img2-1.xml",
"%s/android/repository/sys-img/android/sys-img2-1.xml" % ANDROID_REPOSITORY,
"%s/android/repository/sys-img/google_apis/sys-img2-1.xml" % ANDROID_REPOSITORY,
"%s/android/repository/sys-img/google_apis_playstore/sys-img2-1.xml" % ANDROID_REPOSITORY,
"%s/android/repository/sys-img/google_atd/sys-img2-1.xml" % ANDROID_REPOSITORY,
"%s/android/repository/sys-img/android-tv/sys-img2-1.xml" % ANDROID_REPOSITORY,
]

EMU_REPOS = ["https://dl.google.com/android/repository/repository2-1.xml"]
EMU_REPOS = ["%s/android/repository/repository2-1.xml" % ANDROID_REPOSITORY]

CHANNEL_MAPPING = {
"channel-0": "stable",
Expand Down Expand Up @@ -161,7 +163,8 @@ def __init__(self, pkg, licenses):
url_element = pkg.find(".//url")
self.zip = url_element.text

self.url = "https://dl.google.com/android/repository/sys-img/%s/%s" % (
self.url = "%s/android/repository/sys-img/%s/%s" % (
ANDROID_REPOSITORY,
self.tag,
self.zip,
)
Expand Down Expand Up @@ -214,7 +217,7 @@ def __init__(self, pkg, licenses):
for archive in archives:
url = archive.find(".//url").text
hostos = archive.find("host-os").text
self.urls[hostos] = "https://dl.google.com/android/repository/%s" % url
self.urls[hostos] = "%s/android/repository/%s" % (ANDROID_REPOSITORY, url)

def download_name(self):
return "emulator-{}.zip".format(self.version)
Expand Down
4 changes: 3 additions & 1 deletion emu/platform_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import zipfile
from pathlib import Path

from emu.utils import download

ANDROID_REPOSITORY = os.environ.get("ANDROID_REPOSITORY", "https://dl.google.com")

class PlatformTools(object):
"""The platform tools zip file. It will be downloaded on demand."""

# Platform tools, needed to get adb.
PLATFORM_TOOLS_URL = (
"https://dl.google.com/android/repository/platform-tools_r29.0.5-linux.zip"
'%s/android/repository/platform-tools_r29.0.5-linux.zip' % ANDROID_REPOSITORY
)
PLATFORM_TOOLS_ZIP = "platform-tools-latest-linux.zip"

Expand Down