-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (54 loc) · 2.32 KB
/
Makefile
File metadata and controls
61 lines (54 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.PHONY: all build clean test lint deb
# Variables
BINARY_NAME=bucketsyncd
VERSION?=v0.4.0
ARCH?=amd64
PKG_VERSION=$(VERSION:v%=%)
BUILD_DIR=build
DEB_DIR=$(BUILD_DIR)/debian
# Default target
all: build
# Build the binary
build:
mkdir -p $(BUILD_DIR)
go build -ldflags="-s -w -X main.version=$(VERSION) -X main.buildTime=$(shell date -u +%Y-%m-%dT%H:%M:%SZ) -X main.gitCommit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)" -o "$(BUILD_DIR)/$(BINARY_NAME)" .
# Run tests
test:
go test ./...
# Run linter
lint:
golangci-lint run
# Create .deb package
deb: build
@echo "Building .deb package for $(PKG_VERSION) on $(ARCH)"
# Create Debian package structure
mkdir -p $(DEB_DIR)/DEBIAN
mkdir -p $(DEB_DIR)/usr/bin
mkdir -p $(DEB_DIR)/usr/share/doc/bucketsyncd/examples
# Copy binary
cp "$(BUILD_DIR)/$(BINARY_NAME)" $(DEB_DIR)/usr/bin/$(BINARY_NAME)
chmod 755 $(DEB_DIR)/usr/bin/$(BINARY_NAME)
# Copy documentation
cp README.md $(DEB_DIR)/usr/share/doc/bucketsyncd/
cp CHANGELOG.md $(DEB_DIR)/usr/share/doc/bucketsyncd/
cp -r example/* $(DEB_DIR)/usr/share/doc/bucketsyncd/examples/
# Create control file
echo "Package: $(BINARY_NAME)" > $(DEB_DIR)/DEBIAN/control
echo "Version: $(PKG_VERSION)" >> $(DEB_DIR)/DEBIAN/control
echo "Architecture: $(ARCH)" >> $(DEB_DIR)/DEBIAN/control
echo "Maintainer: rossigee <ross@example.com>" >> $(DEB_DIR)/DEBIAN/control
echo "Description: Bucket synchronisation service for automatic file sync" >> $(DEB_DIR)/DEBIAN/control
echo " This application provides a bucket synchronisation service that automatically" >> $(DEB_DIR)/DEBIAN/control
echo " downloads files to a local folder as they appear in a remote bucket, or uploads" >> $(DEB_DIR)/DEBIAN/control
echo " files to a remote bucket or WebDAV server from a local folder." >> $(DEB_DIR)/DEBIAN/control
echo "Depends: libc6" >> $(DEB_DIR)/DEBIAN/control
echo "Section: utils" >> $(DEB_DIR)/DEBIAN/control
echo "Priority: optional" >> $(DEB_DIR)/DEBIAN/control
echo "Homepage: https://github.com/rossigee/bucketsyncd" >> $(DEB_DIR)/DEBIAN/control
echo "License: MIT" >> $(DEB_DIR)/DEBIAN/control
# Build .deb package
cd $(BUILD_DIR) && dpkg-deb --build debian "$(BINARY_NAME)-$(PKG_VERSION)-$(ARCH).deb"
@echo "Package created: $(BUILD_DIR)/$(BINARY_NAME)-$(PKG_VERSION)-$(ARCH).deb"
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)