Skip to content

Commit

Permalink
Merge pull request #89 from OctopusDeploy/enh-packaging-adjustments
Browse files Browse the repository at this point in the history
Minor packaging improvements
  • Loading branch information
thedewi authored Jun 30, 2020
2 parents 74e979e + cffeecf commit d48a543
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
8 changes: 5 additions & 3 deletions BuildAssets/create-octopuscli-linux-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ which fpm >/dev/null || {
exit 1
}
if [[ ! -e /opt/linux-package-feeds ]]; then
echo "This script requires tools in '/opt/linux-package-feeds'. If running inside a container, check the volume mounts." >&2
echo "This script requires 'linux-package-feeds' scripts, installed in '/opt/linux-package-feeds'." >&2
echo "They come from https://github.com/OctopusDeploy/linux-package-feeds, distributed in TeamCity" >&2
echo " via 'Infrastructure / Linux Package Feeds'. If running inside a Docker container, supply them using a volume mount." >&2
exit 1
fi


# Create .deb and .rpm packages, with executable permission and a /usr/bin symlink, using a script from 'linux-package-feeds'.
COMMAND_FILE=octo
INSTALL_PATH=/opt/octopus/octopuscli
PACKAGE_NAME=octopuscli
Expand All @@ -48,5 +51,4 @@ FPM_RPM_OPTS=(
--depends 'zlib'
--depends 'libicu'
)

source /opt/linux-package-feeds/create-linux-packages.sh
source /opt/linux-package-feeds/create-linux-packages.sh || exit
7 changes: 4 additions & 3 deletions BuildAssets/repos/test-linux-package-from-feed-in-dists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Smoke test our apt and rpm feeds in various dockerized distros.

