4 # Future products supporting Flatpaks will set this accordingly
5 : PRODUCT
"${PRODUCT:=firefox}"
7 # Required env variables
11 test "$CANDIDATES_DIR"
12 test "$L10N_CHANGESETS"
13 test "$FLATPAK_BRANCH"
15 # Optional env variables
16 : WORKSPACE
"${WORKSPACE:=/home/worker/workspace}"
17 : ARTIFACTS_DIR
"${ARTIFACTS_DIR:=/home/worker/artifacts}"
21 # XXX: this is used to populate the datetime in org.mozilla.firefox.appdata.xml
22 DATE
=$
(date +%Y-
%m-
%d
)
25 SCRIPT_DIRECTORY
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" && pwd )"
26 TARGET_TAR_XZ_FULL_PATH
="$ARTIFACTS_DIR/target.flatpak.tar.xz"
27 SOURCE_DEST
="${WORKSPACE}/source"
29 # When updating this, please make sure to keep in sync the script for symbol
31 # https://github.com/mozilla/symbol-scrapers/blob/master/firefox-flatpak/script.sh
32 FREEDESKTOP_VERSION
="23.08"
33 FIREFOX_BASEAPP_CHANNEL
="23.08"
36 # XXX: these commands are temporarily, there's an upcoming fix in the upstream Docker image
37 # that we work on top of, from `freedesktopsdk`, that will make these two lines go away eventually
38 mkdir
-p /root
/tmp
/var
/tmp
39 mkdir
-p "$ARTIFACTS_DIR"
40 rm -rf "$SOURCE_DEST" && mkdir
-p "$SOURCE_DEST"
42 # XXX ensure we have a clean slate in the local flatpak repo
43 rm -rf ~
/.local
/share
/flatpak
/
46 CURL
="curl --location --retry 10 --retry-delay 10"
48 # Download en-US linux64 binary
49 $CURL -o "${WORKSPACE}/firefox.tar.bz2" \
50 "${CANDIDATES_DIR}/${VERSION}-candidates/build${BUILD_NUMBER}/linux-x86_64/en-US/firefox-${VERSION}.tar.bz2"
52 # Use list of locales to fetch L10N XPIs
53 $CURL -o "${WORKSPACE}/l10n_changesets.json" "$L10N_CHANGESETS"
54 locales
=$
(python3
"$SCRIPT_DIRECTORY/extract_locales_from_l10n_json.py" "${WORKSPACE}/l10n_changesets.json")
56 DISTRIBUTION_DIR
="$SOURCE_DEST/distribution"
57 if [[ "$PRODUCT" == "firefox" ]]; then
58 # Get Flatpak configuration
59 PARTNER_CONFIG_DIR
="$WORKSPACE/partner_config"
60 git clone https
://github.com
/mozilla-partners
/flatpak.git
"$PARTNER_CONFIG_DIR"
61 mv "$PARTNER_CONFIG_DIR/desktop/flatpak/distribution" "$DISTRIBUTION_DIR"
63 mkdir
-p "$DISTRIBUTION_DIR"
66 mkdir
-p "$DISTRIBUTION_DIR/extensions"
67 for locale
in $locales; do
68 $CURL -o "$DISTRIBUTION_DIR/extensions/langpack-${locale}@firefox.mozilla.org.xpi" \
69 "$CANDIDATES_DIR/${VERSION}-candidates/build${BUILD_NUMBER}/linux-x86_64/xpi/${locale}.xpi"
72 envsubst
< "$SCRIPT_DIRECTORY/org.mozilla.firefox.appdata.xml.in" > "${WORKSPACE}/org.mozilla.firefox.appdata.xml"
73 cp -v "$SCRIPT_DIRECTORY/org.mozilla.firefox.desktop" "$WORKSPACE"
74 cp -v "$SCRIPT_DIRECTORY/launch-script.sh" "$WORKSPACE"
75 cp -v "$SCRIPT_DIRECTORY/firefox-symbolic.svg" "$WORKSPACE"
78 flatpak remote-add
--user --if-not-exists --from flathub https
://dl.flathub.org
/repo
/flathub.flatpakrepo
79 # XXX: added --user to `flatpak install` to avoid ambiguity
80 flatpak
install --user -y flathub org.mozilla.firefox.BaseApp
//${FIREFOX_BASEAPP_CHANNEL} --no-deps
82 # XXX: this command is temporarily, there's an upcoming fix in the upstream Docker image
83 # that we work on top of, from `freedesktopsdk`, that will make these two lines go away eventually
85 cp -r ~
/.local
/share
/flatpak
/app
/org.mozilla.firefox.BaseApp
/current
/active
/files build
/files
87 ARCH
=$
(flatpak
--default-arch)
88 cat <<EOF > build/metadata
90 name=org.mozilla.firefox
91 runtime=org.freedesktop.Platform/${ARCH}/${FREEDESKTOP_VERSION}
92 sdk=org.freedesktop.Sdk/${ARCH}/${FREEDESKTOP_VERSION}
93 base=app/org.mozilla.firefox.BaseApp/${ARCH}/${FIREFOX_BASEAPP_CHANNEL}
94 [Extension org.mozilla.firefox.Locale]
95 directory=share/runtime/langpack
99 [Extension org.freedesktop.Platform.ffmpeg-full]
103 version=${FREEDESKTOP_VERSION}
105 [Extension org.mozilla.firefox.systemconfig]
106 directory=etc/firefox
110 cat <<EOF > build/metadata.locale
112 name=org.mozilla.firefox.Locale
115 ref=app/org.mozilla.firefox/${ARCH}/${FLATPAK_BRANCH}
119 install -d "${appdir}/lib/"
120 (cd "${appdir}/lib/" && tar jxf
"${WORKSPACE}/firefox.tar.bz2")
121 install -D -m644 -t "${appdir}/share/appdata" org.mozilla.firefox.appdata.xml
122 install -D -m644 -t "${appdir}/share/applications" org.mozilla.firefox.desktop
123 for size
in 16 32 48 64 128; do
124 install -D -m644 "${appdir}/lib/firefox/browser/chrome/icons/default/default${size}.png" "${appdir}/share/icons/hicolor/${size}x${size}/apps/org.mozilla.firefox.png"
126 install -D -m644 firefox-symbolic.svg
"${appdir}/share/icons/hicolor/symbolic/apps/org.mozilla.firefox-symbolic.svg"
127 mkdir
-p "${appdir}/lib/ffmpeg"
128 mkdir
-p "${appdir}/etc/firefox"
130 appstream-compose
--prefix="${appdir}" --origin=flatpak
--basename=org.mozilla.firefox org.mozilla.firefox
131 appstream-util mirror-screenshots
"${appdir}"/share/app-info/xmls/org.mozilla.firefox.xml.gz "https://dl.flathub.org/repo/screenshots/org.mozilla.firefox-${FLATPAK_BRANCH}" build/screenshots "build/screenshots/org.mozilla.firefox-${FLATPAK_BRANCH}"
133 # XXX: we used to `install -D` before which automatically created the components
134 # of target, now we need to manually do this since we're symlinking
135 mkdir
-p "${appdir}/lib/firefox/distribution/extensions"
136 # XXX: we put the langpacks in /app/share/locale/$LANG_CODE and symlink that
137 # directory to where Firefox looks them up; this way only subset configured
138 # on user system is downloaded vs all locales
139 for locale
in $locales; do
140 install -D -m644 -t "${appdir}/share/runtime/langpack/${locale%%-*}/" "${DISTRIBUTION_DIR}/extensions/langpack-${locale}@firefox.mozilla.org.xpi"
141 ln -sf "/app/share/runtime/langpack/${locale%%-*}/langpack-${locale}@firefox.mozilla.org.xpi" "${appdir}/lib/firefox/distribution/extensions/langpack-${locale}@firefox.mozilla.org.xpi"
143 install -D -m644 -t "${appdir}/lib/firefox/distribution" "$DISTRIBUTION_DIR/distribution.ini"
144 install -D -m755 launch-script.sh
"${appdir}/bin/firefox"
146 # We use features=devel to enable ptrace, which we need for the crash
147 # reporter. The application is still confined in a pid namespace, so
148 # that won't let us escape the flatpak sandbox. See bug 1653852.
150 flatpak build-finish build \
154 --socket=pulseaudio \
156 --socket=fallback-x11 \
159 --require-version=0.11.1 \
161 --env=DICPATH
=/usr
/share
/hunspell \
162 --filesystem=xdg-download
:rw \
163 --filesystem=/run
/.heim_org.h5l.kcm-socket \
164 --filesystem=xdg-run
/speech-dispatcher
:ro \
166 --talk-name=org.freedesktop.FileManager1 \
167 --system-talk-name=org.freedesktop.NetworkManager \
168 --talk-name=org.a11y.Bus \
169 --talk-name="org.gtk.vfs.*" \
170 --own-name="org.mpris.MediaPlayer2.firefox.*" \
171 --own-name="org.mozilla.firefox.*" \
172 --own-name="org.mozilla.firefox_beta.*" \
175 flatpak build-export
--disable-sandbox --no-update-summary --exclude='/share/runtime/langpack/*/*' repo build
"$FLATPAK_BRANCH"
176 flatpak build-export
--disable-sandbox --no-update-summary --metadata=metadata.locale
--files=files
/share
/runtime
/langpack repo build
"$FLATPAK_BRANCH"
177 ostree commit
--repo=repo
--canonical-permissions --branch=screenshots
/x86_64 build
/screenshots
178 flatpak build-update-repo
--generate-static-deltas repo
179 tar cvfJ flatpak.
tar.xz repo
181 mv -- flatpak.
tar.xz
"$TARGET_TAR_XZ_FULL_PATH"
183 # XXX: if we ever wanted to go back to building flatpak bundles, we can revert this command; useful for testing individual artifacts, not publishable
184 # flatpak build-bundle "$WORKSPACE"/repo org.mozilla.firefox.flatpak org.mozilla.firefox
185 # TARGET_FULL_PATH="$ARTIFACTS_DIR/target.flatpak"
186 # mv -- *.flatpak "$TARGET_FULL_PATH"