Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,25 @@
# Declare files that will always have LF line endings on checkout.
Makefile text eol=lf

# Enforce LF line endings for script files.
*.sh text eol=lf
*.bash text eol=lf
*.bats text eol=lf
*.py text eol=lf

# Shebang scripts without extensions.
integration-test/env/fake-waagent text eol=lf
integration-test/env/wait-for-enable text eol=lf
misc/custom-script-shim text eol=lf
pkg/preprocess/testdata/script_shebang text eol=lf
pkg/preprocess/testdata/utf8_with_bom text eol=lf

# Keep DOS-specific preprocess fixtures as CRLF for tests.
pkg/preprocess/testdata/dos_with_bom.py text eol=crlf
pkg/preprocess/testdata/dos_with_bom.sh text eol=crlf
pkg/preprocess/testdata/dos_without_bom.py text eol=crlf
pkg/preprocess/testdata/dos_without_bom.sh text eol=crlf

# Packaging definition file requires CRLF for catalog signing
misc/custom-script-extension.cdf text eol=crlf

29 changes: 22 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,45 @@ BIN=custom-script-extension
BIN_ARM64=custom-script-extension-arm64
BUNDLEDIR=bundle
BUNDLE=custom-script-extension.zip
BUNDLE_UNZIP_DIR=custom-script-extension-bundle
GOPATH ?= $(shell go env GOPATH 2>/dev/null)
VERSION ?=

bundle: clean binary
@mkdir -p $(BUNDLEDIR)
zip -r ./$(BUNDLEDIR)/$(BUNDLE) ./$(BINDIR)
zip -j ./$(BUNDLEDIR)/$(BUNDLE) ./misc/HandlerManifest.json
zip -j ./$(BUNDLEDIR)/$(BUNDLE) ./misc/manifest.xml
zip -j ./$(BUNDLEDIR)/$(BUNDLE) ./misc/custom-script-extension.cdf

binary: clean
if [ -z "$$GOPATH" ]; then \
echo "GOPATH is not set"; \
bundle-dir: clean binary
@mkdir -p $(BUNDLEDIR)/$(BUNDLE_UNZIP_DIR)
cp -r ./$(BINDIR) ./$(BUNDLEDIR)/$(BUNDLE_UNZIP_DIR)/
cp ./misc/HandlerManifest.json ./$(BUNDLEDIR)/$(BUNDLE_UNZIP_DIR)/
cp ./misc/custom-script-extension.cdf ./$(BUNDLEDIR)/$(BUNDLE_UNZIP_DIR)/

validate-input:
if [ -z "$(VERSION)" ]; then \
echo "VERSION is required. Usage: make VERSION=X.Y.Z"; \
exit 1; \
fi
if [ -z "$(GOPATH)" ] || [ ! -d "$(GOPATH)" ]; then \
echo "GOPATH from 'go env GOPATH' is not set or does not exist: $(GOPATH)"; \
exit 1; \
fi

binary: validate-input clean
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v \
-tags "netgo osusergo" \
-ldflags "-X main.Version=`grep -E -m 1 -o '<Version>(.*)</Version>' misc/manifest.xml | awk -F">" '{print $$2}' | awk -F"<" '{print $$1}'`" \
-ldflags "-X main.Version=$(VERSION)" \
-o $(BINDIR)/$(BIN) ./main
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -v \
-tags "netgo osusergo" \
-ldflags "-X main.Version=`grep -E -m 1 -o '<Version>(.*)</Version>' misc/manifest.xml | awk -F">" '{print $$2}' | awk -F"<" '{print $$1}'`" \
-ldflags "-X main.Version=$(VERSION)" \
-o $(BINDIR)/$(BIN_ARM64) ./main
cp ./misc/custom-script-shim ./$(BINDIR)

clean:
rm -rf "$(BINDIR)" "$(BUNDLEDIR)"

.PHONY: clean binary
.PHONY: clean validate-input binary bundle bundle-dir

3 changes: 2 additions & 1 deletion misc/HandlerManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"supportsPolicy": true,
"rebootAfterInstall": false,
"reportHeartbeat": false,
"updateMode": "UpdateWithInstall"
"updateMode": "UpdateWithInstall",
"catalogFileName": "custom-script-extension.cat"
}
}]
13 changes: 13 additions & 0 deletions misc/custom-script-extension.cdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[CatalogHeader]
Name=custom-script-extension.cat
ResultDir=.
EncodingType=0x00010001
CatalogVersion=2
HashAlgorithms=SHA256
CATATTR1=0x10010001:OSAttr:2:6.2

[CatalogFiles]
<HASH>custom-script-shim=bin\custom-script-shim
<HASH>custom-script-extension=bin\custom-script-extension
<HASH>custom-script-extension-arm64=bin\custom-script-extension-arm64

18 changes: 0 additions & 18 deletions misc/manifest.xml

This file was deleted.

Loading