2018-06-06 09:55:55 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
#
|
2021-12-23 00:43:21 +00:00
|
|
|
# Copyright (C) 2018-2021 Roberto Mier Escandón <rmescandon@gmail.com>
|
2018-06-06 09:55:55 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 3 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
PROJECT := yq
|
|
|
|
OWNER := mikefarah
|
|
|
|
REPO := github.com
|
2020-02-16 19:16:23 +00:00
|
|
|
|
2018-06-06 09:55:55 +00:00
|
|
|
export DH_OPTIONS
|
|
|
|
export DH_GOPKG := ${REPO}/${OWNER}/${PROJECT}
|
2021-12-23 00:43:21 +00:00
|
|
|
export GOROOT := /usr/local/go
|
2018-06-06 09:55:55 +00:00
|
|
|
export GOPATH := ${CURDIR}/_build
|
|
|
|
export GOBIN := ${GOPATH}/bin
|
|
|
|
export PATH := ${GOROOT}/bin:${GOBIN}:${PATH}
|
2020-02-16 19:16:23 +00:00
|
|
|
export GOCACHE := /tmp/gocache
|
|
|
|
export GOFLAGS := -mod=vendor
|
2021-12-23 00:43:21 +00:00
|
|
|
export GO111MODULE := on
|
2020-02-16 19:16:23 +00:00
|
|
|
|
|
|
|
SRCDIR := ${GOPATH}/src/${DH_GOPKG}
|
2018-06-06 09:55:55 +00:00
|
|
|
DESTDIR := ${CURDIR}/debian/${PROJECT}
|
|
|
|
BINDIR := /usr/bin
|
2021-12-23 00:43:21 +00:00
|
|
|
MANDIR := /usr/share/man/man1/
|
2018-06-06 09:55:55 +00:00
|
|
|
ASSETSDIR := /usr/share/${PROJECT}
|
|
|
|
|
|
|
|
%:
|
2021-06-29 20:31:35 +00:00
|
|
|
dh $@
|
2018-06-06 09:55:55 +00:00
|
|
|
|
|
|
|
override_dh_auto_build:
|
|
|
|
mkdir -p ${SRCDIR}
|
|
|
|
mkdir -p ${GOBIN}
|
|
|
|
# copy project to local srcdir to build from there
|
2020-02-24 20:27:10 +00:00
|
|
|
rsync -avz --progress --exclude=_build --exclude=debian --exclude=tmp. --exclude=go.mod --exclude=docs . $(SRCDIR)
|
2018-06-06 09:55:55 +00:00
|
|
|
# build go code
|
2021-12-23 00:43:21 +00:00
|
|
|
( \
|
|
|
|
cd ${SRCDIR} && \
|
|
|
|
go install -buildmode=pie ./... \
|
|
|
|
)
|
|
|
|
|
|
|
|
# build man page
|
|
|
|
( \
|
|
|
|
cd ${SRCDIR} && \
|
|
|
|
./scripts/generate-man-page-md.sh && \
|
|
|
|
./scripts/generate-man-page.sh \
|
|
|
|
)
|
2020-02-16 19:16:23 +00:00
|
|
|
|
2018-06-06 09:55:55 +00:00
|
|
|
override_dh_auto_test:
|
2021-10-06 10:46:40 +00:00
|
|
|
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
|
2018-06-06 09:55:55 +00:00
|
|
|
(cd ${SRCDIR} && go test -v ./...)
|
2021-10-06 10:46:40 +00:00
|
|
|
endif
|
2018-06-06 09:55:55 +00:00
|
|
|
|
|
|
|
override_dh_auto_install:
|
2020-02-16 19:16:23 +00:00
|
|
|
cp ${GOBIN}/yq ${DESTDIR}/${BINDIR}
|
|
|
|
cp -f ${SRCDIR}/LICENSE ${DESTDIR}/${ASSETSDIR}
|
2018-06-06 09:55:55 +00:00
|
|
|
chmod a+x ${DESTDIR}/${BINDIR}/yq
|
|
|
|
|
2021-12-23 00:43:21 +00:00
|
|
|
# man
|
|
|
|
mkdir -p "${DESTDIR}"/"${MANDIR}"
|
|
|
|
cp "${SRCDIR}"/yq.1 "${DESTDIR}"/"${MANDIR}" \
|
|
|
|
|
2018-06-06 09:55:55 +00:00
|
|
|
override_dh_auto_clean:
|
|
|
|
dh_clean
|
|
|
|
rm -rf ${CURDIR}/_build
|