-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-firefox.sh
More file actions
executable file
·109 lines (94 loc) · 4.16 KB
/
build-firefox.sh
File metadata and controls
executable file
·109 lines (94 loc) · 4.16 KB
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
106
107
108
109
#!/bin/bash
# ozgurun degisikligi budur
# Prompt for architecture and release channel
clear
echo "Mozilla Firefox packager for Debian-based Linux distributions"
echo ""
echo "Which architecture would you like to target?"
echo ""
echo "[1] i386 (32-bit)"
echo "[2] amd64 (64-bit)"
echo ""
echo "Please enter a number below:"
echo ""
read PKGARCH
echo ""
echo "Which release channel would you like to download?"
echo ""
echo "[1] Firefox Quantum Stable channel release"
echo "[2] Firefox Quantum Beta channel release"
echo "[3] Firefox Developer Edition"
echo ""
echo "Please enter a number below:"
read FXREL
# Set variables for user options
# Architecture
if [ $PKGARCH = 1 ]; then
FXOS=linux
FXARCH=i686
DEBARCH=i386
elif [ $PKGARCH = 2 ]; then
FXOS=linux64
FXARCH=x86_64
DEBARCH=amd64
fi
# Release channel
if [ $FXREL = 1 ]; then
FXCHANNEL=firefox-latest-ssl
FXDIR=firefox
elif [ $FXREL = 2 ]; then
FXCHANNEL=firefox-beta-latest-ssl
FXDIR=firefox
elif [ $FXREL = 3 ]; then
FXCHANNEL=firefox-devedition-latest-ssl
FXDIR=devedition
fi
# Check for the latest version of Firefox
VERSION=${VERSION:-$(wget --spider -S --max-redirect 0 "https://download.mozilla.org/?product=${FXCHANNEL}&os=${FXOS}&lang=en-US" 2>&1 | sed -n '/Location: /{s|.*/firefox-\(.*\)\.tar.*|\1|p;q;}')}
# Set download URL
FIREFOXPKG="https://download-installer.cdn.mozilla.net/pub/${FXDIR}/releases/${VERSION}/linux-${FXARCH}/en-US/firefox-${VERSION}.tar.bz2"
# Download and extract the latest Firefox release package
clear
echo "Downloading Firefox $VERSION ..."
wget --quiet --show-progress -O "firefox-$VERSION.tar.bz2" $FIREFOXPKG
clear
echo "Extracting files..."
tar xvf firefox-$VERSION.tar.bz2
rm firefox-$VERSION.tar.bz2
# Move files to Debian package build directory
mkdir firefox-${VERSION}_${DEBARCH}
mkdir -p firefox-${VERSION}_${DEBARCH}/usr/share/applications
mkdir -p firefox-${VERSION}_${DEBARCH}/opt
mv firefox firefox-${VERSION}_${DEBARCH}/opt/firefox
# Create .deb package of Firefox
clear
echo "Preparing to build Firefox installation package ..."
mkdir firefox-${VERSION}_${DEBARCH}/DEBIAN
cp ./src/DEBIAN/* firefox-${VERSION}_${DEBARCH}/DEBIAN/
chmod +x firefox-${VERSION}_${DEBARCH}/DEBIAN/postinst
chmod +x firefox-${VERSION}_${DEBARCH}/DEBIAN/postrm
chmod 775 firefox-${VERSION}_${DEBARCH}/DEBIAN/*
printf "Architecture: $DEBARCH\n" | tee -a firefox-${VERSION}_${DEBARCH}/DEBIAN/control
printf "Version: 1:$VERSION+b0~mozilla\n" | tee -a firefox-${VERSION}_${DEBARCH}/DEBIAN/control
printf "Installed-Size: " >> firefox-${VERSION}_${DEBARCH}/DEBIAN/control | du -sx --exclude DEBIAN firefox-${VERSION}_${DEBARCH} | tee -a firefox-${VERSION}_${DEBARCH}/DEBIAN/control
sed -i 's/firefox-'$VERSION'_'$DEBARCH'//g' firefox-${VERSION}_${DEBARCH}/DEBIAN/control
cp ./src/launcher/firefox.desktop firefox-${VERSION}_${DEBARCH}/usr/share/applications/firefox.desktop
cd firefox-${VERSION}_${DEBARCH}
find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums
cd ..
dpkg-deb --build firefox-${VERSION}_${DEBARCH}
rm -rf firefox-${VERSION}_${DEBARCH}
# If --install argument was passed, install the built .deb package
while test $# -gt 0
do
case "$1" in
--install)
clear
echo "Installing Firefox $VERSION ..."
sudo dpkg -i firefox-${VERSION}_${DEBARCH}.deb
echo ""
;;
esac
shift
done
exit 0