Skip to content
forked from gofed/gofed

Pack of tools to generate spec file, automate builds, updates, dependency check and other handy task around packaging and keeping the ecosystem in a good shape.

License

Notifications You must be signed in to change notification settings

nullr0ute/gofed

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Gofed is a set of tools that automates the packaging process of golang development source codes.

Supported features:

  • a spec file generator for the github.com, code.google.com, and bitbucket.org repositories
  • preparation of the Fedora's Review Request for a new golang package
  • golang imports discovering (dependency on other imports or packages)
  • comparison of APIs (exported symbols) of two golang projects
  • scan of available golang packages, construction of dependency graphs of packages
  • other useful commands (parallel push, pull or update of all chosen branches, ...)

Installation

The repository provides a spec file for Fedora. The package can be build as:

$ wget https://github.com/ingvagabund/GolangPackageGenerator/archive/<commit>/gpg-<shortcommit>.tar.gz
$ cp gpg-<shortcommit>.tar.gz /home/<user>/rpmbuild/SOURCES/.
$ rpmbuild -ba *.spec
$ rpm -Uvh <built rpm>.rpm

Launching

To generate a spec file for the github https://github.com/stretchr/respond repository, run the following command:

$ gofed github2spec -p stretchr -r respond --commit fb9c7353c67cdeccb10af1320b978c5a1e401e9b -f

Output:

Repo URL:
https://github.com/stretchr/respond

(1/4) Checking if the package already exists in PkgDB
(2/4) Creating spec file
(3/4) Downloading tarball
(4/4) Discovering golang dependencies
Class: github.com/stretchr/testify (golang-github-stretchr-testify) PkgDB=True

Spec file golang-github-stretchr-respond.spec at:
/tmp/test/golang-github-stretchr-respond/fedora/golang-github-stretchr-respond

At the beginning, golang checks the Fedora repository if the package already exists. If not, it creates a spec file (needs to be filled for missing data), downloads the tarball, and lists all dependencies (classes of imports decomposed by a repository - common import path prefix).

Dependency discovering

To discover imports and dependencies of packages in the https://github.com/rackspace/gophercloud repository, run the following command on the repository's tarball:

$ gofed ggi -c -s -d

Output:

Class: github.com/mitchellh/mapstructure (golang-github-mitchellh-mapstructure) PkgDB=True
Class: github.com/racker/perigee (golang-github-racker-perigee) PkgDB=True
Class: github.com/rackspace/gophercloud (golang-github-rackspace-gophercloud) PkgDB=True
Class: github.com/tonnerre/golang-pretty (golang-github-tonnerre-golang-pretty) PkgDB=True

When running with the -d option, gofed checks if the dependency is already packaged in the PkgDB database.

Check of up2date dependencies in Fedora

To check if all dependencies of a package are up-to-date in Fedora (for example kubernetes), run the following command on the package's Godeps.json file:

$ gofed check-deps Godeps.json

Output:

package golang-github-davecgh-go-spew outdated
package golang-github-onsi-gomega outdated
package golang-github-onsi-ginkgo outdated
package golang-github-ghodss-yaml outdated
package golang-github-spf13-pflag outdated

When running with the -v option, gofed displays status of all dependencies. When running with the -l option, gofed does not perform git|hg pull on each repository.

Check devel builds of all golang packages

To create a local database of exported symbols, provided import paths, and imported paths each development build, run:

$ gofed scan-imports -c

This command downloads every build providing source codes. Each build is parsed and exported symbols are extracted. Every golang project consists of a package. Every package in a project is defined by its path and by a set of symbols that developer can use. Once the scan is finished, all symbols are locally saved in XML files. These files can be further analyzed. Extracted information can be queried for used or provided import paths. The command also constructs a dependency graph for a given package. Implicitly, only outdated packages are scanned so once the database is created, there is no need to regenerate it for all packages every time.

Golang dependency graph

To display a dependency graph for a package, for example docker-io, run:

$ gofed scan-deps -g -o docker.png docker-io

This command generates a PNG picture, in this case named docker.png, with the dependency graph.

docker-io dependencies

Golang project decomposition

To display a decomposition of a project into a dependency graph, for example prometheus, run the following command in project's directory:

$ gofed scan-deps -d github.com/prometheus/prometheus --from-dir . --skip-errors -g -o prometheus.png

This command generates a PNG picture, in this case named prometheus.png, with the dependency graph.

prometheus decomposition

API check

To see differences in exported symbols between two releases, commits, or versions of the same project, use the "gofed apidiff" command in the following format:

$ gofed apidiff <DIR1> <DIR2>

For example, to check API of etcd between etcd-2.0.3 and etcd-2.0.4 versions (untared tarballs), run:

$ gofed apidiff etcd-2.0.3 etcd-2.0.4

Output

Package: etcdserver
   -GetClusterFromPeers func removed
Package: etcdserver/etcdhttp
   -function NewPeerHandler: parameter count changed: 2 -> 3

To get new symbols and other information, use the -a option:

Package: etcdserver
   struct Cluster has different number of fields
   struct Cluster: fields are reordered
   +struct Cluster: new field 'index'
   +GetClusterFromRemotePeers func added
   +UpdateIndex func added
   -GetClusterFromPeers func removed
Package: etcdserver/etcdhttp
   -function NewPeerHandler: parameter count changed: 2 -> 3
Package: pkg/wait
   +WaitTime type added
   +NewTimeList func added
   +Wait func added
Package: wal
   +WALv2_0Proxy variable/constant added

Lines starting with the minus symbol ("-") are breaking backward compatibility. Lines starting with the plus symbol ("+") are new. Other lines reports other issues.

About

Pack of tools to generate spec file, automate builds, updates, dependency check and other handy task around packaging and keeping the ecosystem in a good shape.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 84.5%
  • Go 12.9%
  • Shell 2.6%