Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the CI script used to test changes in the overlay #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
image: docker:latest
services:
- docker:dind
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- /usr/portage
- /var/portage
- /var/lib/docker

build-ebuilds:
script:
- ./.tools/bin/ci-run-mr
23 changes: 23 additions & 0 deletions .tools/bin/ci-mkdockercmds
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /usr/bin/env sh

set -e

export PATH=$PATH:$(pwd)/.tools/bin
export DEBIAN_FRONTEND=noninteractive

hash -r

{
# We need git for consecutive commands
apt update -qq
apt install -qqy git

# Make sure the latest `master` is also available to diff against
git fetch -a origin
git checkout master
git pull origin master
git checkout -
} > /dev/null

# Generate the testing commands
updated-ebuilds | ebuild2atom | make-docker-commands --root="$1"
31 changes: 31 additions & 0 deletions .tools/bin/ci-run-mr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /usr/bin/env sh

set -e

main()
{
cmds=$(mktemp)

mkdir -p /usr/portage
mkdir -p /var/portage

# Sync latest portage tree
do_cmd docker run -v /usr/portage:/usr/portage gentoo/stage3-amd64 emerge -q --sync

# Run the script to generate the testing commands
do_cmd docker run -w /app -v "$(pwd):/app" rakudo-star sh .tools/bin/ci-mkdockercmds "$(pwd)" > "$cmds"

# Run the testing commands
while read -r cmd
do
do_cmd $cmd
done < "$cmds"
}

do_cmd()
{
printf "> %s\n" "$*" >&2
$@
}

main "$@"
14 changes: 14 additions & 0 deletions .tools/bin/ebuild2atom
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/env perl6

#| Convert a path to an ebuild into an atom that can be passed to emerge.
sub MAIN (*@ebuilds)
{
@ebuilds = $*IN.lines unless @ebuilds;

for @ebuilds {
my $category = $_.split("/").head;
my $package = $_.split("/").tail.IO.extension("").Str;

say "=$category/$package"
}
}
58 changes: 58 additions & 0 deletions .tools/bin/make-docker-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#! /usr/bin/env perl6

#| Build packages
sub MAIN (
#| Host's path to the Portage tree.
Str:D :$tree = "/usr/portage",

#| Host's path to Portage's var dir. This holds binpkgs and distfiles.
Str:D :$var = "/var/portage",

#| Host's path to the root of the overlay.
Str:D :$root is copy = "",

#| A list of packages to build
*@packages,
) {
@packages = $*IN.lines unless @packages;
$root = shell("git rev-parse --show-toplevel", :out).out.slurp.trim unless $root;

build-pkg($_, :$tree, :$var, root => $root.IO) for @packages;
}

#| Build a given package in a clean Docker container
sub build-pkg (
#| The name of the package to build
Str:D $package,

#| Host's path to the Portage tree.
Str:D :$tree = "/usr/portage",

#| Host's path to Portage's var dir. This holds binpkgs and distfiles.
Str:D :$var = "/var/portage",

#| Path to overlay's root
IO::Path:D :$root,
) {
my Pair @volumes = (
$tree => "/usr/portage",
$var => "/var/portage",
$root.add(".tools").add("etc").absolute => "/etc/portage",
$root.absolute => "/app",
);

my Str @cmd = <
docker
run
>;

for @volumes {
@cmd.push: "-v $_.key():$_.value()";
}

@cmd.push: "gentoo/stage3-amd64";
@cmd.push: "emerge";
@cmd.push: $package;

@cmd.join(" ").say;
}
18 changes: 18 additions & 0 deletions .tools/bin/mkcommit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /usr/bin/env perl6

