Git Product home page Git Product logo

go-bin-deb's Introduction

go-bin-deb

travis Status Go Report Card GoDoc MIT License

Package go-bin-deb creates binary package for debian system

Using a json files to declare rules, it then performs necessary operations to invoke dpkg-deb to build a package, then check it with the help of lintian.

This tool is part of the go-github-release workflow

See the demo.

TOC

Install

Check the release page!

Go

go install github.com/mh-cbon/go-bin-deb@latest

Requirements

A debian system, vagrant, travis, docker, whatever.

Usage

Workflow overview

To create a binary package you need to

  • build your application binaries
  • invoke go-bin-deb to generate the package
  • create deb repositories on travis hosted on gh-pages using this script

JSON file

For a reference of all fields, see this

For a real world example including service, shortcuts, env, see this

For a casual example to provide a simple binary, see this

JSON tokens

Several tokens are provided to consume into the JSON file.

name description example
!version! The version number provided in the command line, or in the JSON file. 1.0.2
!arch! The architecture short name provided in the command line or in the JSON file. amd64
!name! The name of the project provided in the JSON file. hello

CLI

go-bin-deb -help

NAME:
   go-bin-deb - Generate a binary debian package

USAGE:
   go-bin-deb <cmd> <options>
   
VERSION:
   0.0.0
   
COMMANDS:
     generate  Generate the contents of the package
     test      Test the package json file
     help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

generate

go-bin-deb generate -help

NAME:
   go-bin-deb generate - Generate the contents of the package

USAGE:
   go-bin-deb generate [command options] [arguments...]

OPTIONS:
   --wd value, -w value      Working directory to prepare the package (default: "pkg-build")
   --output value, -o value  Output directory for the debian package files
   --file value, -f value    Path to the deb.json file (default: "deb.json")
   --version value           Version of the package
   --arch value, -a value    Arch of the package

test

go-bin-deb test -help

NAME:
   go-bin-deb test - Test the package json file

USAGE:
   go-bin-deb test [command options] [arguments...]

OPTIONS:
   --file value, -f value  Path to the deb.json file (default: "deb.json")

Recipes

Installing generated package

TLDR

# install a package with dependencies
dpkg -i mypackage.deb
apt-get install --fix-missing
# or
gdebi mypackage.deb

On debian system to install a package .deb file, you should use dpkg -i and not apt-get i.

But, dpkg does not install dependencies by itself, thus you will need to execute an extra command apt-get i --fix-missing to locate and install missing dependencies ater you installed your own .deb.

An alternative is to use gdebi, which appears to be bale to all of that in one command.

Finally, if one provides a web interface to host the package, it should be no problem to use a regular apt-get.

PS: To remove the package dpkg -r.

Vagrant recipe

Please check the demo app here

Travis recipe

  • get a github repo
  • create a token in your settings
  • get a travis account
  • connect your github account to travis and register your repo
  • install travis client gem install --user travis
  • run travis encrypt --add -r your/repo GH_TOKEN=xxxx
  • run travis setup releases
  • personalize the .travis.yml
sudo: required

services:
  - docker

language: go
go:
  - tip

env:
  global:
    - MYAPP=dummy
    - [email protected]
    - secure: GH_TOKEN xxxx

before_install:
  - sudo apt-get -qq update
  - mkdir -p ${GOPATH}/bin

install:
  - cd $GOPATH/src/github.com/YOUR_USERNAME/$MYAPP
  - go install

script: echo "pass"

# build the app, build the package
before_deploy:
  - mkdir -p build/{386,amd64}
  - GOOS=linux GOARCH=386 go build --ldflags "-X main.VERSION=${TRAVIS_TAG}" -o build/386/$MYAPP main.go
  - GOOS=linux GOARCH=amd64 go build --ldflags "-X main.VERSION=${TRAVIS_TAG}" -o build/amd64/$MYAPP main.go
  - curl -L https://raw.githubusercontent.com/mh-cbon/go-bin-deb/master/create-pkg.sh | GH=YOUR_USERNAME/$MYAPP sh -xe

# build the package repo on gh-pages
after_deploy:
  - curl -L https://raw.githubusercontent.com/mh-cbon/go-bin-deb/master/setup-repository.sh | GH=YOUR_USERNAME/$MYAPP EMAIL=$MYEMAIL sh -xe

# deploy package files into gh releases
deploy:
  provider: releases
  api_key:
    secure: GH_TOKEN xxxx
  file_glob: true
  file:
    - $MYAPP-386.deb
    - $MYAPP-amd64.deb
  skip_cleanup: true
  on:
    tags: true

useful deb commands

# Install required dependencies to build a package
sudo apt-get install build-essential lintian -y
# build a bin package
dpkg-deb --build debian hello.deb
# show info of a package
dpkg-deb --show hello.deb
# list contents of a package
dpkg-deb --contents hello.deb

Release the project

gump patch -d # check
gump patch # bump

History

CHANGELOG

go-bin-deb's People

Contributors

mh-cbon avatar uzuna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.