|
| 1 | +#!/bin/sh -l |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +repoman_args="$INPUT_REPOMAN_ARGS" |
| 6 | +path="$INPUT_PATH" |
| 7 | +profile="$INPUT_PROFILE" |
| 8 | +portage_version="$INPUT_PORTAGE_VERSION" |
| 9 | +gentoo_repo="$INPUT_GENTOO_REPO" |
| 10 | + |
| 11 | +apk add python3 py3-yaml py3-lxml git bash |
| 12 | +ln -s /usr/bin/python3 /usr/bin/python |
| 13 | +mkdir -p /etc/portage /var/cache/distfiles "$gentoo_repo" |
| 14 | +echo "portage:x:250:250:portage:/var/tmp/portage:/bin/false" >> /etc/passwd |
| 15 | +echo "portage::250:portage" >> /etc/group |
| 16 | +wget "https://www.gentoo.org/dtd/metadata.dtd" -O /var/cache/distfiles/metadata.dtd |
| 17 | +wget -O - "https://github.com/gentoo-mirror/gentoo/archive/master.tar.gz" | tar xz -C "$gentoo_repo" --strip-components=1 |
| 18 | + |
| 19 | +if [ "$profile" = "latest" ]; then |
| 20 | + profile="$(sed "1,/SYMLINK_LIB=no/d" < "$gentoo_repo/profiles/profiles.desc" | grep stable | head -1 | awk '{print $2}')" |
| 21 | +fi |
| 22 | +echo "Using profile \"$profile\"" |
| 23 | + |
| 24 | +if [ ! -e "$gentoo_repo/profiles/$profile" ]; then |
| 25 | + echo "Profile \"$profile\" not found in $gentoo_repo/profiles/" |
| 26 | + exit 2 |
| 27 | +fi |
| 28 | +ln -s "$gentoo_repo/profiles/$profile" /etc/portage/make.profile |
| 29 | + |
| 30 | +if [ "$portage_version" = "latest" ]; then |
| 31 | + portage_version=$(grep DIST "$gentoo_repo/sys-apps/portage/Manifest" | tail -1 | cut -d ' ' -f 2) |
| 32 | + portage_version=${portage_version%.tar.bz2} |
| 33 | + portage_version=${portage_version#portage-} # e.g. "2.3.20" |
| 34 | +fi |
| 35 | +echo "Using portage version \"$portage_version\"" |
| 36 | + |
| 37 | +if [ -z "$portage_version" ]; then |
| 38 | + echo "Unable to determine portage version." |
| 39 | + exit 3 |
| 40 | +fi |
| 41 | + |
| 42 | +wget -O - "https://github.com/gentoo/portage/archive/portage-${portage_version}.tar.gz" | tar xz -C / |
| 43 | +ln -s "/portage-portage-${portage_version}/cnf/repos.conf" /etc/portage/repos.conf |
| 44 | +ln -s "/portage-portage-${portage_version}/repoman/bin/repoman" /usr/bin/repoman |
| 45 | + |
| 46 | +if [ ! -d ".git" ]; then |
| 47 | + echo |
| 48 | + echo "Found no git repository." |
| 49 | + echo "Did you forget the actions/checkout step in your workflow job?" |
| 50 | + echo |
| 51 | + echo " steps:" |
| 52 | + echo " - uses: actions/checkout@v2" |
| 53 | + echo |
| 54 | +fi |
| 55 | + |
| 56 | +if [ -n "$path" ]; then |
| 57 | + cd "$path" |
| 58 | +fi |
| 59 | + |
| 60 | +echo "Running 'repoman full $repoman_args' from $(pwd)" |
| 61 | +# shellcheck disable=SC2086 |
| 62 | +repoman full $repoman_args |
0 commit comments