From b409944faddbfa5dc4e318ef14942f7d9847397a Mon Sep 17 00:00:00 2001 From: ohfp <1813007-ohfp@users.noreply.gitlab.com> Date: Sat, 28 Mar 2020 23:15:41 +0100 Subject: de-Archify some aspects of builds and -scripts; allow to initiate separate steps manually; first attempt to build tarball on ubuntu 16.04 --- .gitlab-ci.yml | 99 +++++++++++++++------- PKGBUILD | 27 +++--- appimage/build_appimage.sh | 16 ++-- arch/01_build.sh | 13 +++ binary_tarball/scripts/1_Install_Dependencies.sh | 3 +- binary_tarball/scripts/2_Download_Source_Code.sh | 6 +- binary_tarball/scripts/3_Configure_Source_Code.sh | 90 +++++++++++++++++++- binary_tarball/scripts/4_Build_Binary_Tarball.sh | 80 +++++++++++++++++ .../scripts/5_Configure_Binary_Tarball.sh | 26 +++++- flatpak/build_flatpak.sh | 11 +++ scripts/01_arch_build.sh | 12 --- scripts/02_configure_tarball.sh | 42 --------- 12 files changed, 311 insertions(+), 114 deletions(-) create mode 100755 arch/01_build.sh delete mode 100755 scripts/01_arch_build.sh delete mode 100755 scripts/02_configure_tarball.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f22fd22..418b1ca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,20 @@ stages: - build - paks - # - deploy + +# variables: + # GENERIC: $GENERIC + # ARCH: $ARCH + # FLATPAK: $FLATPAK + # APPIMAGE: $FLATPAK + # pkgver: $PKGVER + # pkgrel: $PKGREL + # AARCH64: $AARCH64 + # X86_64: $X86_64 + # download tarball if none available as artifact, + # ie. not built in the same pipeline run + # TARBALL_URL: $TARBALL_URL + # $RELEASE, to trigger deploy, maybe? .carch_aarch64: &carch_aarch64 variables: @@ -11,18 +24,23 @@ stages: variables: CARCH: 'x86_64' -.main_build_config: &main_build_config +.tarball_build_config: &tarball_build_config stage: build script: - - ./scripts/01_arch_build.sh - - ./scripts/02_configure_tarball.sh + - ./binary_tarball/build_tarball.sh "${CI_PROJECT_DIR}/LibreWolf.${CARCH}.tar.bz2" artifacts: name: "Librewolf-${CI_COMMIT_TAG}-${CARCH}" paths: - - "librewolf*pkg.tar*" - "LibreWolf.${CARCH}.tar.bz2" - only: - - tags + +.arch_build_config: &arch_build_config + stage: build + script: + - ./arch/01_build.sh + artifacts: + name: "Librewolf-Arch-${CI_COMMIT_TAG}-${CARCH}" + paths: + - "librewolf*pkg.tar*" .flatpak_config: &flatpak_config stage: paks @@ -31,8 +49,6 @@ stages: paths: - "LibreWolf.${CARCH}.flatpak" - "${CI_PROJECT_DIR}/librewolf-${CARCH}-flatpak-repo" - only: - - tags script: - ./flatpak/build_flatpak.sh "${CI_PROJECT_DIR}/LibreWolf.${CARCH}.tar.bz2" "${CI_PROJECT_DIR}/librewolf-${CARCH}-flatpak-repo" "${CI_PROJECT_DIR}/LibreWolf.${CARCH}.flatpak" @@ -42,56 +58,79 @@ stages: name: "Librewolf-${CI_COMMIT_TAG}-AppImage-${CARCH}" paths: - "LibreWolf.${CARCH}.AppImage" - only: - - tags script: - ./appimage/build_appimage.sh "${CI_PROJECT_DIR}/LibreWolf.${CARCH}.tar.bz2" "${CI_PROJECT_DIR}/LibreWolf.${CARCH}.AppImage" -build_x86_64: +arch_x86_64: image: archlinux/base tags: [x86_64b] <<: *carch_x86_64 - <<: *main_build_config + <<: *arch_build_config + only: + variables: + - $ARCH && $X86_64 -build_aarch64: +arch_aarch64: image: registry.gitlab.com/ohfp/manjaro-arm-docker tags: [aarch64b] <<: *carch_aarch64 - <<: *main_build_config + <<: *arch_build_config + only: + variables: + - $ARCH && $AARCH64 + +tarball_x86_64: + image: ubuntu:16.04 + tags: [x86_64b] + <<: *carch_x86_64 + <<: *tarball_build_config + only: + variables: + - $TARBALL && $X86_64 + +tarball_aarch64: + image: arm64v8/ubuntu:16.04 + tags: [aarch64b] + <<: *carch_aarch64 + <<: *tarball_build_config + only: + variables: + - $TARBALL && AARCH64 flatpak_x86_64: - image: ubuntu:18.04 + image: ubuntu:16.04 tags: [flat_runner] <<: *carch_x86_64 <<: *flatpak_config + only: + variables: + - $FLATPAK && $X86_64 flatpak_aarch64: - image: arm64v8/ubuntu:18.04 + image: arm64v8/ubuntu:16.04 tags: [flat_runner_aarch64] <<: *carch_aarch64 <<: *flatpak_config + only: + variables: + - $FLATPAK && $AARCH64 appimage_x86_64: - image: ubuntu:18.04 + image: ubuntu:16.04 tags: [x86_64b] <<: *carch_x86_64 <<: *appimage_config + only: + variables: + - $APPIMAGE && $X86_64 appimage_aarch64: - image: arm64v8/ubuntu:18.04 + image: arm64v8/ubuntu:16.04 tags: - aarch64b - arm64 # can also be run on any other less powerful aarch64 runner <<: *carch_aarch64 <<: *appimage_config - -# Release to Gitlab: - # stage: deploy - # image: python:latest - # script: - # - pip3 install gitlab-release - # - tar czf librewolf-aarch64-flatpak-repo.tar.gz librewolf-aarch64-flatpak-repo - # - tar czf librewolf-x86_64-flatpak-repo.tar.gz librewolf-x86_64-flatpak-repo - # - "gitlab-release librewolf*.pkg.tar.* LibreWolf.*.AppImage librewolf-*-flatpak-repo.tar.gz LibreWolf.*.flatpak" - # only: - # - tags + only: + variables: + - $APPIMAGE && $AARCH64 diff --git a/PKGBUILD b/PKGBUILD index 52848d0..a5dfbf8 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -5,8 +5,11 @@ pkgname=librewolf _pkgname=LibreWolf -pkgver=74.0 -pkgrel=3 +# pkgver=74.0 +# pkgrel=3 +# now provided as ci variables +pkgver=$pkgver +pkgrel=$pkgrel pkgdesc="Community-maintained fork of Firefox, focused on privacy, security and freedom." arch=(x86_64 aarch64) license=(MPL GPL LGPL) @@ -94,7 +97,7 @@ mk_add_options MOZ_TELEMETRY_REPORTING=0 END if [[ $CARCH == 'aarch64' ]]; then -cat >>../mozconfig <>../mozconfig <> /etc/sudoers +mkdir -p /home/nobody && chown -R nobody /home/nobody +usermod -d /home/nobody nobody +# we need to un-expire the account, otherwise PAM will complain +usermod -e '' nobody +chown -R nobody . +# makepkg will not run as root +sudo -u nobody -E -H makepkg --noconfirm --nosign --syncdeps --cleanbuild diff --git a/binary_tarball/scripts/1_Install_Dependencies.sh b/binary_tarball/scripts/1_Install_Dependencies.sh index eb20de0..da2efb9 100755 --- a/binary_tarball/scripts/1_Install_Dependencies.sh +++ b/binary_tarball/scripts/1_Install_Dependencies.sh @@ -2,7 +2,8 @@ printf "\n\n-------------------------------------- DEPENDENCY INSTALLATION ---------------------------------------------\n"; # Setup Script Variables -_DEPENDENCIES="mercurial wget git flatpak flatpak-builder"; +# _DEPENDENCIES="mercurial wget git flatpak flatpak-builder"; +_DEPENDENCIES="wget git xvfb"; # Installs Dependencies printf "\nInstalling dependencies: $_DEPENDENCIES\n"; diff --git a/binary_tarball/scripts/2_Download_Source_Code.sh b/binary_tarball/scripts/2_Download_Source_Code.sh index 67e87d2..c50149d 100755 --- a/binary_tarball/scripts/2_Download_Source_Code.sh +++ b/binary_tarball/scripts/2_Download_Source_Code.sh @@ -1,10 +1,12 @@ #!/bin/bash printf "\n\n--------------------------------- SOURCE CODE DOWNLOAD --------------------------------------\n"; +if [[ -z ${pkgver} || -z ${pkgrel} ]]; then + echo '$pkgrel and/or $pkgver not provided' + exit 1 +fi # Setup Script Variables SOURCE_FOLDER=$1; -# hardcoded vor now, we'll parse the _pkgver later on, probably from tags -pkgver="73.0.1" _SOURCE_CODE_URL="https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz"; _SOURCE_TAR="firefox-${pkgver}.tar.xz" diff --git a/binary_tarball/scripts/3_Configure_Source_Code.sh b/binary_tarball/scripts/3_Configure_Source_Code.sh index 46b7e2c..4c26b5d 100755 --- a/binary_tarball/scripts/3_Configure_Source_Code.sh +++ b/binary_tarball/scripts/3_Configure_Source_Code.sh @@ -3,9 +3,11 @@ printf "\n\n------------------------------ FINAL PREBUILD CONFIGURATION -------- # Setup Script Variables SOURCE_CODE_FOLDER=$1; +CI_PROJECT_DIR=${CI_PROJECT_DIR:-$(realpath $(dirname $0)/../../)} _COMMON_REPO='https://gitlab.com/librewolf-community/browser/common.git'; -_POCKET_SED_STRING="s/'pocket'/#'pocket'/g"; -_POCKET_FILE=$SOURCE_CODE_FOLDER/browser/components/moz.build; +_MOZBUILD=$SOURCE_CODE_FOLDER/../mozbuild + +mkdir -p ${_MOZBUILD} # Copy Source Code Changes to Source Code printf "\nCopying branding and source code changes to firefox source code\n"; @@ -13,7 +15,87 @@ git clone $_COMMON_REPO common; cp -r common/source_files/* $SOURCE_CODE_FOLDER/; rm -rf common; -# Disables Pocket +cd $SOURCE_CODE_FOLDER + +cat >../mozconfig <>../mozconfig <.mozconfig ../mozconfig - <.mozconfig ../mozconfig - <.mozconfig ../mozconfig - <.mozconfig ../mozconfig - <> /etc/sudoers -mkdir -p /home/nobody && chown -R nobody /home/nobody -usermod -d /home/nobody nobody -# we need to un-expire the account, otherwise PAM will complain -usermod -e '' nobody -chown -R nobody . -# makepkg will not run as root -sudo -u nobody -E -H makepkg --noconfirm --nosign --syncdeps --cleanbuild --skippgpcheck diff --git a/scripts/02_configure_tarball.sh b/scripts/02_configure_tarball.sh deleted file mode 100755 index 2b4d959..0000000 --- a/scripts/02_configure_tarball.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -e - -printf "\n\n---------------- prepare package for other distros ----------------\n" - -# Setup Script Variables - -# use $CI_PROJECT_DIR unless not in CI, then assign script path -CI_PROJECT_DIR=${CI_PROJECT_DIR:-$(realpath $(dirname $0)/../)} -OUTPUT_TARBALL=$CI_PROJECT_DIR/LibreWolf.${CARCH}.tar.bz2 -SOURCE_CODE_BINARY_TARBALL_LOCATION="$CI_PROJECT_DIR/src/firefox-*/obj*/dist/librewolf*.tar.bz2" -EXTRACTED_TARBALL_FOLDER=$CI_PROJECT_DIR/librewolf_unpacked/librewolf - -# Prevents build from breaking in CI/CD environments -export SHELL=/bin/bash - -# Moves the packaged tarball to the specified location -printf "\nMoving Binary Tarball to output location\n" -mv $SOURCE_CODE_BINARY_TARBALL_LOCATION $OUTPUT_TARBALL - -# Extracts the binary tarball -printf "\nExtracting librewolf binary tarball\n" -mkdir librewolf_unpacked -tar -xf $OUTPUT_TARBALL -C librewolf_unpacked - -# Adds the librefox config files to the packaged tarball -printf "\nCopying librewolf settings to extracted binary tarball\n" -cp -r $CI_PROJECT_DIR/src/settings $EXTRACTED_TARBALL_FOLDER/settings -# no need to keep that in there -rm -rf "${EXTRACTED_TARBALL_FOLDER}/settings/.git"; -cp $CI_PROJECT_DIR/content/toggle-settings.sh $EXTRACTED_TARBALL_FOLDER/settings -cp $CI_PROJECT_DIR/content/launch_librewolf.sh $EXTRACTED_TARBALL_FOLDER/launch_librewolf.sh - -# Somewhat crude workaround to use settings per default -# until we've worked out how to use `--install-settings` with links -# in all major packages instead -printf "\nWorkaround: auto-enable Settings\n" -cp -r $EXTRACTED_TARBALL_FOLDER/settings/* $EXTRACTED_TARBALL_FOLDER; - -# Repacks the binary tarball -printf "\nRecompressing binary tarball\n" -tar -jvcf $OUTPUT_TARBALL -C $EXTRACTED_TARBALL_FOLDER . -- cgit