Skip to content

Commit

Permalink
Packer customize package info (#3188)
Browse files Browse the repository at this point in the history
* packer: Enable overriding of vendor and license
* packer: customize URL of documentation link
* packer: location of readme.md.j2 folder can be specified with PACKER_TEMPLATES_DIR
  • Loading branch information
cyrilleverrier authored and ruflin committed Dec 14, 2016
1 parent d22c291 commit 32b1e19
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dev-tools/packer/platforms/centos/run.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ RPM_VERSION=`echo ${VERSION} | sed 's/-/_/g'`
fpm --force -s dir -t rpm \
-n {{.beat_name}} -v ${RPM_VERSION} \
--architecture {{.rpm_arch}} \
--vendor "Elastic" \
--license "ASL 2.0" \
--vendor "{{.beat_vendor}}" \
--license "{{.beat_license}}" \
--description "{{.beat_description}}" \
--url {{.beat_url}} \
--rpm-init /tmp/{{.beat_name}}.init \
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/packer/platforms/centos/systemd.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description={{.beat_name}}
Documentation=https://www.elastic.co/guide/en/beats/{{.beat_name}}/current/index.html
Documentation={{.beat_doc_url}}
Wants=network-online.target
After=network-online.target

Expand Down
4 changes: 2 additions & 2 deletions dev-tools/packer/platforms/debian/run.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fi
# create deb
fpm --force -s dir -t deb \
-n {{.beat_name}} -v ${VERSION} \
--vendor "Elastic" \
--license "ASL 2.0" \
--vendor "{{.beat_vendor}}" \
--license "{{.beat_license}}" \
--architecture {{.deb_arch}} \
--description "{{.beat_description}}" \
--url {{.beat_url}} \
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/packer/platforms/debian/systemd.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description={{.beat_name}}
Documentation=https://www.elastic.co/guide/en/beats/{{.beat_name}}/current/index.html
Documentation={{.beat_doc_url}}
Wants=network-online.target
After=network-online.target

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/packer/xgo-scripts/before_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ go install github.com/tsg/gotpl
cat ${LIBBEAT_PATH}/docs/version.asciidoc >> ${PREFIX}/package.yml
# Make variable naming of doc-branch compatible with gotpl. Generate and copy README.md into homedir
sed -i -e 's/:doc-branch/doc_branch/g' ${PREFIX}/package.yml
/go/bin/gotpl ${LIBBEAT_PATH}/../dev-tools/packer/readme.md.j2 < ${PREFIX}/package.yml > ${PREFIX}/homedir/README.md
/go/bin/gotpl /templates/readme.md.j2 < ${PREFIX}/package.yml > ${PREFIX}/homedir/README.md

# Copy template
cp $BEATNAME.template.json $PREFIX/$BEATNAME.template.json
Expand Down
13 changes: 11 additions & 2 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

### VARIABLE SETUP ###

### Application using libbeat may override the following variables in their Makefile
BEATNAME?=libbeat
BEAT_DESCRIPTION?=Sends events to Elasticsearch or Logstash
BEAT_VENDOR?=Elastic
BEAT_LICENSE?=ASL 2.0
BEAT_DOC_URL?=https://www.elastic.co/guide/en/beats/${BEATNAME}/current/index.html
BEAT_DIR?=github.com/elastic/beats/${BEATNAME}
ES_BEATS?=..
GOPACKAGES?=${BEAT_DIR}/...
PACKER_TEMPLATES_DIR?=${ES_BEATS}/dev-tools/packer

# Makefile for a custom beat that includes this libbeat/scripts/Makefile:
# if glide is used to manage vendor dependencies,
Expand Down Expand Up @@ -341,6 +344,7 @@ prepare-package:
# cross compile on ubuntu
docker run --rm \
-v $(abspath ${ES_BEATS}/dev-tools/packer/xgo-scripts):/scripts \
-v $(abspath ${PACKER_TEMPLATES_DIR}):/templates \
-v $(abspath ../):/source \
-v $(BUILD_DIR):/build \
-e PUREGO="yes" \
Expand All @@ -359,6 +363,7 @@ prepare-package-cgo:
# cross compile on ubuntu
docker run --rm \
-v $(abspath ${ES_BEATS}/dev-tools/packer/xgo-scripts):/scripts \
-v $(abspath ${PACKER_TEMPLATES_DIR}):/templates \
-v $(abspath ../):/source \
-v $(BUILD_DIR):/build \
-e PACK=${BEATNAME} \
Expand All @@ -373,6 +378,7 @@ prepare-package-cgo:
docker run --rm \
-v ${BUILD_DIR}:/build \
-v $(abspath ${ES_BEATS}/dev-tools/packer/xgo-scripts):/scripts \
-v $(abspath ${PACKER_TEMPLATES_DIR}):/templates \
-v $(abspath ..):/source \
-e PACK=${BEATNAME} \
-e BEFORE_BUILD=before_build.sh \
Expand Down Expand Up @@ -400,6 +406,9 @@ package: package-setup
echo "beat_url: https://${BEAT_DIR}" >> ${BUILD_DIR}/package.yml
echo "beat_repo: ${BEAT_DIR}" >> ${BUILD_DIR}/package.yml
echo "beat_description: ${BEAT_DESCRIPTION}" >> ${BUILD_DIR}/package.yml
echo "beat_vendor: ${BEAT_VENDOR}" >> ${BUILD_DIR}/package.yml
echo "beat_license: ${BEAT_LICENSE}" >> ${BUILD_DIR}/package.yml
echo "beat_doc_url: ${BEAT_DOC_URL}" >> ${BUILD_DIR}/package.yml
cat ${ES_BEATS}/dev-tools/packer/version.yml >> ${BUILD_DIR}/package.yml

if [ $(CGO) = true ]; then \
Expand Down

0 comments on commit 32b1e19

Please sign in to comment.