Skip to content

Commit

Permalink
docs: Add episode about update of golang packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ingvagabund committed Aug 14, 2015
1 parent af41c62 commit 5940cf9
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ABOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It supports the following features:

First episode of this story will show you how to package your first golang
project. It will show and explain important lines of spec line, concentrate
on macros, list pro BuildRequires and Requires, list of Provides.
on macros, list of BuildRequires and Requires, list of Provides.

#### Where to get gofed

Expand Down Expand Up @@ -62,7 +62,7 @@ If I will talk about Fedora package, word 'package' will be used.
Golang project consists of source code units called packages. In this
context, word 'golang package' will be used. The same holds for word 'project'.
If I will talk about github project, I will used word 'github project' if
is it not clear from context. Otherwise 'project' will mean golang project.
it is not clear from the context. Otherwise 'project' will mean golang project.

#### Generate you first spec file

Expand All @@ -73,7 +73,7 @@ Gofed provides 3 generators:

All generators can be accessed via 'gofed repo2spec' command. If you know
provider, project and repository in advance, specific generators are your
choise. E.g. for github.com/kr/pretty run:
choice. E.g. for github.com/kr/pretty run:

```vim
gofed github2spec --project kr --repo pretty
Expand Down Expand Up @@ -178,7 +178,7 @@ BuildRequires: golang
%endif
```

This is not the smallest and clearest way how to do it. However, it is clear
This is not the smallest and the clearest way how to do it. However, it is clear
what you get. Macro go_arches defines a list of all architectures that are
supported by both golang and gcc-go compiler. If the macro is not defined
explicit list of architectures for golang is used. The macro is not defined
Expand Down Expand Up @@ -209,7 +209,7 @@ that are imported (by import keyword) and those that are provided
(defined by the project). For Fedora package imported packages translate into
build-time and run-time dependencies and provided packages into a list of
Provides. In the form the spec file is generated, all build-time dependencies
are wrapper with 'with_check' macro. Since it make sense to BuildRequire
are wrapped with 'with_check' macro. Since it make sense to BuildRequire
golang packages only where you run some tests on the project. Run-time
dependencies are needed everytime you install the devel subpackage

Expand Down Expand Up @@ -276,9 +276,9 @@ for unit-test subpackage.
Another reason to have unit-test subpackage is a support for CI. As some tests
need internet connection, specific configuration or services running, those
tests can not be run during building. In CI, unit-test subpackage can be run
in defined environment which support exactly those resources that are needed.
in well defined environment which support exactly those resources that are needed.

As tests are run on various architecture you need to choose golang or gcc-go.
As tests are run on various architectures you need to choose golang or gcc-go.
Thus the subpackage is architecture specific. And as tests in %check section
are run only on tests provided by unit-test subpackage, 'if go_arches' and
'ifarch gccgo_arches' are under %package unit-test again.
Expand Down
120 changes: 120 additions & 0 deletions UPDATE_ANALYSIS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
## UPDATES AND ANALYSIS OF GOLANG SOURCE CODES

The second episode of the series will show you how to:
- update golang project packaged in Fedora
- analyse source codes and get list of provided and imported packages
- get a list of unit-test files

### Update of spec files

In the previous episode I showed you how to generated spec file for a given
golang project. Here, I will show you how to update packaged project with
new tarball, how to update a list of provided and imported packages and how
to update a list of unit-test files. Among others, 'gofed lint' command will
be introduced.

Every fedora package has a root directory. It is the one you cd in once you
clone its repository. For example, for golang-github-onsi-ginkgo:

```vim
$ fedpkg clone golang-github-onsi-ginkgo
$ cd golang-github-onsi-ginkgo
$ ls
golang-github-onsi-ginkgo.spec sources
```

It contains spec file and sources file. If you run 'fedpkg prep', tarball
with source codes is downloaded as well.

