Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian package #510

Merged
merged 1 commit into from
Dec 11, 2019
Merged
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 tekton/debbuild/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
* We are proving a PPA for users to install, it should be compatible with most debian versions.

* Since we need a GPG key we build directly the docker image and mount our ~/.gnupg into the container.

* First you need to join the launchpad team here :

https://launchpad.net/~tektoncd/+join

* You need to make sure you upload your GPG key to your launchpad profile, ie:

https://launchpad.net/~chmouel/+editpgpkeys


(replace chmouel by your user)

* add an environment variable called GPG_KEY with your GPG key user ID

* start `./run.sh`

* It should upload to
https://launchpad.net/~tektoncd/+archive/ubuntu/cli/+packages you can inspect
the build logs in there in case of failure.
25 changes: 25 additions & 0 deletions tekton/debbuild/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# using rolling to get latest golang
FROM ubuntu:rolling

RUN set -ex \
&& sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
dput \
cdbs \
git \
curl \
equivs \
vim \
libdistro-info-perl \
bash-completion \
golang-any \
devscripts \
debhelper \
dh-golang \
fakeroot \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/*

ADD buildpackage.sh /run.sh
42 changes: 42 additions & 0 deletions tekton/debbuild/container/buildpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
set -eux

[[ -z ${GPG_KEY} ]] && {
echo "You need to setup your GPG_KEY."
exit 1
}

[[ -z ${PPATARGET} ]] && {
echo "You need to setup a PPA Target."
exit 1
}


TMPD=$(mktemp -d)
mkdir -p ${TMPD}
clean() { rm -rf ${TMPD} ;}
# trap clean EXIT
TMPD=/tmp/debug;mkdir -p ${TMPD}

curl -o ${TMPD}/output.json -s https://api.github.com/repos/tektoncd/cli/releases/latest
version=$(python3 -c "import sys, json;x=json.load(sys.stdin);print(x['tag_name'])" < ${TMPD}/output.json)
version=${version/v}

cd ${TMPD}

curl -C- -L -# -o tektoncd-cli_${version}.orig.tar.gz -L https://github.com/tektoncd/cli/archive/v${version}.tar.gz
tar xzf ${TMPD}/tektoncd-cli_${version}.orig.tar.gz

cd cli-${version}

# Make it easy for devs
[[ -d /debian ]] && { rm -rf debian && cp -a /debian . ; }

dch -M -v ${version}-1 -D $(sed -n '/DISTRIB_CODENAME/ { s/.*=//;p;;}' /etc/lsb-release) "new update"

gpgconf --kill gpg-agent && gpg-agent --pinentry-program /usr/bin/pinentry-curses --verbose --daemon
debuild -S --force-sign -k${GPG_KEY}

cd ..

dput ppa:${PPATARGET} *source.changes
5 changes: 5 additions & 0 deletions tekton/debbuild/control/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tektoncd-cli (0.5.1-1) stable; urgency=medium

* Initial release.

-- Chmouel Boudjnah <[email protected]> Tue, 10 Dec 2019 16:54:58 +0000
1 change: 1 addition & 0 deletions tekton/debbuild/control/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
16 changes: 16 additions & 0 deletions tekton/debbuild/control/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: tektoncd-cli
Maintainer: Chmouel Boudjnah <[email protected]>
Section: misc
Priority: optional
Standards-Version: 4.3.0
Build-Depends: debhelper (>= 11),
dh-golang (>= 1.34~),
golang-any (>= 2:1.12~),
bash-completion
Vcs-Git: https://github.com/tektoncd/cli.git

Package: tektoncd-cli
Architecture: any
Depends: ${misc:Depends}
Description: A command line interface for interacting with Tekton
The Tekton Pipelines CLI project a user friendly CLI for interacting with Tekton !
29 changes: 29 additions & 0 deletions tekton/debbuild/control/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/make -f

TKN := obj-$(DEB_HOST_GNU_TYPE)/bin/tkn

DATE_FMT = %Y-%m-%dT%H:%M:%S%z
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
else
BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
endif
BUILD_DATE := $(BUILD_DATE:+0000=Z)

%:
dh $@

override_dh_auto_build:
export XDG_CACHE_HOME=/tmp/cache ; \
test -e ./VERSION && VERSION=`cat VERSION` || VERSION=$(BUILD_DATE) ; \
go build -mod=vendor -v -o ${TKN} -ldflags "-X github.com/tektoncd/cli/pkg/cmd/version.clientVersion=$$VERSION" ./cmd/tkn
$(TKN) version
$(TKN) completion zsh > debian/tkn.zsh-completion
$(TKN) completion bash > debian/tektoncd-cli.bash-completion

override_dh_auto_test:

override_dh_auto_install:
dh_auto_install -O--buildsystem=golang
dh_bash-completion -O--buildsystem=golang
install -D -m644 debian/tkn.zsh-completion debian/tektoncd-cli/usr/share/zsh/vendor-completions/_zsh
1 change: 1 addition & 0 deletions tekton/debbuild/control/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
30 changes: 30 additions & 0 deletions tekton/debbuild/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -eux

# Uploading to tektoncd/cli ppa :
# https://launchpad.net/~tektoncd/+archive/ubuntu/cli
# You need to join this team to be able to upload there
# and have your gpg setup in your profile
PPATARGET=tektoncd/cli
GPG_KEY=${GPG_KEY}

[[ -n ${GPG_KEY} ]] || {
echo "You need to setup your GPG_KEY"
exit 1
}


gpg --list-secret-keys >/dev/null || { echo "You need to have a secret GPG key"; exit 1 ;}

cd container
docker build -t ubuntu-build-deb .

cd ..
fpath=$(readlink -f control)
docker run --rm \
-v ~/.gnupg:/root/.gnupg \
-v ${fpath}:/debian --name ubuntu-build-deb \
--env PPATARGET=${PPATARGET} \
--env GPG_KEY=${GPG_KEY} \
-it ubuntu-build-deb \
/run.sh