sub MAIN (
*@words,
) {
my @ebuilds = (run « git diff --name-status master », :out).out.lines.grep(*.ends-with(".ebuild"));

if (@ebuilds.elems != 1) {
exit note q:to/EOF/;
Committed ebuilds does not equal to 1. Each commit should only
contain a single ebuild update.
EOF
}

my $ebuild = @ebuilds.head.split("\t").tail.split("/").head(2).join("/");

run « git commit -S -m "$ebuild: @words.join(" ")" »;
}
11 changes: 11 additions & 0 deletions .tools/bin/updated-ebuilds
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env perl6

#| Get a list of all changed package atoms.
sub MAIN ()
{
(run « git diff --name-status master », :out).out.lines
.grep(*.ends-with(".ebuild"))
.map(*.split("\t").tail)
.map(*.say)
;
}
33 changes: 33 additions & 0 deletions .tools/etc/make.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
COMMON_FLAGS="-O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

FEATURES="
$FEATURES
buildpkg
network-sandbox
parallel-fetch
parallel-install
sandbox
userfetch
userpriv
usersandbox
usersync
"

EMERGE_DEFAULT_OPTS="
$EMERGE_DEFAULT_OPTS
--binpkg-respect-use=y
--binpkg-changed-deps=y
--tree
--usepkg
--verbose
"

PKGDIR=/var/portage/packages
DISTDIR=/var/portage/distfiles

