Skip to content

Commit

Permalink
Merge pull request #7 from Sabayon/develop
Browse files Browse the repository at this point in the history
Add new features and review
  • Loading branch information
mudler authored May 18, 2019
2 parents c3b0468 + 8064b66 commit 1812f2b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
35 changes: 18 additions & 17 deletions sark-localbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ export LC_ALL=en_US.UTF-8
export SKIP_PORTAGE_SYNC="${SKIP_PORTAGE_SYNC:-0}"
export SKIP_CLEAN_PACKAGESDIR="${SKIP_CLEAN_PACKAGESDIR:-0}"
export EQUO_MIRRORSORT="${EQUO_MIRRORSORT:-0}"
# Enable/Disable create repository phase
export CREATEREPO_PHASE=${CREATEREPO_PHASE:-true}
# Enable/Disable builder phase. In general this is always true.
# It is set to false for testing injection of packages or move binhost files
# under a new repository.
export BUILDER_PHASE=${BUILDER_PHASE:-true}
export SAB_WORKSPACE="${SAB_WORKSPACE:-$PWD}"
export SAB_ARCH="${SAB_ARCH:-intel}"
export MAKE_CONF="${MAKE_CONF:-}"
export LOCAL_OVERLAY="${LOCAL_OVERLAY:-$SAB_WORKSPACE/local_overlay}"
export SKIP_COMMIT="${SKIP_COMMIT:-0}"
export SKIP_PUSH="${SKIP_PUSH:-0}"
export REPO_RESET="${REPO_RESET:-0}"
# Add skip env print if there are env vars with credentials.
export SKIP_PRINTENV="${SKIP_PRINTENV:-0}"
export REPO_CLEAN_EXPIRE="${REPO_CLEAN_EXPIRE:-0}"
export REPO_CLEAN_EXPIRE_DAYS="${REPO_CLEAN_EXPIRE_DAYS:-1}"
# Clean obsolete packages .tgz under binhost directory
export REPO_BINHOST_CLEAN="${REPO_BINHOST_CLEAN:-0}"

export SAB_BUILDFILE=${SAB_BUILDFILE:-build.yaml}
export SAB_BUILDER=${SAB_BUILDER:-/usr/sbin/builder}
export SAB_PORTDIR=${SAB_PORTDIR:-/opt/sabayon-build/conf/${SAB_ARCH}/portage}

export ENTROPY_DIR="/${SAB_WORKSPACE}/artifacts/${REPOSITORY_NAME}"
export EDITOR=cat

if [ -e "$SAB_WORKSPACE/specs/make.conf" ]; then
Expand Down Expand Up @@ -94,10 +91,7 @@ if [ -d "$SAB_WORKSPACE"/specs ]; then
cp -rfv "$SAB_WORKSPACE/specs/custom.keywords" "${SAB_PORTDIR}/package.keywords/99-custom.keywords"
fi

if [ -d "$SAB_WORKSPACE"/specs/env ] ; then
mkdir -p "${SAB_PORTDIR}/package.keywords" || true
cp -rfv "$SAB_WORKSPACE/specs/env/" "${SAB_PORTDIR}/env/"
fi
[ -d "$SAB_WORKSPACE"/specs/env ] && cp -rfv "$SAB_WORKSPACE/specs/env/" "${SAB_PORTDIR}/env/"

[ -e "$SAB_WORKSPACE"/specs/custom.env ] && cp -rfv "$SAB_WORKSPACE/specs/custom.env" "${SAB_PORTDIR}/package.env"
fi
Expand All @@ -108,9 +102,13 @@ if [ "${SKIP_PRINTENV}" != 1 ] ; then
fi


pushd /
/usr/bin/tini -s -- ${SAB_BUILDER} $BUILD_ARGS
popd
if [ "$BUILDER_PHASE" = true ] ; then
pushd /
/usr/bin/tini -s -- ${SAB_BUILDER} $BUILD_ARGS
popd
fi

[ "$CREATEREPO_PHASE" = false ] && exit $?

BUILD_STATUS=$?

