Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simple debian package building and management

License

NotificationsYou must be signed in to change notification settings

penguinpowernz/go-ian

Repository files navigation

Simple debian package building and management named in memory of the late Ian Murdock, founder of the Debian project.

The purpose of this tool is to decrease the overhead in maintaining a debian package storedin a git repository. It tries to mimic the CLI of other popular tools such as git and bundler.It is intended to be helpful when integrating other build tools/systems and with CI/CD.

It has been ported to golang from theruby project of the same name.

You can download binaries and Debian packages from thereleases page.

Requirements

I shell out a bit to save time, will eventually make things more native. For now, need the following tools:

  • dpkg-deb
  • fakeroot
  • rsync

This should do it.

sudo apt-get install fakeroot dpkg-dev rsync coreutils findutils

Installation

Simple to build / install, provided you have go setup:

go get github.com/penguinpowernz/go-iango install github.com/penguinpowernz/go-ian/cmd/ian

Or you can download a pre-built binary or Debian package fromthe releases page.

Usage

This tool is used for working with what Debian called "Binary packages" - that is ones that have theDEBIANfolder in capitals to slap Debian packages together quickly. It uses dpkg-deb -b in the background which mostDebian package maintainers frown at but it is suitable enough for rolling your own packages quickly, and itscratches an itch.

Creation/Initializing

ian new my-package

Analogous tobundle new gemname orrails new appname this will create a folder calledmy-package in thecurrent folder and initialize it with the appropriate debian files.

ian init

Analagous togit init this will do the same asnew but do it in the current folder.

Now you will see you have aDEBIAN folder with acontrol andpostinst file.

Info

ian info

This will simply dump the control file contents out.

Set fields in the control file

The architecture and the version can be set quickly in this manner. Other fields are not (yet) supported.

ian set -a amd64ian set -v 1.2.3-test

You can also use increments on semantic versions like so:

ian set -v +M    # increment the Major numberian set -v +m    # increment the minor numberian set -v +p    # increment patch level

Packaging

ian pkg [-b]

The one you came here for. Packages the repo in a debian package, excluding junk files like.git and.gitignore,moves root files (likeREADME.md) to a/usr/share/doc folder so you don't dirty your root partition on install.
The package will be output to apkg directory in the root of the repo. It will also generate the md5sums fileand calculate the package size proir to packaging. By adding a-b flag it will run the build script beforepackaging.

Build

ian build

This will run the build script found inDEBIAN/build parsing it the following arguments:

  • root directory of the package git repository
  • architecture from the control file
  • version from the control file

It can do whatever things you need it to do to prepare for the packaging such as building binaries, etc.

Push

ian push [target]

Setup scripts to run in a file called.ianpush in the repo root and runningian push will run all the lines inthe file as commands with the current package. The package filename will be appended to each command unless$PKGis found on the line, in which case that will be replaced with the package filename. Also the target name can begiven as an argument to push to specfic targets (supports globbing).

package_cloud push user/app-testing/debian/wheezystable: package_cloud push user/app-stable/debian/wheezydevbox: scp $PKG root@192.168.1.200:~s3: aws s3 cp $PKG s3://mybucket/dpkg/

Note that targets requiring input will fail as there is no terminal attached to the command. For SCP, it is recommendedto use the SSH config files to your advantage.

Other

Some other commands:

ian install     # installs the current packageian excludes    # shows the excluded filesian size        # calculates the package size (in kB)ian -v          # prints the ian versionian version     # prints the package versionian versions    # prints all known versionsian deps        # prints the dependencies line by linebpi             # run build, pkg, installpi              # run pkg, installpp [target]     # run pkg, pushbp              # run build, pkgbpp [target]    # run build, pkg push

You can also use the envvarIAN_DIR in the same way that you would useGIT_DIR - that is, to do stuffwith ian but from a different folder location.

UseDEBUG=1 ian pkg to show debug logs for ian commands.

Library Usage

GoDoc

The Debian packageControl struct could come in handy for others. As a quick overview here's what it can do:

  • Parse([]byte) (Control, error) - parse the bytes from the control file
  • Read(string) (Control, error) - read the given file and parse it's contents
  • Default() (Control) - a default package control file
  • ctrl.Filename() string - the almost Debian standard filename (missing distro name)
  • ctrl.String() string - render the control file as a string
  • ctrl.WriteFile(string) error - write the string into the given filename

Plus the exported fields on theControl struct that mirror the dpkg field names.

For more information please check the godocs.

Dogfooding

The debian package source for Ian is actually managed by Ian in the folderdpkg. So you can build the debianpackage for ian, using ian. Give it a try!

go get github.com/penguinpowernz/go-iango install github.com/penguinpowernz/go-ian/cmd/iancd $GOPATH/src/github.com/penguinpowernz/go-ian/dpkgian buildian pkgsudo $GOBIN/ian install # or sudo dpkg -i pkg/ian_v1.0.0_amd64.deb

TODO

  • more tests
  • add help page
  • add subcommands help
  • releasing
  • pushing
  • test pushing
  • ignore file
  • allow specifying where to output the package to after building
  • deps management
  • running of a build script
  • install after packaging
  • package a specific version
  • optional semver enforcement
  • utilize rules file
  • support copyright file
  • support changelog
  • don't shell out for md5sums
  • don't shell out for rsync
  • don't shell out for find
  • don't shell out for dpkg-deb
  • pull maintainer from git config

Contributor Code of Conduct

This project adheres to No Code of Conduct. We are all adults. We accept anyone's contributions. Nothing else matters.

For more information please visit theNo Code of Conduct homepage.

Contributing

Bug reports and pull requests are welcome on GitHub athttps://github.com/penguinpowernz/ian.

In Memory Of

In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.


[8]ページ先頭

©2009-2025 Movatter.jp