Skip to content

Commit

Permalink
Merge pull request #181 from mozilla/fix-180
Browse files Browse the repository at this point in the history
fix(project): Fix firefox downloader script for update tests.
  • Loading branch information
b4handjr authored Dec 18, 2024
2 parents cb0153b + f565837 commit 21d5325
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 71 deletions.
58 changes: 34 additions & 24 deletions Dockerfile.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# 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/.

FROM ubuntu:mantic as moz-central
FROM python:3-slim as moz-central

RUN apt-get -qq update && apt-get -qq install -y git

RUN git clone https://github.com/mozilla/gecko-dev.git --depth 1

FROM ubuntu:mantic
FROM python:3-slim

USER root

Expand All @@ -26,25 +26,35 @@ ENV DEBIAN_FRONTEND=noninteractive \

# Install requirements to install tools
RUN dependencies=' \
bzip2 \
ca-certificates \
curl \
firefox \
python3-pip \
python3-setuptools \
python3-wheel \
sudo \
wget \
build-essential \
gcc \
python3 \
tox \
pipx \
libgtk-3-dev \
libasound2 \
libdbus-glib-1-dev \
xvfb \
libgl1-mesa-dri \
bzip2 \
curl \
gcc \
gnupg2 \
libasound2 \
libatspi2.0-0 \
libdbus-glib-1-2 \
libdrm2 \
libfontconfig1 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgbm1 \
libglib2.0-0 \
libgtk-3-0 \
libgconf-2-4 \
libnss3 \
libxt6 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrender1 \
libxext6 \
libxrandr2 \
musl-dev \
wget \
xauth \
xvfb \
xz-utils \
' \
&& set -x \
&& apt-get -qq update && apt-get -qq install -y software-properties-common \
Expand All @@ -63,10 +73,10 @@ WORKDIR /code

# Download Firefox
ARG FIREFOX_DOWNLOAD_URL=https://download.mozilla.org/?product=firefox${FIREFOX_VERSION}-latest-ssl&lang=en-US&os=linux64
RUN wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \
RUN wget --no-verbose -O /tmp/firefox $FIREFOX_DOWNLOAD_URL \
&& rm -rf /opt/firefox \
&& tar -C /opt -xjf /tmp/firefox.tar.bz2 \
&& rm /tmp/firefox.tar.bz2 \
&& tar -C /opt -xf /tmp/firefox \
&& rm /tmp/firefox \
&& ln -fs /opt/firefox/firefox /usr/bin/firefox

# @hackebrot
Expand Down
128 changes: 120 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ beautifulsoup4 = "^4.12.3"
pytest-repeat = "^0.9.3"
flask = "^3.1.0"
python-dateutil = "^2.9.0.post0"
tox = "^4.23.2"

[build-system]
requires = ["poetry-core"]
Expand Down
52 changes: 13 additions & 39 deletions utilities/download_old_firefox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import date
from datetime import date, timedelta
import re

import requests
Expand All @@ -7,45 +7,19 @@
if __name__ == "__main__":
base_url = "https://download-installer.cdn.mozilla.net"
today = date.today()
# Set correct month for URL builder
if len(f"{today.month}") < 2:
current_month = f"0{today.month}"
else:
current_month = f"{today.month}"

# Set correct month for URL builder
if len(f"{today.day}") < 2 and int(today.day - 5) < 0:
download_day = "01"
elif int(today.day) < 15:
download_day = f"0{today.day - 5}"
else:
download_day = f"{today.day - 5}"

download_month = f"{current_month}"

# if its a new month just grab the 28th day build of last month and build URL
if int(download_day) < 6:
if int(current_month) < 10:
download_month = f"0{int(current_month) - 1}"
else:
download_month = f"{int(current_month) - 1}"
download_dir = f"{base_url}/pub/firefox/nightly/{today.year}/{download_month}/"
html = requests.get(download_dir)

soup = BeautifulSoup(html.text, "html.parser")
page_link = soup.find_all(
href=re.compile(f"{today.year}-{download_month}-28.*-mozilla-central")
)
else:
download_dir = f"{base_url}/pub/firefox/nightly/{today.year}/{download_month}/"
html = requests.get(download_dir)

soup = BeautifulSoup(html.text, "html.parser")
page_link = soup.find_all(
href=re.compile(
f"{today.year}-{download_month}-{download_day}.*-mozilla-central"
)
download_date = today - timedelta(weeks=4)
download_date = download_date.replace(day=15)


download_dir = f"{base_url}/pub/firefox/nightly/{download_date.year}/{download_date.month}/"
html = requests.get(download_dir)

soup = BeautifulSoup(html.text, "html.parser")
page_link = soup.find_all(
href=re.compile(
f"{download_date.year}-{download_date.month}-{download_date.day}.*-mozilla-central"
)
)
page_link = page_link[1]

html = requests.get(f'{base_url}{page_link["href"]}')
Expand Down

0 comments on commit 21d5325

Please sign in to comment.