Gofed provides 'gofed bump' command which allows you to automatically
download tarball of the latest commit (or the one specified via --commit
option) of a given golang project and update spec file.
The command does not update a list of provided and imported packages
nor a list of unit-tests. At the moment 'gofed bump' supports only github.com
and bitbucket.org providers.

List of provided/imported packages and unit-test has to be updated manually.
Gofed provides 'gofed inspect' and 'gofed ggi' for this case. Running the
command with --spec option will generate an output in a spec file format.

Once you run 'gofed bump' command you can run 'gofed lint' to check which
provided/required/buildrequired packages are missing or superfluous. Both
commands have to be run in a package root directory, 'gofed lint' needs a
tarball in addition to spec file and sources file.

```
$ cd golang-github-onsi-ginkgo
$ git checkout master
$ ls
ginkgo-462326b.tar.gz golang-github-onsi-ginkgo.spec sources
$ gofed bump
Searching for spec file
Reading macros from golang-github-onsi-ginkgo.spec
Getting the latest commit from github.com/onsi/ginkgo
Tags: v1.2.0-beta, v1.2.0, v1.1.1, v1.1.0, v1.0.0
Releases:
Downloading tarball
Updating spec file
Bumping spec file
$ git diff
diff --git a/golang-github-onsi-ginkgo.spec b/golang-github-onsi-ginkgo.spec
index 6a3d878..62b93b2 100644
--- a/golang-github-onsi-ginkgo.spec
+++ b/golang-github-onsi-ginkgo.spec
@@ -2,7 +2,7 @@
%global provider_tld com
%global project onsi
%global repo ginkgo
-%global commit 462326b1628e124b23f42e87a8f2750e3c4e2d24
+%global commit d94e2f4000332f62b356ecb2840c98f4218f5358
# https://github.com/onsi/ginkgo
%global import_path %{provider}.%{provider_tld}/%{project}/%{repo}
%global shortcommit %(c=%{commit}; echo ${c:0:7})
@@ -10,7 +10,7 @@
Name: golang-%{provider}-%{project}-%{repo}
Version: 1.1.0
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: A Golang BDD Testing Framework
License: MIT
URL: http://%{import_path}
@@ -77,6 +77,9 @@ cp -pav {config,ginkgo,integration,internal,reporters,types} %{buildroot}
%{gopath}/src/%{import_path}
%changelog
+* Fri Aug 14 2015 jchaloup <[email protected]> - 1.1.0-4
+- Bump to upstream d94e2f4000332f62b356ecb2840c98f4218f5358
+
* Wed Jun 17 2015 Fedora Release Engineering <[email protected]> - 1.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
$ gofed lint -a ginkgo-d94e2f4.tar
...
W: Missing BuildRequires: golang(github.com/onsi/B)
W: Missing BuildRequires: golang(github.com/onsi/C)
W: Missing BuildRequires: golang(github.com/onsi/gomega/gbytes)
...
1 golang specfile checked; 1 errors, 23 warnings.
$ fedpkg prep
$ cd ginkgo-d94e2f4000332f62b356ecb2840c98f4218f5358
$ # get a list of all provided packages in a spec file format
$ gofed inspect -p --spec
Provides: golang(%{import_path}) = %{version}-%{release}
Provides: golang(%{import_path}/config) = %{version}-%{release}
Provides: golang(%{import_path}/ginkgo/convert) = %{version}-%{release}
Provides: golang(%{import_path}/ginkgo/interrupthandler) = %{version}-%{release}
...
$ # get a list of all imported packages in a spec file format
$ gofed ggi --spec
BuildRequires: golang(github.com/onsi/B)
BuildRequires: golang(github.com/onsi/C)
BuildRequires: golang(github.com/onsi/ginkgo)
BuildRequires: golang(github.com/onsi/ginkgo/config)
...
$ # get a list of all unit-tests
$ $ gofed inspect -t --spec
go test %{import_path}/ginkgo/nodot
go test %{import_path}/ginkgo/testsuite
go test %{import_path}/integration
...
```

0 comments on commit 5940cf9

Please sign in to comment.