diff --git a/.gitattributes b/.gitattributes
index 9377325..f7db292 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -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
+
diff --git a/Makefile b/Makefile
index 7c0afc0..d3acb41 100644
--- a/Makefile
+++ b/Makefile
@@ -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 '(.*)' 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 '(.*)' 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
diff --git a/misc/HandlerManifest.json b/misc/HandlerManifest.json
index 325f5cd..be40a40 100644
--- a/misc/HandlerManifest.json
+++ b/misc/HandlerManifest.json
@@ -9,6 +9,7 @@
"supportsPolicy": true,
"rebootAfterInstall": false,
"reportHeartbeat": false,
- "updateMode": "UpdateWithInstall"
+ "updateMode": "UpdateWithInstall",
+ "catalogFileName": "custom-script-extension.cat"
}
}]
diff --git a/misc/custom-script-extension.cdf b/misc/custom-script-extension.cdf
new file mode 100644
index 0000000..070e80a
--- /dev/null
+++ b/misc/custom-script-extension.cdf
@@ -0,0 +1,13 @@
+[CatalogHeader]
+Name=custom-script-extension.cat
+ResultDir=.
+EncodingType=0x00010001
+CatalogVersion=2
+HashAlgorithms=SHA256
+CATATTR1=0x10010001:OSAttr:2:6.2
+
+[CatalogFiles]
+custom-script-shim=bin\custom-script-shim
+custom-script-extension=bin\custom-script-extension
+custom-script-extension-arm64=bin\custom-script-extension-arm64
+
diff --git a/misc/manifest.xml b/misc/manifest.xml
deleted file mode 100644
index be248d2..0000000
--- a/misc/manifest.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- Microsoft.Azure.Extensions
- CustomScript
- 2.1.18
-
- VmRole
-
- Microsoft Azure Custom Script Extension for Linux Virtual Machines
- true
- https://github.com/Azure/custom-script-extension-linux/blob/master/LICENSE
- http://www.microsoft.com/privacystatement/en-us/OnlineServices/Default.aspx
- https://github.com/Azure/custom-script-extension-linux
- true
- Linux
- Microsoft
-
-