From fab5b0df2eead06cffad041cc6ac2c17a540b916 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sun, 18 Dec 2022 20:40:41 +0000 Subject: [PATCH] Remove arch-travis and directly use docker --- .travis.yml | 36 ++---------------------------------- ci/build_image.sh | 15 +++++++++++++++ lib/checks/check.sh | 21 ++------------------- lib/core/build.sh | 16 ++-------------- lib/core/common.sh | 24 ++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 67 deletions(-) create mode 100755 ci/build_image.sh diff --git a/.travis.yml b/.travis.yml index e024bbd..153b779 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,39 +9,6 @@ cache: services: - docker -archlinux: - mount: - - ~/.ccache:~/.ccache - - ~/.pkg-cache:/var/cache/pacman/pkg - packages: - # Pacman packages - - ccache - - git - - haveged - - before_install: - # 1.Override `package-cleanup.hook` to preserve cache for travis. - # 2.Enable ccache - # 3.Multithreaded build and compress - # 4.Suppress all gcc warnings - - | - sudo mkdir /etc/pacman.d/hooks/ - sudo ln -s /dev/null /etc/pacman.d/hooks/package-cleanup.hook - sudo sed -i '/^BUILDENV/s/\!ccache/ccache/' /etc/makepkg.conf - sudo sed -i '/#MAKEFLAGS=/c MAKEFLAGS="-j2"' /etc/makepkg.conf - sudo sed -i '/^COMPRESSXZ/s/\xz/xz -T 2/' /etc/makepkg.conf - sudo sed -i '$a CFLAGS="$CFLAGS -w"' /etc/makepkg.conf - sudo sed -i '$a CXXFLAGS="$CXXFLAGS -w"' /etc/makepkg.conf - sudo pacman -Syy --noconfirm --disable-download-timeout - sudo pacman-key --init - sudo pacman -S --noconfirm --disable-download-timeout archlinux-keyring - sudo pacman-key --populate archlinux - sudo pacman -Su --noconfirm --disable-download-timeout - script: - # Here do not make any validation (-n) because it will be done later on in the Ubuntu host directly - - ./bin/junest build -n - - env: matrix: - TRAVIS_BASH_VERSION="4.0" @@ -75,7 +42,8 @@ script: # Build and validation ####################### - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin - - "curl -s https://raw.githubusercontent.com/fsquillace/arch-travis/master/arch-travis.sh | bash" + - docker run --rm -v "$(pwd):/build" -v ~/.ccache:/home/travis/.ccache -v ~/.pkg-cache:/var/cache/pacman/pkg --privileged archlinux:latest bash /build/ci/build_image.sh + - "echo pacman pkg cache size: $(du -h ~/.pkg-cache|cut -f1) in $(ls ~/.pkg-cache|wc -l) files" - ls -l # Test the newly created JuNest image against Ubuntu host diff --git a/ci/build_image.sh b/ci/build_image.sh new file mode 100755 index 0000000..f9cda95 --- /dev/null +++ b/ci/build_image.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -ex + +pacman -Sy --noconfirm sudo + +# Create a travis user +echo "travis ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/travis +chmod 'u=r,g=r,o=' /etc/sudoers.d/travis +groupadd --gid "2000" "travis" +useradd --create-home --uid "2000" --gid "2000" --shell /usr/bin/false "travis" + +# Here do not make any validation (-n) because it will be done later on in the Ubuntu host directly +cd /build +runuser -u travis -- /build/bin/junest build -n diff --git a/lib/checks/check.sh b/lib/checks/check.sh index 720e9e0..e811f8a 100755 --- a/lib/checks/check.sh +++ b/lib/checks/check.sh @@ -47,26 +47,9 @@ info "Initial JuNest setup..." # otherwise it is not possible to exit from the session trap "[[ -e /etc/pacman.d/gnupg/S.gpg-agent ]] && gpg-connect-agent -S /etc/pacman.d/gnupg/S.gpg-agent killagent /bye" QUIT EXIT ABRT TERM INT +prepare_archlinux "$SUDO" + PACMAN_OPTIONS="--noconfirm --disable-download-timeout" - -# shellcheck disable=SC2086 -$SUDO pacman $PACMAN_OPTIONS -Syy - -$SUDO pacman-key --init - -if [[ $(uname -m) == *"arm"* ]] -then - # shellcheck disable=SC2086 - $SUDO pacman $PACMAN_OPTIONS -S archlinuxarm-keyring - $SUDO pacman-key --populate archlinuxarm -else - # shellcheck disable=SC2086 - $SUDO pacman $PACMAN_OPTIONS -S archlinux-keyring - $SUDO pacman-key --populate archlinux -fi - -# shellcheck disable=SC2086 -$SUDO pacman $PACMAN_OPTIONS -Su # shellcheck disable=SC2086 $SUDO pacman $PACMAN_OPTIONS -S grep coreutils # shellcheck disable=SC2086 diff --git a/lib/core/build.sh b/lib/core/build.sh index 45f3631..09939d1 100644 --- a/lib/core/build.sh +++ b/lib/core/build.sh @@ -24,20 +24,8 @@ function _install_pkg(){ function _prepare() { # ArchLinux System initialization - sudo pacman --noconfirm -Syy - sudo pacman-key --init - if [[ $(uname -m) == *"arm"* ]] - then - sudo pacman -S --noconfirm archlinuxarm-keyring - sudo pacman-key --populate archlinuxarm - else - sudo pacman -S --noconfirm archlinux-keyring - sudo pacman-key --populate archlinux - fi - - sudo pacman --noconfirm -Su - sudo pacman -S --noconfirm base-devel - sudo pacman -S --noconfirm git arch-install-scripts + prepare_archlinux + sudo pacman -S --noconfirm git arch-install-scripts haveged } function build_image_env(){ diff --git a/lib/core/common.sh b/lib/core/common.sh index 7062ecd..d44303f 100644 --- a/lib/core/common.sh +++ b/lib/core/common.sh @@ -308,3 +308,27 @@ function copy_common_files() { copy_file /etc/resolv.conf return 0 } + +function prepare_archlinux() { + local sudo=${1:-sudo} + local pacman_options="--noconfirm --disable-download-timeout" + + # shellcheck disable=SC2086 + $sudo pacman $pacman_options -Syy + + $sudo pacman-key --init + + if [[ $(uname -m) == *"arm"* ]] + then + # shellcheck disable=SC2086 + $sudo pacman $pacman_options -S archlinuxarm-keyring + $sudo pacman-key --populate archlinuxarm + else + # shellcheck disable=SC2086 + $sudo pacman $pacman_options -S archlinux-keyring + $sudo pacman-key --populate archlinux + fi + + # shellcheck disable=SC2086 + $sudo pacman $pacman_options -Su +}