Expand Down Expand Up @@ -144,7 +142,10 @@ if [ "$CHECK_BUILD_DIFFS" -eq 1 ]; then
cp -rf "${TBZ2_DIR}"/${TO_INJECT[$i]} ${TEMPDIR}/
done
fi
else
# Inject all packages available under /usr/portage/packages
cp -R /usr/portage/packages/* ${TEMPDIR} || true
fi

export PACKAGES_DIR=$TEMPDIR
sark-localcreaterepo
export PKGS_CACHE_DIR=$TEMPDIR
sark-localcreaterepo
26 changes: 20 additions & 6 deletions sark-localcreaterepo
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
export REPOSITORY_NAME="${REPOSITORY_NAME:-$(basename $(pwd))}"
export LC_ALL=en_US.UTF-8
export SKIP_PULL="${SKIP_PULL:-0}"
export SKIP_PUSH="${SKIP_PUSH:-0}"
export SKIP_COMMIT="${SKIP_COMMIT:-0}"
export SAB_WORKSPACE="${SAB_WORKSPACE:-$PWD}"

# Add additional option for eit inject command.
export EIT_INJECT_OPTS="${EIT_INJECT_OPTS:---quick}"
export REPO_RESET="${REPO_RESET:-0}"

# Add skip env print if there are env vars with credentials.
Expand All @@ -19,6 +23,12 @@ export REPOSITORY_DESCRIPTION="${REPOSITORY_DESCRIPTION:-Autogenerated repositor
export ENTROPY_DIR="${ENTROPY_DIR:-/${SAB_WORKSPACE}/artifacts/${REPOSITORY_NAME}}"
export PACKAGES_DIR="${PACKAGES_DIR:-/${SAB_WORKSPACE}/artifacts/${REPOSITORY_NAME}-binhost}"

export ENTROPY_RSS_BASEURL="${ENTROPY_RSS_BASEURL:-http://packages.sabayon.org/?quicksearch=}"
export ENTROPY_RSS_WEBURL="${ENTROPY_RSS_WEBURL:-http://www.sabayon.org/}"
# When PKGS_CACHE_DIR is defined then use directly packages
# directory without the use of a temporary directory.
export PKGS_CACHE_DIR="${PKGS_CACHE_DIR:-}"

set -e

. /sbin/sark-functions.sh
Expand All @@ -43,8 +53,8 @@ database-format = bz2
rss-feed = enable
changelog = enable
rss-name = packages.rss
rss-base-url = http://packages.sabayon.org/?quicksearch=
rss-website-url = http://www.sabayon.org/
rss-base-url = ${ENTROPY_RSS_BASEURL}
rss-website-url = ${ENTROPY_RSS_WEBURL}
max-rss-entries = 10000
# max-rss-light-entries = 100
rss-light-name = updates.rss
Expand All @@ -56,9 +66,13 @@ EOF


mkdir -p ${ENTROPY_DIR} || true
TEMPDIR=$(mktemp -d)

cp -rf $(find $PACKAGES_DIR -name "*.tbz2" | xargs) $TEMPDIR
if [ -z "${PKGS_CACHE_DIR}" ] ; then
TEMPDIR=$(mktemp -d)
cp -rf $(find $PACKAGES_DIR -name "*.tbz2" | xargs) $TEMPDIR
else
TEMPDIR="${PKGS_CACHE_DIR}"
fi

built_pkgs=$(find $TEMPDIR -name "*.tbz2" | xargs)
[[ -z "${built_pkgs}" ]] && echo "ERROR: no tbz2s found" && exit 2
Expand Down Expand Up @@ -90,13 +104,13 @@ fi
eit key import ${REPOSITORY_NAME} ${SAB_WORKSPACE}/confs/${REPOSITORY_NAME}.key ${SAB_WORKSPACE}/confs/${REPOSITORY_NAME}.pub && { eit key sign ${REPOSITORY_NAME} || true; } && { echo "=== Repository key imported successfully ==="; }
echo "=== Injecting packages ==="
echo "INJECT = ${built_pkgs}"
eit inject --to ${REPOSITORY_NAME} --quick ${built_pkgs} || { echo "ouch unable to inject" && exit 3; }
eit inject ${EIT_INJECT_OPTS} --to ${REPOSITORY_NAME} --quick ${built_pkgs} || { echo "ouch unable to inject" && exit 3; }
echo "=== Inject COMPLETED ====="

echo "=== Removing packages ==="

if [ -n "${TOREMOVE}" ]; then
echo "Yes" | eit rm --from $REPOSITORY_NAME $TOREMOVE || { echo "ouch unable to remove" && exit 3; }
eit rm --quick --from $REPOSITORY_NAME $TOREMOVE || { echo "ouch unable to remove" && exit 3; }
fi

echo "=== Removing packages completed ==="
Expand Down

0 comments on commit 1812f2b

Please sign in to comment.