subgraph / subgraph-os-issues

Subgraph OS issues repository
73 stars 10 forks source link

Documenting steps to create a new Debian package #282

Open kibal opened 6 years ago

kibal commented 6 years ago

SubgraphOS uses git-buildpackage in subgraph/subgraph-debian-packages to build all Debian packages. All SubgraphOS software is developed with git using the master branch for upstream development and with git-buildpackage overlay style packages in the debian branch. The debian branch contains at least two files in the root: .travis.yml for Continuous Integration by the Travis CI service and a directory named debian that is automatically merged into master by git-buildpackage.

To build an already existing SubgraphOS package we encourage you to use the documented methods in the subgraph/subgraph-debian-packages repository. To build even a single package - we recommend the use of subgraph/subgraph-debian-packages to prepare a cowbuilder chroot for use with git-buildpackage. We encourage the use of a dedicated user for initiation of the build on a freshly installed Debian stable (stretch) system or by using a SubgraphOS install. When using SubgraphOS, take note that some packages such as subgraph/onioncfg may require PaX exceptions set by subgraph/paxrat for their dependencies, to build, or to run the resulting binary.

To build a fresh checkout of a package by hand after the cowbuilder chroot has been initialized by the subgraph-debian-packages setup.sh script:

git clone https://www.github.com/subgraph/onioncfg
cd onioncfg
git checkout debian
ARCH=amd64 DIST=testing gbp buildpackage -us -uc 

The same process is also automated with subgraph/subgraph-debian-packages by using the build-package.sh script:

# Please read the documentation in https://www.subgraph/subgraph-debian-packages
git clone https://www.subgraph/subgraph-debian-packages
cd subgraph-debian-packages
./setup.sh # Create the cowbuilder chroot
./fetch-src.sh # Download source code for all relevant packages
./build-package.sh onioncfg # Build a specific package

The build artifacts will be located in /tmp/build_area/ after build completion.

It is possible to use dh-make-golang to package golang software, however we do not currently package SubgraphOS software with a similar git branch naming style. It may still be useful to use dh-make-golang to generate a debian directory for a project. We also provide a sample golang debian directory as an example in subgraph/subgraph-debian-packages.

Create a new package for an already existing SubgraphOS repository for a golang project with the following example:

NEWPACKAGE=your-new-package-name
git clone https://www.github.com/subgraph/subgraph-debian-packages
git clone https://www.github.com/subgraph/$NEWPACKAGE
cd $NEWPACKAGE
git checkout --orphan debian
# remove all files in the repository
git rm *
# add sample configuration files
cp ../subgraph-debian-packages/examples/travis.yml-sample .travis.yml
cp -arv ../subgraph-debian-packages/examples/debian-golang debian
sed -i "s/PACKAGE_NAME/$NEWPACKAGE/g" debian/*
dch --create --package $NEWPACKAGE
git add .travis.yml debian
git commit -m 'initial packaging'
# Test building of the new package by tagging master with v0.0.1:
git checkout master
git tag v0.0.1
git checkout debian
ARCH=amd64 DIST=testing gbp buildpackage -us -uc
git push orgin

Important note for golang packages: the build may break if there are GOBIN/GOROOT or other golang environment variables set when gbp is invoked. The build artifacts will be located in /tmp/build_area/ after build completion.

DarkCoridor commented 6 years ago

Hi @kibal by following the instructions in the README and doing the following:

git clone https://github.com/subgraph/subgraph-debian-packages
cd subgraph-design-packages
./setup.sh
./fetch-src.sh
./build-package.sh oz

I was able to successfully build /tmp/build-area/oz-daemon_0.2.4-1_amd64.deb

However, I was unable to install the oz-dameon package but will open a more specific issue for that.

dma commented 6 years ago

This useful information should go somewhere more easily findable than in our issues repo.