summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-04-29 11:22:27 -0400
committerB. Stack <bgstack15@gmail.com>2021-04-29 13:25:05 -0400
commitc2222923135ed252afa7bd7d93cdd4a25b84fb14 (patch)
tree209381ebe6874f9627504d1ae44fb8f111cccfa1
parentinitial commit (diff)
downloadlibrewolf-fedora-c2222923135ed252afa7bd7d93cdd4a25b84fb14.tar.gz
librewolf-fedora-c2222923135ed252afa7bd7d93cdd4a25b84fb14.tar.bz2
librewolf-fedora-c2222923135ed252afa7bd7d93cdd4a25b84fb14.zip
now builds src.rpm
-rw-r--r--.gitignore1
-rwxr-xr-xscripts/prep-librewolf-rpm.sh134
2 files changed, 116 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index 99d798f..e327738 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
git
[0-9]*/
.*.swp
+prepared/
diff --git a/scripts/prep-librewolf-rpm.sh b/scripts/prep-librewolf-rpm.sh
index 6708b1f..1d6ddb2 100755
--- a/scripts/prep-librewolf-rpm.sh
+++ b/scripts/prep-librewolf-rpm.sh
@@ -1,11 +1,24 @@
#!/bin/sh
# File: prep-librewolf-rpm.sh
-# Goal: modify the src.rpm git repo of firefox into src.rpm git repo for LibreWolf
+# Location: https://gitlab.com/bgstack15/librewolf-fedora
+# Latest supported version: librewolf-88.0-6.fc33
+# Author: bgstack15
+# SPDX-License-Identifier: CC-BY-SA-4.0
# Startdate: 2021-04-28
+# Title: Build Rpm for LibreWolf
+# Purpose: Prepare src.rpm for running "rpmbuild -ra librewolf.src.rpm" for LibreWolf by adapting distro Firefox assets
+# History:
+# Usage:
+# Can send the output to COPR
+# Reset the local build environment with:
+# rm -rf ../git ../prepared ../88.0
+# References:
+# https://gitlab.com/librewolf-community/browser/linux/-/tree/master/scripts
+# Improve:
# Dependencies:
-# req-fedora: rpmdevtools
+# req-fedora: rpmdevtools, dnf
-set -e;
+set -e # fail out on any errors
#####################################
# Load settings
@@ -45,16 +58,15 @@ if test -z "${SKIP_DOWNLOAD}" ; then
git checkout "${src_rpm_git_commit}"
}
# Download original firefox source
- spectool -g firefox.spec --source 0
else : ; fi
# Download git sources
if test -z "${SKIP_GIT}" ; then (
# yes, use sub-shell for cd. pushd is a bashism.
mkdir -p "${git_source_dir}" ; cd "${git_source_dir}"
- git clone "${librewolf_common_url}" ${git_source_dir}/common
- git clone "${librewolf_settings_url}" ${git_source_dir}/settings
- git clone "${librewolf_linux_url}" ${git_source_dir}/linux
+ git clone "${librewolf_common_url}" ${git_source_dir}/common || :
+ git clone "${librewolf_settings_url}" ${git_source_dir}/settings || :
+ git clone "${librewolf_linux_url}" ${git_source_dir}/linux || :
) ; else : ; fi
@@ -62,14 +74,12 @@ if test -z "${SKIP_GIT}" ; then (
# Script 1 tasks
# Modify dependencies, and also lw-ize firefox fedora sources
cd "${src_rpm_dir}"
-# FIXME: add -i, remove redirect
sed -r firefox.spec \
-e '/^%global mozapp/{s:\/firefox:librewolf:;}' \
-e '/^Name:/{s:firefox:librewolf:;}' \
-e '/^%package (x11|wayland)/,/^\s*$/{s/firefox/librewolf/g;s/Firefox/LibreWolf/g;}' \
-e '/^BuildRequires.*zip$/aBuildRequires: jack-audio-connection-kit-devel' \
> firefox.spec2
-# FIXME: probably need a lot more librewolf-ization, like disabling crashreporter, etc.
#####################################
# Script 2 tasks
@@ -85,21 +95,107 @@ cd "${git_source_dir}"/common/source_files/browser/branding ; tar -zcf "${src_rp
# add new source tarball for the common.git/source_files/browser/branding/librewolf,a nd other script3 tasks
# just change any logic for enable tests to disable them
cd "${src_rpm_dir}"
-# FIXME: final changes should happen to firefox.spec
+# MOZ_SMP_FLAGS is inside the %build and only appears once in the spec file, so should be a good place to add LW-specific settings.
sed -r firefox.spec2 \
- -e '/__rm.*\.mozconfig/iSOURCE100: librewolf-branding.tgz\' -e '( cd browser/branding ; tar -zxf ${SOURCE100} . )' \
+ -e '/^%description\s*$/iSource100: librewolf-branding.tgz' \
+ -e '/__rm.*\.mozconfig/i( cd browser/branding ; tar -zxf ${SOURCE100} . )' \
-e 's/--enable-tests\>/--disable-tests/g;' \
-e 's/--enable-debug\>/--disable-debug/g;' \
- -e '/^MOZ_SMP_FLAGS/iecho "ac_add_options --enable-hardening" >> .mozconfig\'
- -e 'echo "ac_add_options --enable-rust-simd" >> .mozconfig\'
- -e 'echo "ac_add_options --with-app-name=librewolf" >> .mozconfig\'
- -e 'echo "ac_add_options --with-app-basename=LibreWolf" >> .mozconfig\'
- -e 'echo "ac_add_options --with-branding=browser/branding/librewolf" >> .mozconfig\'
- -e 'echo "ac_add_options --with-branding=browser/branding/librewolf" >> .mozconfig\'
- -e 'echo "ac_add_options --with-distribution-id=io.gitlab.librewolf-community" >> .mozconfig\'
- -e 'echo "ac_add_options --with-unsigned-addon-scopes=app,system" >> .mozconfig\'
+ -e '/^Version/i%global enable_mozilla_crashreporter 0' \
+ -e '/^MOZ_SMP_FLAGS/iecho "ac_add_options --enable-hardening" >> .mozconfig\' \
+ -e 'echo "ac_add_options --enable-rust-simd" >> .mozconfig\' \
+ -e 'echo "ac_add_options --with-app-name=librewolf" >> .mozconfig\' \
+ -e 'echo "ac_add_options --with-app-basename=LibreWolf" >> .mozconfig\' \
+ -e 'echo "ac_add_options --with-branding=browser/branding/librewolf" >> .mozconfig\' \
+ -e 'echo "ac_add_options --with-branding=browser/branding/librewolf" >> .mozconfig\' \
+ -e 'echo "ac_add_options --with-distribution-id=io.gitlab.librewolf-community" >> .mozconfig\' \
+ -e 'echo "ac_add_options --with-unsigned-addon-scopes=app,system" >> .mozconfig\' \
+ -e 'echo "ac_add_options --enable-alsa" >> .mozconfig\' \
+ -e 'echo "ac_add_options --enable-jack" >> .mozconfig\' \
+ -e 'echo "export MOZ_REQUIRE_SIGNING=0" >> .mozconfig\' \
+ -e 'echo "ac_add_options --disable-updater" >> .mozconfig\' \
+ -e 'echo "export MOZ_CRASHREPORTER=0" >> .mozconfig\' \
+ -e 'echo "export MOZ_DATA_REPORTING=0" >> .mozconfig\' \
+ -e 'echo "export MOZ_SERVICES_HEALTHREPORT=0" >> .mozconfig\' \
+ -e 'echo "export MOZ_TELEMETRY_REPORTING=0" >> .mozconfig' \
> firefox.spec3
# script 3 notes: fedora firefox already includes some important options:
# enable-release
# allow-addon-sideload
+#
+# Unfortunately aarch64 is outside of my scope.
+
+# still in script 3, add the relevant patches to the spec
+cp -pf "${git_source_dir}"/linux/megabar.patch "${git_source_dir}"/linux/remove_addons.patch "${git_source_dir}"/linux/mozilla-vpn-ad.patch "${git_source_dir}"/linux/context-menu.patch "${git_source_dir}"/linux/deb_patches/*.patch "${src_rpm_dir}"
+# "cd browser/branding" was added in the previous sed command
+sed -r firefox.spec3 \
+ -e '/^%description\s*$/iPatch900: armhf-reduce-linker-memory-use.patch\' \
+ -e 'Patch901: fix-armhf-webrtc-build.patch\' \
+ -e 'Patch902: webrtc-fix-compiler-flags-for-armhf.patch\' \
+ -e 'Patch903: sandbox-update-arm-syscall-numbers.patch\' \
+ -e 'Patch904: remove_addons.patch\' \
+ -e 'Patch905: megabar.patch\' \
+ -e 'Patch906: reduce-rust-debuginfo.patch\' \
+ -e 'Patch907: mozilla-vpn-ad.patch\' \
+ -e 'Patch908: context-menu.patch' \
+ -e '/ cd browser\/branding/i%patch900 -p1\' \
+ -e '%patch901 -p1\' \
+ -e '%patch902 -p1\' \
+ -e '%patch903 -p1\' \
+ -e '%patch904 -p1\' \
+ -e '%patch905 -p1\' \
+ -e '%patch906 -p1\' \
+ -e '%patch907 -p1\' \
+ -e '%patch908 -p1\' \
+ -e 'sed -i "/\\"pocket\\"/d" browser/components/moz.build\' \
+ -e 'sed -i "/SaveToPocket\.init/d" browser/components/BrowserGlue.jsm\' \
+ -e "sed -i -r -e '/organizationalUnit.{0,5}=.{0,5}Mozilla/{N;N;N;d}' toolkit/mozapps/extensions/internal/XPIInstall.jsm\\" \
+ -e "sed -i -r -e '/enterprise_only/s#true#false#g;' browser/components/enterprisepolicies/schemas/policies-schema.json\\" \
+ -e "_settings_services_sed='s#firefox.settings.services.mozilla.com#f.s.s.m.c.qjz9zk#g'\\" \
+ -e 'sed -e "${_settings_services_sed}" -i browser/components/newtab/data/content/activity-stream.bundle.js\' \
+ -e 'sed -e "${_settings_services_sed}" -i modules/libpref/init/all.js\' \
+ -e 'sed -e "${_settings_services_sed}" -i services/settings/Utils.jsm\' \
+ -e 'sed -e "${_settings_services_sed}" -i toolkit/components/search/SearchUtils.jsm\' \
+ > firefox.spec4
+# unity-menubar is not a feature expected in Fedora at all, so ignore it.
+
+###################################
+# Script 4 tasks
+# "cd browser/branding" was added in the previous sed command
+sed firefox.spec4 \
+ -e '/ cd browser\/branding/iexport MOZ_NOSPAM=1' \
+ > firefox.spec5
+
+# but the build itself will happen of course in the build environment and not here.
+
+###################################
+# Additional steps for rpm implementation
+cd "${src_rpm_dir}"
+mv -f firefox.spec4 librewolf.spec
+sed -i -r librewolf.spec \
+ -e '/%changelog\s*$/a* '"$( date "+%a %b %d %Y" ) B. Stack <bgstack15@gmail.com> - ${firefox_version}-${distro_firefox_release}"'\' \
+ -e '- Fork to librewolf release.\' -e ''
+
+# upstream fedora firefox src.rpm lists some sources which are only used inside if-endif blocks
+# Also, fix %files list
+sed -i -r librewolf.spec \
+ -e '/^Source[0-9]+:.*mochitest-python\.tar/{i%if 0' -e 'a%endif' -e '}' \
+ -e '/^%files -f/,/^%change/{' -e '/_bindir|mozappdir|\/icons/{/browser/!{s/firefox/librewolf/g;}}}'
+
+if test -z "${SKIP_SRC_RPM}" ; then
+ if test -f "firefox-${firefox_version}.source.tar.xz" || test -z "${SKIP_SPECTOOL}" ; then
+ spectool -g librewolf.spec --source 0 # from rpmdevtools
+ fi
+ # Upstream fedora firefox does not include some tarballs for some weird reason, so let's pull them from Fedora src.rpm and rip them out
+ # Unfortunately the version available may not be identical to what is in src.fedoraproject.org
+ cd "${work_dir}" ; dnf download --source firefox
+ this_srcrpm="$( find . -iname 'firefox-*.src.rpm' -printf '%f\n' | sort | tail -n1 )"
+ # find the tarballs closest to these expressions: firefox-langpacks cbindgen-vendor
+ cd "${src_rpm_dir}" ; rpm2cpio "${work_dir}/${this_srcrpm}" | cpio -idm $( spectool -l --sources "${src_rpm_dir}/librewolf.spec" | awk '$NF ~/z$/ && $NF ~ /cbindgen|langpacks/{print $NF}' )
+ # I only know how to get rpmbuild to pull sources from ~/rpmbuild/SOURCES
+ mkdir -p ~/rpmbuild/SOURCES
+ cd "${src_rpm_dir}" ; cp -pf * ~/rpmbuild/SOURCES ;
+ rpmbuild -bs librewolf.spec # creates the librewolf src.rpm in ~/rpmbuild/SRPMS/
+ cp -p ~/rpmbuild/SRPMS/librewolf-${firefox_version}-${distro_firefox_version}*.src.rpm "${work_dir}"
+fi
bgstack15