0
Fork 0
mirror of https://codeberg.org/librewolf/source.git synced 2024-12-22 13:43:04 -05:00
This commit is contained in:
Bert van der Weerd 2021-11-19 19:07:31 +01:00
parent 8b17505c05
commit 3ea59bb933
No known key found for this signature in database
GPG key ID: 4CFABB96ADE0F5B1
8 changed files with 9 additions and 411 deletions

142
Makefile
View file

@ -1,4 +1,4 @@
.PHONY : all help clean veryclean check source buildenv build artifacts pub purge init
.PHONY : all help clean veryclean check init
version_file=./version
version:=$(shell cat $(version_file))
@ -6,106 +6,30 @@ version:=$(shell cat $(version_file))
include assets/Makefile.includes
help :
@echo "use: make [all] [clean] [veryclean] [check]"
@echo " [source] [pub] [buildenv] [no-cache] [upload]"
@echo " [purge] [prune] [init]"
@echo "use: make [all] [clean] [veryclean] [check] [source] [init]"
@echo ""
@echo " all - do: make source [build-all] artifacts pub"
@echo " clean - clean the biggest folders and intermediate results."
@echo " veryclean - clean everything, including sources and artifacts."
@echo " all - make librewolf tarball ${version} in source/ folder."
@echo " check - check if there is a new version of Firefox."
@echo ""
@echo " source - create the source tarball."
@echo " clean - clean everything except the upstream firefox tarball."
@echo " veryclean - clean everything and the firefox tarball."
@echo ""
@echo " debian10 - build the browser for debian10."
@echo " debian11 - build the browser for debian11."
@echo " mint20 - build the browser for mint20."
@echo " ubuntu20 - build the browser for mint20."
@echo ""
@echo " pub - copy the final artifact to the pub/librewolf tree."
@echo ""
@echo " buildenv - 'docker build' the images needed for building."
@echo " no-cache - 'docker build --no-cache' the images."
@echo " upload - upload the images to docker hub."
@echo ""
@echo " purge/prune - remove all docker resources not currently in use."
@echo " init - run bootstrap.py locally."
@echo " init - set up local build environment, takes a long time."
clean :
make -C source clean
make -C build/debian10 clean
make -C artifacts/debian10 clean
make -C build/debian11 clean
make -C artifacts/debian11 clean
make -C build/mint20 clean
make -C artifacts/mint20 clean
make -C build/ubuntu20 clean
make -C artifacts/ubuntu20 clean
veryclean : # deliberately not depending on 'clean' in this case.
make -C source veryclean
make -C buildenv/debian10 veryclean
make -C build/debian10 veryclean
make -C artifacts/debian10 veryclean
make -C buildenv/debian11 veryclean
make -C build/debian11 veryclean
make -C artifacts/debian11 veryclean
make -C buildenv/mint20 veryclean
make -C build/mint20 veryclean
make -C artifacts/mint20 veryclean
make -C buildenv/ubuntu20 veryclean
make -C build/ubuntu20 veryclean
make -C artifacts/ubuntu20 veryclean
#
# The 'all' target builds everything while trying to minimize
# disk space.
#
all : source
make -C source pub
make debian10
make -C artifacts/debian10 pub
make -C build/debian10 veryclean # reclaim disk space
make debian11
make -C artifacts/debian11 pub
make -C build/debian11 veryclean # reclaim disk space
make mint20
make -C artifacts/mint20 pub
make -C build/mint20 veryclean # reclaim disk space
make ubuntu20
make -C artifacts/ubuntu20 pub
make -C build/ubuntu20 veryclean # reclaim disk space
debian10 :
make -C build/debian10 all # perform ./mach build && ./mach package
make -C artifacts/debian10 all # make final artifacts
debian11 :
make -C build/debian11 all # perform ./mach build && ./mach package
make -C artifacts/debian11 all # make final artifacts
mint20 :
make -C build/mint20 all # perform ./mach build && ./mach package
make -C artifacts/mint20 all # make final artifacts
ubuntu20 :
make -C build/ubuntu20 all # perform ./mach build && ./mach package
make -C artifacts/ubuntu20 all # make final artifacts
all :
make -C source all
#
# Keeping ./version up to date.
@ -115,56 +39,6 @@ check :
@python3 assets/update-version.py
#
# Making the source tarball
#
source :
make -C source all
#
# buildenv: Creating build environment and performing the build
#
buildenv :
make -C buildenv/debian10 build
make -C buildenv/debian11 build
make -C buildenv/mint20 build
make -C buildenv/ubuntu20 build
no-cache :
make -C buildenv/debian10 no-cache
make -C buildenv/debian11 no-cache
make -C buildenv/ubuntu20 no-cache
upload :
make -C buildenv/debian10 upload
make -C buildenv/debian11 upload
make -C buildenv/ubuntu20 upload
#
# pub
#
pub :
make -C source pub
make -C artifacts/debian10 pub
make -C artifacts/debian11 pub
make -C artifacts/mint20 pub
make -C artifacts/ubuntu20 pub
#
# zapping all docker state..
#
purge : prune
prune :
$(docker) system prune --all --force
#
# init: run bootstrap on local machine
#

