summaryrefslogtreecommitdiff
path: root/scripts/prep-librewolf-rpm.sh
blob: 6708b1f22443bd70b7f9b5fb97d26443b996a62e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
# File: prep-librewolf-rpm.sh
# Goal: modify the src.rpm git repo of firefox into src.rpm git repo for LibreWolf
# Startdate: 2021-04-28
# Dependencies:
#    req-fedora: rpmdevtools

set -e;

#####################################
# Load settings
# basically, dot-source the conf file.
test -z "${librewolf_rpm_conf}" && export librewolf_rpm_conf="$( find "$( dirname "${0}" )" -maxdepth 2 -name "$( basename "${0%%.sh}.conf" )" -print 2>/dev/null | head -n1 )"
test ! -r "${librewolf_rpm_conf}" && { echo "Unable to load config file, which should be named the same as this script but with a .conf ending. Aborted." 1>&2 ; exit 1 ; }
. "${librewolf_rpm_conf}"

librewolf_common_url=https://gitlab.com/librewolf-community/browser/common.git
librewolf_settings_url=https://gitlab.com/librewolf-community/settings.git
librewolf_linux_url=https://gitlab.com/librewolf-community/browser/linux.git

case "${DISTRO}" in
   fedora)
      _mozconfig='firefox-mozconfig'
      src_rpm_git_url="https://src.fedoraproject.org/rpms/firefox/"
      src_rpm_git_commit="main"
      ;;
   *)
      echo "Unconfigured DISTRO ${DISTRO}. Where in repo is mozconfig, and what is git url?" 1>&2
      exit 1
   ;;
esac

# user configurable
git_source_dir=${CI_PROJECT_DIR}/git  # where LibreWolf git contents are cached
src_rpm_dir=${CI_PROJECT_DIR}/${firefox_version}/git # where the src git repo is downloaded
work_dir=${CI_PROJECT_DIR}/prepared/

#############################3
# Download initial components
mkdir -p "${work_dir}" ; cd "${work_dir}"
if test -z "${SKIP_DOWNLOAD}" ; then
   mkdir -p "${src_rpm_dir}" ; cd "${src_rpm_dir}"
   git clone "${src_rpm_git_url}" . || :
   test -n "${src_rpm_git_commit}" && {
      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
) ; else : ; fi


#############################3
# 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

# none. Download happened earlier

#####################################
# Script 3 tasks

# Make new source tarball of branding elements
cd "${git_source_dir}"/common/source_files/browser/branding ; tar -zcf "${src_rpm_dir}"/librewolf-branding.tgz librewolf 

# 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
sed -r firefox.spec2 \
   -e '/__rm.*\.mozconfig/iSOURCE100: librewolf-branding.tgz\' -e '( 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\'
   > firefox.spec3

# script 3 notes: fedora firefox already includes some important options:
#    enable-release
#    allow-addon-sideload
bgstack15