Skip to content

Commit

Permalink
Build separate OSS and Elastic licensed packages
Browse files Browse the repository at this point in the history
Now `dev-tools/osx-deploy` builds two sets of packages per Beat:
- beatname-oss-version.{pkg,dmg} packages without X-Pack content.
- beatname-version.{pkg,dmg} packages with X-Pack content

The main Makefile target has been renamed to `osx-package-all` to match
the existing `package-all` target. From inside a Beat it is possible to
use the targets `osx-package-oss` and `osx-package-elastic` to build
only one set of packages.
  • Loading branch information
adriansr committed Jun 19, 2018
1 parent 3951924 commit 25b08b5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ package-all: update beats-dashboards
@# Run tests on the generated packages.
@go test ./dev-tools/package_test.go -files "${BUILD_DIR}/upload/*/*"

.PHONY: osx-package
osx-package:
.PHONY: osx-package-all
osx-package-all:
@$(test "$(uname -s)" = Darwin || { echo "Must run on Darwin" ; exit 1;} )
@$(foreach var,$(OSX_BEATS),$(MAKE) -C $(var) osx-package || exit 1;)
@$(foreach var,$(OSX_BEATS),$(MAKE) -C $(var) osx-package-all || exit 1;)
@mkdir -p build/upload/
@$(foreach var,$(OSX_BEATS),cp -r $(var)/build/upload/*.dmg $(var)/build/upload/*.pkg build/upload/$(var) || exit 1;)

Expand Down
4 changes: 2 additions & 2 deletions dev-tools/osx-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def main():
dir = os.path.dirname(__file__)
os.chdir(dir + "/../")
if args.no_snapshot:
check_call("make SNAPSHOT=no osx-package", shell=True)
check_call("make SNAPSHOT=no osx-package-all", shell=True)
else:
check_call("make SNAPSHOT=yes osx-package", shell=True)
check_call("make SNAPSHOT=yes osx-package-all", shell=True)
print("All done")

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/packer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ beat_abspath=${BEATS_GOPATH}/src/${BEAT_PATH}

%/dmg:
echo Creating OSX packages for $(@D)
ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) $(packer_absdir)/platforms/darwin/pkg/build.sh
ARCH=amd64 BEAT=$(@D) BUILD_DIR=${BUILD_DIR} UPLOAD_DIR=${UPLOAD_DIR} BEAT_PATH=$(beat_abspath) BUILDID=$(BUILDID) SNAPSHOT=$(SNAPSHOT) PKG_SUFFIX=$(PKG_SUFFIX) $(packer_absdir)/platforms/darwin/pkg/build.sh

.PHONY: package-dashboards
package-dashboards:
Expand Down
7 changes: 5 additions & 2 deletions dev-tools/packer/platforms/darwin/pkg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,25 @@ test -n "SIGN_IDENTITY_INSTALLER" || die "Installer certificate not found"
test -n "SIGN_IDENTITY_APP" || die "Codesigning certificate not found"
export SIGN_IDENTITY_INSTALLER SIGN_IDENTITY_APP

test -f "${BUILD_DIR}/package.yml" || die "package.yml not found in BUILD_DIR"
PKG_YML="${BUILD_DIR}/package${PKG_SUFFIX}/package.yml"
test -f "$PKG_YML" || die "package.yml not found in $PKG_YML"
ARCH_FILE="${PACKERDIR}/archs/$ARCH.yml"
test -f "$ARCH_FILE" || die "$ARCH_FILE not found (check ARCH environment variable)"

TMPDIR=$(mktemp -d)
test "$?" -ne 0 && die "Failed creating temporary directory"
echo "Building in directory $TMPDIR"

cat "${BUILD_DIR}/package.yml" "$ARCH_FILE" "$BASEDIR/base_conf.yml" > "${TMPDIR}/conf.yml" || die "Failed generating conf.yml"
cat "$PKG_YML" "$ARCH_FILE" "$BASEDIR/base_conf.yml" > "${TMPDIR}/conf.yml" || die "Failed generating conf.yml"

if [ "$SNAPSHOT" = "yes" ]; then
echo 'snapshot: "-SNAPSHOT"' >> "${TMPDIR}/conf.yml"
else
echo 'snapshot: ""' >> "${TMPDIR}/conf.yml"
fi

echo "pkg_suffix: '${PKG_SUFFIX}'" >> "${TMPDIR}/conf.yml"

echo 'Building preference-pane'
make -e CODE_SIGNING_REQUIRED=YES -C "${PACKERDIR}/platforms/darwin/preference-pane" clean build pkg || die "Build of preference-pane failed"
cp -a "${PACKERDIR}/platforms/darwin/preference-pane/BeatsPrefPane.pkg" "${TMPDIR}/" || die "Preference pane package not found"
Expand Down
9 changes: 6 additions & 3 deletions dev-tools/packer/platforms/darwin/pkg/internal_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ set -e

BASEDIR=$(cd "$(dirname "$0")"; pwd)

FILE_NAME="$BEAT-$VERSION-$ARCH"
FILE_NAME="$BEAT$PKG_SUFFIX-$VERSION-$ARCH"
PKG_NAME="$FILE_NAME.pkg"
DMG_NAME="$FILE_NAME.dmg"
INNER_NAME="internal-$FILE_NAME.pkg"
VENDOR_DIR="root/$INSTALL_PATH/$VENDOR"
BEAT_DIR="$VENDOR_DIR/$BEAT"
mkdir -p "$VENDOR_DIR"
TAR_NAME="$BEAT-$VERSION-darwin-$ARCH"
TAR_NAME="$BEAT$PKG_SUFFIX-$VERSION-darwin-$ARCH"
# When uncompressed, both the -oss and non-oss tar.gz
# yield the same directory name.
TAR_DIR_NAME="$BEAT-$VERSION-darwin-$ARCH"
tar zxf "$BUILD_DIR/upload/$TAR_NAME".tar.gz
mv "$TAR_NAME" "$BEAT_DIR"
mv "$TAR_DIR_NAME" "$BEAT_DIR"

cp launchd-daemon.plist "$BEAT_DIR/$IDENTIFIER.plist"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<pkg-ref id="{{.identifier_base}}.{{.beat_name}}"/>
<pkg-ref id="{{.identifier_base}}.preference-pane"/>
</choice>
<pkg-ref id="{{.identifier_base}}.{{.beat_name}}" version="{{.version}}{{.snapshot}}" auth="Root" onConclusion="none">internal-{{.beat_name}}-{{.version}}{{.snapshot}}-{{.osx_arch}}.pkg</pkg-ref>
<pkg-ref id="{{.identifier_base}}.{{.beat_name}}" version="{{.version}}{{.snapshot}}" auth="Root" onConclusion="none">internal-{{.beat_name}}{{.pkg_suffix}}-{{.version}}{{.snapshot}}-{{.osx_arch}}.pkg</pkg-ref>
<readme file="README.html" />
<license file="LICENSE.txt" />
<title>{{.beat_name}} {{.version}}{{.snapshot}}</title>
Expand Down
13 changes: 12 additions & 1 deletion libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,21 @@ package-dashboards: package-setup
# build the dashboards package
BEAT_NAME=${BEAT_NAME} BUILD_DIR=${BUILD_DIR} SNAPSHOT=$(SNAPSHOT) $(MAKE) -C ${ES_BEATS}/dev-tools/packer package-dashboards ${shell pwd}/build/upload/build_id.txt

.PHONY: osx-package-all
osx-package-all: osx-package-elastic osx-package-oss

.PHONY: osx-package-elastic
osx-package-elastic:
@$(MAKE) osx-package

.PHONY: osx-package-oss
osx-package-oss:
@$(MAKE) PKG_SUFFIX=-oss osx-package

.PHONY: osx-package
osx-package: package-yml
osx-package: ## @packaging Create OSX packages for the beat.
$(MAKE) -C ${ES_BEATS}/dev-tools/packer -e BEAT_NAME=${BEAT_NAME} BUILD_DIR=${BUILD_DIR} SNAPSHOT=$(SNAPSHOT) $(BEAT_NAME)/dmg
$(MAKE) -C ${ES_BEATS}/dev-tools/packer -e PKG_SUFFIX=${PKG_SUFFIX} BEAT_NAME=${BEAT_NAME} BUILD_DIR=${BUILD_DIR} SNAPSHOT=$(SNAPSHOT) $(BEAT_NAME)/dmg

fix-permissions:
# Change ownership of all files inside /build folder from root/root to current user/group
Expand Down

0 comments on commit 25b08b5

Please sign in to comment.