View file

@ -1,40 +0,0 @@
.PHONY : all clean veryclean pub shell
version_file=../../version
version:=$(shell cat $(version_file))
tag=librewolf/bs4-buildenv-$(distro)
build-artifact=librewolf-$(version).en-US.linux-x86_64.tar.bz2
output=librewolf-$(version).en-US.$(distro).x86_64.deb
all : $(output)
clean :
$(rm) -rf work
veryclean : clean
rm -f $(build-artifact) $(output)
# pub
pub : $(output)
-mkdir -p ../../pub/librewolf/librewolf-$(version)
cp -v $(output) ../../pub/librewolf/librewolf-$(version)
$(output) : work
$(docker) run --rm --privileged -v $(shell pwd)/work:/work:rw $(tag) bash build-deb.sh $(version)
cp -v work/librewolf.deb $(output)
work : $(build-artifact)
$(rm) -rf work
mkdir work
(cd work && tar xf ../$(build-artifact))
cp -v ../../assets/build-deb.sh work
$(build-artifact) :
@(echo "Error: Please use 'make $(distro)' at top-level to build first." && false)
shell : work
$(docker) pull $(tag)
$(docker) run -it --rm --privileged -v $(shell pwd)/work:/work:rw $(tag) bash

View file

@ -1,28 +0,0 @@
.PHONY : all clean veryclean build shell
version_file=../../version
version:=$(shell cat $(version_file))
tag=librewolf/bs4-buildenv-$(distro)
all : build
clean :
$(rm) -rf work
veryclean : clean
-$(docker) rmi $(tag)
work : ../../source/librewolf-$(version).source.tar.gz
$(rm) -rf work
$(mkdir) work
(cd work && $(tar) xf ../$< && cd ..)
$(chown) -R root:root work
build : work
$(docker) pull $(tag)
$(docker) run --rm --privileged -v $(shell pwd)/work:/work:rw $(tag) python3 /work/librewolf-$(version)/build-librewolf.py $(version)
cp -v work/librewolf-$(version)/librewolf-$(version).en-US.linux-x86_64.tar.bz2 ../../artifacts/$(distro)
shell : work
$(docker) pull $(tag)
$(docker) run -it --rm --privileged -v $(shell pwd)/work:/work:rw $(tag) bash

View file

@ -1,21 +0,0 @@
.PHONY : all clean veryclean build no-cache upload push
tag=librewolf/bs4-buildenv-$(distro)
all : build
clean :
veryclean : clean
-$(docker) rmi $(tag)
build :
$(docker) build -t $(tag) .
no-cache :
$(docker) build --no-cache -t $(tag) .
upload : push
push : build
$(docker) push $(tag)

View file

@ -1,6 +0,0 @@
docker=sudo docker
rm=sudo rm
mkdir=sudo mkdir
tar=sudo tar
cp=sudo cp -v
chown=sudo chown

View file

