From 2d664ada40e0d94f1d303da40f28cd5b34227f16 Mon Sep 17 00:00:00 2001 From: Vladislav Ananev Date: Sat, 17 Dec 2022 00:48:53 +0400 Subject: [PATCH] added deb build script --- .gitignore | 1 + DEBIAN/control | 6 ++++++ README.md | 21 +++++++++++++++++++++ build-deb.sh | 23 +++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 DEBIAN/control create mode 100755 build-deb.sh diff --git a/.gitignore b/.gitignore index 18aaecf..970aa9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ etcd-walker.log +etcd-walker build/ diff --git a/DEBIAN/control b/DEBIAN/control new file mode 100644 index 0000000..d385a9e --- /dev/null +++ b/DEBIAN/control @@ -0,0 +1,6 @@ +Package: etcd-walker +Version: _version_ +Architecture: amd64 +Maintainer: Vladislav Ananev +Description: Simple free CLI tool for etcd +Installed-Size: 10230 diff --git a/README.md b/README.md index 627596b..9e26aaf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,27 @@ in some cases (for example for running inside containers) need to build statical ``` go build -ldflags "-linkmode external -extldflags -static" ``` +to check for lib usage please use ldd command +``` +ldd etcd-walker +``` + +building 32-bit binary +``` +GOOS=linux GOARCH=386 go build -o etcd-walker_linux_i686 main.go +``` + +### **Building deb package** + +installing required tools including golang +``` +sudo apt-get install git devscripts build-essential lintian upx-ucl golang +``` +run build script +``` +./build-deb.sh +``` + ### **Running:** ``` diff --git a/build-deb.sh b/build-deb.sh new file mode 100755 index 0000000..74deb05 --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,23 @@ +#!/bin/env bash + +version=0.0.8 + +echo "building deb for etcd-walker $version" + +if ! type "dpkg-deb" > /dev/null; then + echo "please install required build tools first" +fi + +project="etcd-walker_${version}_amd64" +folder_name="build/$project" +echo "crating $folder_name" +mkdir -p $folder_name +cp -r DEBIAN/ $folder_name +bin_dir="$folder_name/usr/bin" +mkdir -p $bin_dir +go build -ldflags "-linkmode external -extldflags -static" -o etcd-walker cmd/etcd-walker/main.go + +mv etcd-walker $bin_dir +sed -i "s/_version_/$version/g" $folder_name/DEBIAN/control + +cd build/ && dpkg-deb --build --root-owner-group $project