LC_MESSAGES=C
L10N="en"
1 change: 1 addition & 0 deletions .tools/etc/make.profile
1 change: 1 addition & 0 deletions .tools/etc/package.accept_keywords
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/*::sk-overlay ~*
51 changes: 51 additions & 0 deletions .tools/etc/repo.postsync.d/example
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
# Example /etc/portage/repo.postsync.d script. Make it executable (chmod +x) for
# Portage to process it.
#
# With portage-2.2.16 and newer, all repo.postsync.d hooks will be called multiple
# times after syncing each repository.
#
# Older versions of Portage support syncing only one repository.
# In those versions, the postsync.d hooks will be called only once,
# and they will not be passed any parameters.

# On a repo.postsync.d hook call, positional parameters contain
# information about the just-synced repository.

# Your hook can control it's actions depending on any of the three
# parameters passed in to it.
#
# They are as follows:
#
# The repository name.
repository_name=${1}
# The URI to which the repository was synced.
sync_uri=${2}
# The path to the repository.
repository_path=${3}

# Portage assumes that a hook succeeded if it exits with 0 code. If no
# explicit exit is done, the exit code is the exit code of last spawned
# command. Since our script is a bit more complex, we want to control
# the exit code explicitly.
ret=0

if [ -n "${repository_name}" ]; then
# Repository name was provided, so we're in a post-repository hook.
echo "* In post-repository hook for ${repository_name}"
echo "** synced from remote repository ${sync_uri}"
echo "** synced into ${repository_path}"

# Gentoo comes with pregenerated cache but the other repositories
# usually don't. Generate them to improve performance.
if [ "${repository_name}" != "gentoo" ]; then
if ! egencache --update --repo="${repository_name}" --jobs=4
then
echo "!!! egencache failed!"
ret=1
fi
fi
fi

# Return explicit status.
exit "${ret}"
10 changes: 10 additions & 0 deletions .tools/etc/repo.postsync.d/q-reinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

repository_name=$1
repository_path=$3

if [ -n "${repository_name}" ]; then
q ${PORTAGE_QUIET:+-q} --reinitialize="${repository_path}"
fi

:
5 changes: 5 additions & 0 deletions .tools/etc/repos.conf/sk-overlay.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[sk-overlay]
priority = 50
location = /app
layman-type = git
auto-sync = No
38 changes: 6 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
#
# Run repoman via travis
# See https://github.com/mrueg/repoman-travis
#
language: python
python:
- pypy
env:
- PORTAGE_VER="2.3.51"
before_install:
- sudo apt-get -qq update
- pip install lxml pyyaml
before_script:
- sudo chmod a+rwX /etc/passwd /etc/group /etc /usr
- mkdir -p travis-overlay /etc/portage /usr/portage/distfiles
- mv !(travis-overlay) travis-overlay/
- mv .git travis-overlay/
- wget "https://raw.githubusercontent.com/mrueg/repoman-travis/master/.travis.yml" -O .travis.yml.upstream
- wget "https://raw.githubusercontent.com/mrueg/repoman-travis/master/spinner.sh"
- wget -qO - "https://github.com/gentoo/portage/archive/portage-${PORTAGE_VER}.tar.gz" | tar xz
- wget -qO - "https://github.com/gentoo-mirror/gentoo/archive/master.tar.gz" | tar xz -C /usr/portage --strip-components=1
- chmod a+rwx spinner.sh
- echo "portage:x:250:250:portage:/var/tmp/portage:/bin/false" >> /etc/passwd
- echo "portage::250:portage,travis" >> /etc/group
- wget "https://www.gentoo.org/dtd/metadata.dtd" -O /usr/portage/distfiles/metadata.dtd
- ln -s $TRAVIS_BUILD_DIR/portage-portage-${PORTAGE_VER}/cnf/repos.conf /etc/portage/repos.conf
- ln -s /usr/portage/profiles/default/linux/amd64/17.0 /etc/portage/make.profile
- SIZE=$(stat -c %s .travis.yml.upstream)
- if ! cmp -n $SIZE -s .travis.yml .travis.yml.upstream; then echo -e "\e[31m !!! .travis.yml outdated! Update available https://github.com/mrueg/repoman-travis \e[0m" > /tmp/update ; fi
- cd travis-overlay
sudo: required
language: generic
services:
- docker

script:
- ./../spinner.sh "python ../portage-portage-${PORTAGE_VER}/repoman/bin/repoman full -d"
# You can append own scripts after this line
- sudo ./.tools/bin/ci-run-mr
8 changes: 5 additions & 3 deletions dev-util/lonestar/Manifest
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
DIST lonestar-1.0.0.tar.gz 15685 SHA256 fa5ade0ced42f80b05e2e8c1e310eb836788638755e54461fe27b26b5a2f26bf SHA512 414c6dc92fd415994885779fc1b545fa15b681f8d201b0b042ed11d9a99f9953539d0f1301bb6ed54485d5eeecf8fcba8dbe4f94bf88876b574700f77f25e5cc WHIRLPOOL 938b135b1e55746b04d2def729f7962ad66a6b88bd754084b53bc78fefd31bf1c57170702069484b6ab477ee4ff65051aca92c8bc3dc4e2869b82db8989a88cd
EBUILD lonestar-1.0.0.ebuild 491 SHA256 085fb990c4c093b941d8e96878b194824be7eaf21d810c9b6e2ed48de02dfefd SHA512 945103a91a11a7d39223a1439170bb6b674feae9ab526fd9b1c7cd132c196c4b9c825c6fa5ba29b90fa76111cc310368b2eb44ceb2e0886a0b7dd8c3010730c9 WHIRLPOOL fa9f0418fd078363359ea7f1e2fa6e4a1e4a05a849f897a3bf4c51ab62a10820f1d705767969361a7c60202a57b040bd0ac1bdfb9ff5b281d6026164dc949165
MISC metadata.xml 371 SHA256 63414fe8a9f322a44a17dc74d28939d999a874380f7a3b2d3599672fdeec9c99 SHA512 73459c71f25d457b6221277dbca3a77124bf71a6d0824467145f19348bf7eedf5adc6bd1b511835c92d656e13e5dcc780e6375949e83122c1bf458186f4c439f WHIRLPOOL e903378a0d14016f68a61eda0c407e177deaa95b7ebb78bead74833d722c656da952c08b39a57cae81e7a8d08973c271c7e21861dbc4d81deda76865d42870a3
DIST lonestar-1.0.0.tar.gz 15685 BLAKE2B 053d77ad0d3c8699f7d9638d7c6b8c46fe8c17c0af8d18a727627a6042e55c494f0d565fbfb424f8e81daea83d3f51dca4cc58236cd5562ccbdbeeb999b3f8f6 SHA512 414c6dc92fd415994885779fc1b545fa15b681f8d201b0b042ed11d9a99f9953539d0f1301bb6ed54485d5eeecf8fcba8dbe4f94bf88876b574700f77f25e5cc
DIST lonestar-9999.tar.gz 16444 BLAKE2B d37c3094778612ea68bdadf15a2b8baf73af719214f17facb1e8dce11abcca708dfdbe3b58b46fe1bcbb5770180c98f45350775ad9de14b26f165c4d0d3deab2 SHA512 ef0099f04a4402d4eddad297543a1d8bb8d41492bf4bb67e9fdc358abd66e2b40f4abf87e7020511522b9f2bf4b67f7e463ed3ad3c915030ed37281436b6c956
EBUILD lonestar-1.0.0.ebuild 525 BLAKE2B cd119a264bc5779d41487f32dabfa97c7bb082b5607bca9fced715d89150e67d71c956885a7873108465eda21be4d346b57aef00db16677d7f5d30f0a953289c SHA512 adc2ceb00b32d8d3f67df5f8bbec99ff12d39b99b72015a4f914695fe3b19d2f200a547f3762dcc68e144b5fc2a8d3dbc3bb4085f3ab2b88f6e9e8903b617791
EBUILD lonestar-9999.ebuild 525 BLAKE2B ccfb2a0a3c2e3f838c1033994626d4a41725bfdebcfa411299827a6939c22cba878ca9c218e816accfc06e67b1055ecf874eb6ff35f7c7ace03bd5c818372fb5 SHA512 0964393c131cf572736886bc94d1de6586587b04cce69c6184d093a0982d25daac39408c86e0986e29b17c93bc2ce840e7e0d3ee3c92ae94ace201aaaa44c2f5
MISC metadata.xml 371 BLAKE2B 88df600b88babd11eecc31e80533807973d1c25aa4d9678cf7edb5dfc2486b36620b113a4703c7eb2d48083fbcba20459c15fde87dfbdc4415fce72345ca9e3e SHA512 73459c71f25d457b6221277dbca3a77124bf71a6d0824467145f19348bf7eedf5adc6bd1b511835c92d656e13e5dcc780e6375949e83122c1bf458186f4c439f
9 changes: 5 additions & 4 deletions dev-util/lonestar/lonestar-1.0.0.ebuild
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Copyright 2018 Patrick Spek <[email protected]>
#
# Distributed under the terms of the GNU Affero General Public License v3

EAPI=6

DESCRIPTION="A small Bash application to install the Rakudo Star Perl 6 distribution"
HOMEPAGE="https://github.com/tyil/lonestar"
SRC_URI="https://github.com/tyil/lonestar/archive/v${PV}.tar.gz -> ${P}.tar.gz"
HOMEPAGE="https://gitlab.com/tyil/lonestar"
SRC_URI="https://gitlab.com/tyil/lonestar/-/archive/v${PV}/lonestar-v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="AGPL-3"
SLOT="0"
Expand Down
25 changes: 25 additions & 0 deletions dev-util/lonestar/lonestar-9999.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2018 Patrick Spek <[email protected]>
#
# Distributed under the terms of the GNU Affero General Public License v3

EAPI=6

DESCRIPTION="A small Bash application to install the Rakudo Star Perl 6 distribution"
HOMEPAGE="https://gitlab.com/tyil/lonestar"
SRC_URI="https://gitlab.com/tyil/lonestar/-/archive/master/lonestar-master.tar.gz -> ${P}.tar.gz"

LICENSE="AGPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND=""
RDEPEND="${DEPEND}"

src_compile() {
:;
}

src_install() {
emake DESTDIR="${D}/usr" install
}