@ -1,38 +0,0 @@
mv -v librewolf lwdist
mkdir -p librewolf/DEBIAN
cd librewolf/DEBIAN
cat <<EOF > control
Architecture: all
Build-Depends: inkscape, librsvg2-bin
Depends: libc6, libgcc1, libstdc++6, wget
Description: The Librewolf Browser
Download-Size: 56.0 MB
Essential: no
Installed-Size: 204 MB
Maintainer: Bert van der Weerd <bert@stanzabird.nl>
Package: librewolf
Priority: optional
Provides: gnome-www-browser, www-browser, x-www-browser
Section: web
EOF
echo "Version: $1" >> control
cd ..
mkdir -p usr/share/librewolf
mv -v ../lwdist/* usr/share/librewolf
rmdir ../lwdist
mkdir -p usr/bin
cd usr/bin
ln -vs ../share/librewolf/librewolf
cd ../..
cd ..
dpkg-deb --build librewolf
echo ""
ls -lh librewolf.deb
exit 0

View file

@ -1,138 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import optparse
import time
import glob
start_time = time.time()
parser = optparse.OptionParser()
parser.add_option('-n', '--no-execute', dest='no_execute', default=False, action="store_true")
options, args = parser.parse_args()
#
# general functions
#
def script_exit(statuscode):
if (time.time() - start_time) > 60:
# print elapsed time
elapsed = time.strftime("%H:%M:%S", time.gmtime(time.time() - start_time))
print(f"\n\aElapsed time: {elapsed}")
sys.exit(statuscode)
def exec(cmd, exit_on_fail = True, do_print = True):
if cmd != '':
if do_print:
print(cmd)
if not options.no_execute:
retval = os.system(cmd)
if retval != 0 and exit_on_fail:
print("fatal error: command '{}' failed".format(cmd))
script_exit(1)
return retval
return None
def patch(patchfile):
cmd = "patch -p1 -i {}".format(patchfile)
print("\n*** -> {}".format(cmd))
if not options.no_execute:
retval = os.system(cmd)
if retval != 0:
print("fatal error: patch '{}' failed".format(patchfile))
script_exit(1)
def enter_srcdir(_dir = None):
if _dir == None:
dir = "librewolf-{}".format(version)
else:
dir = _dir
print("cd {}".format(dir))
if not options.no_execute:
try:
os.chdir(dir)
except:
print("fatal error: can't change to '{}' folder.".format(dir))
script_exit(1)
def leave_srcdir():
print("cd ..")
if not options.no_execute:
os.chdir("..")
#
# The actual script
#
#
# post_build stage:
#
def get_objdir():
pattern = "obj-*"
retval = glob.glob(pattern)
if options.no_execute:
return "obj-XXX"
if len(retval) != 1:
print("fatal error: in execute_lw_post_build(): cannot glob build output folder '{}'".format(pattern))
script_exit(1)
return retval[0]
_dirname = ""
def post_build(is_macos=False):
print('--- post_build stage [init] ---------------------------------------')
dirname = get_objdir()
_dirname = dirname
distfolder = "dist/bin"
if is_macos:
distfolder = 'dist/LibreWolf.app/Contents/Resources'
if not options.no_execute:
os.makedirs("{}/{}/defaults/pref".format(dirname,distfolder), exist_ok=True)
os.makedirs("{}/{}/distribution".format(dirname,distfolder), exist_ok=True)
exec('git clone https://gitlab.com/librewolf-community/settings.git')
exec("cp -v settings/defaults/pref/local-settings.js {}/{}/defaults/pref/".format(dirname,distfolder))
exec("cp -v settings/distribution/policies.json {}/{}/distribution/".format(dirname,distfolder))
exec("cp -v settings/librewolf.cfg {}/{}/".format(dirname,distfolder))
exec('rm -rf settings')
# maybe a wget -q ?
if not os.path.exists('package-manifest.patch'):
exec('wget -q https://gitlab.com/librewolf-community/browser/windows/-/raw/master/patches/package-manifest.patch')
patch('package-manifest.patch')
print('--- post_build stage [done] ---------------------------------------')
# my build folder will be here:
enter_srcdir(os.path.dirname(os.path.realpath(__file__)))
# perform the build
exec('./mach build')
post_build()
exec('./mach package')
## copy the artifact from obj-* to a friendlier location... to: /work
version = sys.argv[1]
_dirname = get_objdir()
artifact = "{}/dist/librewolf-{}.en-US.linux-x86_64.tar.bz2".format(_dirname,version)
cmd = "cp -v {} .".format(artifact)
exec(cmd)

View file

@ -5,12 +5,11 @@ version:=$(shell cat $(version_file))
all : librewolf-$(version).source.tar.gz
help :
@echo "Use: make [all] [clean] [veryclean] [pub]"
@echo "Use: make [all] [clean] [veryclean]"
@echo ""
@echo " all - build librewolf-$(version).source.tar.gz"
@echo " clean - remove all source trees and other cruft"
@echo " veryclean - same as clean, but also remove source archives"
@echo " pub - copy Libewolf source to pub folder"
clean :
rm -rf *~ firefox-$(version) librewolf-$(version) librewolf-$(version).source.tar.gz work
@ -39,7 +38,3 @@ librewolf-$(version).source.tar.gz : firefox-$(version).source.tar.xz $(version_
rm -f librewolf-$(version).source.tar.gz
tar cfz librewolf-$(version).source.tar.gz librewolf-$(version)
rm -rf librewolf-$(version)
pub : librewolf-$(version).source.tar.gz
cp -v $< ../pub/librewolf/librewolf-$(version)