if [[ ! -e "$LPF_PATH" ]]; then
echo 'This script requires the environment variable LPF_PATH - the location of "linux-package-feeds" tools to use.' >&2
echo "This script requires the environment variable LPF_PATH - the location of 'linux-package-feeds' scripts to use." >&2
echo "They come from https://github.com/OctopusDeploy/linux-package-feeds, distributed in TeamCity" >&2
echo " via 'Infrastructure / Linux Package Feeds'." >&2
exit 1
fi
if [[ -z "$PUBLISH_LINUX_EXTERNAL" ]]; then
echo 'This script requires the environment variable PUBLISH_LINUX_EXTERNAL - specify "true" to test the external public feed.' >&2
exit 1
fi
OSRELID="$(. /etc/os-release && echo $ID)"
if [[ -z "$OCTOPUS_CLI_SERVER" || -z "$OCTOPUS_CLI_API_KEY" || -z "$OCTOPUS_SPACE" || -z "$OCTOPUS_EXPECT_ENV" ]]; then
echo -e 'This script requires the environment variables OCTOPUS_CLI_SERVER, OCTOPUS_CLI_API_KEY, OCTOPUS_SPACE, and'\
'\nOCTOPUS_EXPECT_ENV - specifying an Octopus server for testing "list-environments", an API key to access it, the'\
Expand All @@ -25,7 +26,7 @@ do
echo "== Testing in '$DOCKER_IMAGE' =="
docker pull "$DOCKER_IMAGE" >/dev/null || exit
docker run --rm \
--hostname "testfeedpkgs$RANDOM" \
--hostname "octotestfeedpkg$RANDOM" \
--volume "$(pwd):/working" --volume "$SCRIPT_DIR/test-linux-package-from-feed.sh:/test-linux-package-from-feed.sh" \
--volume "$(realpath "$LPF_PATH"):/opt/linux-package-feeds" \
--env PUBLISH_LINUX_EXTERNAL \
Expand Down
10 changes: 6 additions & 4 deletions BuildAssets/repos/test-linux-package-from-feed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ if [[ -z "$OCTOPUS_CLI_SERVER" || -z "$OCTOPUS_CLI_API_KEY" || -z "$OCTOPUS_SPAC
fi

if [[ ! -e /opt/linux-package-feeds ]]; then
echo "This script requires tools in '/opt/linux-package-feeds'. If running inside a container, check the volume mounts." >&2
echo "This script requires 'linux-package-feeds' scripts, installed in '/opt/linux-package-feeds'." >&2
echo "They come from https://github.com/OctopusDeploy/linux-package-feeds, distributed in TeamCity" >&2
echo " via 'Infrastructure / Linux Package Feeds'. If running inside a Docker container, supply them using a volume mount." >&2
exit 1
fi


# Install the packages from our package feed (with any needed docker config, system registration) using a script from 'linux-package-feeds'.
export PKG_NAMES="octopuscli tentacle"
# TODO: (ZZDY) Remove this workaround once tentacle is added to focal repo
if grep --quiet focal /etc/apt/sources.list 2>/dev/null; then
PKG_NAMES="octopuscli"
fi

bash /opt/linux-package-feeds/install-linux-feed-package.sh || exit

if command -v dpkg > /dev/null; then
Expand All @@ -46,6 +48,6 @@ echo "$OCTO_RESULT" | grep "$OCTOPUS_EXPECT_ENV" || { echo "Expected environment
# TODO: (ZZDY) Remove this workaround once tentacle is added to focal repo
if [[ ! "$PKG_NAMES" == *tentacle ]]; then exit 0; fi

echo Softly smoke-testing tentacle.
/opt/octopus/tentacle/Tentacle version
echo Testing tentacle.
/opt/octopus/tentacle/Tentacle version || exit
echo
6 changes: 4 additions & 2 deletions BuildAssets/test-linux-package-in-dists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Test that .deb and .rpm packages in the working directory install an octo command that can list-environments.

if [[ ! -e "$LPF_PATH" ]]; then
echo 'This script requires the environment variable LPF_PATH - the location of "linux-package-feeds" tools to use.' >&2
echo "This script requires the environment variable LPF_PATH - the location of 'linux-package-feeds' scripts to use." >&2
echo "They come from https://github.com/OctopusDeploy/linux-package-feeds, distributed in TeamCity" >&2
echo " via 'Infrastructure / Linux Package Feeds'." >&2
exit 1
fi
if [[ -z "$OCTOPUS_CLI_SERVER" || -z "$OCTOPUS_CLI_API_KEY" || -z "$OCTOPUS_SPACE" || -z "$OCTOPUS_EXPECT_ENV" ]]; then
Expand All @@ -24,7 +26,7 @@ do
echo "== Testing in '$DOCKER_IMAGE' =="
docker pull "$DOCKER_IMAGE" >/dev/null || exit
docker run --rm \
--hostname "testpkgs$RANDOM" \
--hostname "octotestpkg$RANDOM" \
--volume "$(pwd):/working" --volume "$SCRIPT_DIR/test-linux-package.sh:/test-linux-package.sh" \
--volume "$(realpath "$LPF_PATH"):/opt/linux-package-feeds" \
--env OCTOPUS_CLI_SERVER --env OCTOPUS_CLI_API_KEY --env OCTOPUS_SPACE --env OCTOPUS_EXPECT_ENV \
Expand Down
5 changes: 4 additions & 1 deletion BuildAssets/test-linux-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ if [[ "$OSRELID" == "rhel" && ( -z "$REDHAT_SUBSCRIPTION_USERNAME" || -z "$REDHA
fi

if [[ ! -e /opt/linux-package-feeds ]]; then
echo "This script requires tools in '/opt/linux-package-feeds'. If running inside a container, check the volume mounts." >&2
echo "This script requires 'linux-package-feeds' scripts, installed in '/opt/linux-package-feeds'." >&2
echo "They come from https://github.com/OctopusDeploy/linux-package-feeds, distributed in TeamCity" >&2
echo " via 'Infrastructure / Linux Package Feeds'. If running inside a Docker container, supply them using a volume mount." >&2
exit 1
fi


# Install the package (with any needed docker config, system registration, dependencies) using a script from 'linux-package-feeds'.
export PKG_PATH_PREFIX="octopuscli"
bash /opt/linux-package-feeds/install-linux-package.sh || exit

Expand Down
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Task("CreateLinuxPackages")
.IsDependentOn("AssertLinuxSelfContainedArtifactsExists")
.Does(() =>
{
// This task requires `linuxPackageFeedsDir` to contain tools from https://github.com/OctopusDeploy/linux-package-feeds.
// This task requires `linuxPackageFeedsDir` to contain scripts from https://github.com/OctopusDeploy/linux-package-feeds.
// They are currently added as an Artifact Dependency in TeamCity from "Infrastructure / Linux Package Feeds"
// with the rule: LinuxPackageFeedsTools.*.zip!*=>linux-package-feeds
// See https://build.octopushq.com/admin/editDependencies.html?id=buildType:OctopusDeploy_OctopusCLI_BuildLinuxContainer
Expand Down

0 comments on commit d48a543

Please sign in to comment.