Commit 72d6adcb authored by Lars Kellogg-Stedman's avatar Lars Kellogg-Stedman Committed by Scott Moser

Update build tools to work with git

- Update HACKING.rst to include git instructions
- update MANIFEST.in and .gitignore to ignore git-related things
- replaced tarball generation scripts with git-based script
- have the spec files correctly identify themselves as cheetah templates
- make brpm work with git
parent eed7fccd
build
cloud_init.egg-info
dist
*.pyc
__pycache__
.tox
......@@ -2,47 +2,71 @@
Hacking on cloud-init
=====================
To get changes into cloud-init, the process to follow is:
This document describes how to contribute changes to cloud-init.
Do these things once
--------------------
* If you have not already, be sure to sign the CCA:
- `Canonical Contributor Agreement`_
* Get your changes into a local bzr branch.
Initialize a repo, and checkout trunk (init repo is to share bzr info across multiple checkouts, its different than git):
* Clone the `LaunchPad`_ repository:
git clone YOUR_USERNAME@git.launchpad.net:cloud-init
cd cloud-init
If you would prefer a bzr style `git clone lp:cloud-init`, see
the `Instructions on LaunchPad`_ for more information.
- ``bzr init-repo cloud-init``
- ``bzr branch lp:cloud-init trunk.dist``
- ``bzr branch trunk.dist my-topic-branch``
* Create a new remote pointing to your personal LaunchPad
repository::
git remote add YOUR_USERNAME YOUR_USERNAME@git.launchpad.net:~YOUR_USERNAME/cloud-init
.. _Canonical Contributor Agreement: http://www.canonical.com/contributors
* Commit your changes (note, you can make multiple commits, fixes, more commits.):
Do these things for each feature or bug
---------------------------------------
- ``bzr commit``
* Create a new topic branch for your work::
* Check pep8 and test, and address any issues:
git checkout -b my-topic-branch
- ``make test pep8``
.. _Instructions on launchpad: https://help.launchpad.net/Code/Git
* Push to launchpad to a personal branch:
* Make and commit your changes (note, you can make multiple commits,
fixes, more commits.)::
- ``bzr push lp:~<YOUR_USERNAME>/cloud-init/<BRANCH_NAME>``
git commit
* Propose that for a merge into lp:cloud-init via web browser.
* Check pep8 and test, and address any issues::
- Open the branch in `Launchpad`_
make test pep8
- It will typically be at ``https://code.launchpad.net/<YOUR_USERNAME>/<PROJECT>/<BRANCH_NAME>``
- ie. https://code.launchpad.net/~smoser/cloud-init/mybranch
* Push your changes to your personal LaunchPad repository::
* Click 'Propose for merging'
* Select 'lp:cloud-init' as the target branch
git push -u YOUR_USERNAME my-topic-branch
Then, someone on cloud-init-dev (currently `Scott Moser`_ and `Joshua Harlow`_) will
review your changes and follow up in the merge request.
* Use your browser to create a merge request:
Feel free to ping and/or join #cloud-init on freenode (irc) if you have any questions.
- Open the branch on `LaunchPad`_
- It will typically be at
``https://code.launchpad.net/~YOUR_USERNAME/cloud-init/+git/cloud-init/+ref/BRANCHNAME``
for example
https://code.launchpad.net/~larsks/cloud-init/+git/cloud-init/+ref/feature/move-to-git
- Click 'Propose for merging`
- Select ``cloud-init`` as the target repository
- Select ``master`` as the target reference path
Then, someone on cloud-init-dev (currently `Scott Moser`_ and `Joshua
Harlow`_) will review your changes and follow up in the merge request.
Feel free to ping and/or join ``#cloud-init`` on freenode (irc) if you
have any questions.
.. _Launchpad: https://launchpad.net
.. _Canonical Contributor Agreement: http://www.canonical.com/contributors
.. _Scott Moser: https://launchpad.net/~smoser
.. _Joshua Harlow: https://launchpad.net/~harlowja
......@@ -4,5 +4,7 @@ graft tools
prune build
prune dist
prune .tox
prune .git
prune .bzr
exclude .gitignore
exclude .bzrignore
......@@ -180,13 +180,10 @@ def main():
with util.tempdir() as tdir:
cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
# output like 0.7.6-1022-g36e92d3
cmd = ['git', 'describe', '--long']
(sysout, _stderr) = util.subp(cmd)
version = sysout.strip()
cmd = ['bzr', 'revno']
(sysout, _stderr) = util.subp(cmd)
revno = sysout.strip()
version, extra = sysout.strip().split("-", 1)
# This is really only a temporary archive
# since we will extract it then add in the debian
......@@ -212,12 +209,12 @@ def main():
append_requires=['cloud-utils | cloud-guest-utils']
else:
append_requires=[]
write_debian_folder(xdir, version, revno, pkgmap,
write_debian_folder(xdir, version, extra, pkgmap,
pyver=pyver, append_requires=append_requires)
# The naming here seems to follow some debian standard
# so it will whine if it is changed...
tar_fn = "cloud-init_%s~bzr%s.orig.tar.gz" % (version, revno)
tar_fn = "cloud-init_%s+%s~bddeb.orig.tar.gz" % (version, extra)
print("Archiving the adjusted source into %r" %
(util.abs_join(tdir, tar_fn)))
cmd = ['tar', '-czvf',
......
This diff is collapsed.
## template:basic
cloud-init (${version}~bzr${revision}-1) UNRELEASED; urgency=low
cloud-init (${version}+${revision}~bddeb-1) UNRELEASED; urgency=low
* build
......
## This is a cheetah template
## template: cheetah
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
# See: http://www.zarb.org/~jasonc/macros.php
# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
#for $d in $defines
%define ${d}
#end for
Name: cloud-init
Version: ${version}
Release: ${release}${subrelease}%{?dist}
Release: 1${subrelease}%{?dist}
Summary: Cloud instance init scripts
Group: System Environment/Base
......@@ -22,9 +18,9 @@ Source0: ${archive_name}
BuildArch: noarch
BuildRoot: %{_tmppath}
BuildRequires: python-devel
BuildRequires: python-setuptools
BuildRequires: python-cheetah
BuildRequires: python-devel
BuildRequires: python-setuptools
BuildRequires: python-cheetah
# System util packages needed
Requires: shadow-utils
......@@ -68,7 +64,7 @@ need special scripts to run during initialization to retrieve and install
ssh keys and to let the user run various scripts.
%prep
%setup -q -n %{name}-%{version}~${release}
%setup -q -n ${source_name}
# Custom patches activation
#set $size = 0
......@@ -198,7 +194,3 @@ fi
# Python code is here...
%{python_sitelib}/*
%changelog
${changelog}
## This is a cheetah template
## template: cheetah
# See: http://www.zarb.org/~jasonc/macros.php
# Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
#for $d in $defines
%define ${d}
#end for
Name: cloud-init
Version: ${version}
Release: ${release}${subrelease}%{?dist}
Release: 1${subrelease}%{?dist}
Summary: Cloud instance init scripts
Group: System/Management
......@@ -63,7 +59,7 @@ need special scripts to run during initialization to retrieve and install
ssh keys and to let the user run various scripts.
%prep
%setup -q -n %{name}-%{version}~${release}
%setup -q -n ${source_name}
# Custom patches activation
#set $size = 0
......@@ -157,7 +153,3 @@ mkdir -p %{buildroot}/var/lib/cloud
%{python_sitelib}/*
/var/lib/cloud
%changelog
${changelog}
#!/bin/sh
Usage() {
cat <<EOF
Usage: ${0##*/} version
make a tarball of 'version'
must be in a bzr directory, and 'version' must be a tag
EOF
}
topdir="$PWD"
tag="$1"
[ -n "$tag" ] || { Usage 1>&2 ; exit 1; }
out="${topdir}/cloud-init-${tag}.tar.gz"
bzr export --format=tgz --root="cloud-init-$tag" \
"--revision=tag:${tag}" "$out" "$topdir" &&
echo "Wrote ${out}"
#!/bin/sh
set -e
find_root() {
local topd
if [ -z "${CLOUD_INIT_TOP_D}" ]; then
topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
else
topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
fi
[ $? -eq 0 -a -f "${topd}/setup.py" ] || return
ROOT_DIR="$topd"
}
rev=${1:-HEAD}
revname=$(git describe $rev)
if ! find_root; then
echo "Unable to locate 'setup.py' file that should" \
"exist in the cloud-init root directory." 1>&2
exit 1;
fi
REVNO=$(bzr revno "$ROOT_DIR")
# revname could be 0.7.5 or 0.7.5-NNN-gHASH
# turn that into 0.7.5 or 0.7.5+NNN.gHASH
case "$revname" in
*-*) revname=$(echo "$revname" | sed -e 's/-/+/' -e 's/-/./')
esac
if [ ! -z "$1" ]; then
ARCHIVE_FN="$1"
else
VERSION=$("$ROOT_DIR/tools/read-version")
ARCHIVE_FN="$PWD/cloud-init-$VERSION~bzr$REVNO.tar.gz"
fi
archive_base="cloud-init-$revname"
export_uncommitted=""
if [ "${UNCOMMITTED:-0}" != "0" ]; then
export_uncommitted="--uncommitted"
# when building an archiving from HEAD, ensure that there aren't any
# uncomitted changes in the working directory (because these would not
# end up in the archive).
if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then
if [ -z "$SKIP_UNCOMITTED_CHANGES_CHECK" ]; then
echo "ERROR: There are uncommitted changes in your working directory." >&2
exit 1
else
echo "WARNING: There are uncommitted changes in your working directory." >&2
echo " This changes will not be included in the archive." >&2
fi
fi
bzr export ${export_uncommitted} \
--format=tgz --root="cloud-init-$VERSION~bzr$REVNO" \
"--revision=${REVNO}" "${ARCHIVE_FN}" "$ROOT_DIR"
git archive \
--format=tar.gz \
--prefix="$archive_base/" "$rev" \
"--output=$archive_base.tar.gz"
echo "$ARCHIVE_FN"
echo "${archive_base}.tar.gz"
#!/usr/bin/env python
# You might be tempted to rewrite this as a shell script, but you
# would be surprised to discover that things like 'egrep' or 'sed' may
# differ between Linux and *BSD.
import os
import re
import sys
import subprocess
if 'CLOUD_INIT_TOP_D' in os.environ:
topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
......@@ -16,14 +21,21 @@ for fname in ("setup.py", "requirements.txt"):
sys.exit(1)
if len(sys.argv) > 1:
reqfile = sys.argv[1]
reqfile = sys.argv[1]
else:
reqfile = "requirements.txt"
reqfile = "requirements.txt"
with open(os.path.join(topd, reqfile), "r") as fp:
for line in fp:
if not line.strip() or line.startswith("#"):
line = line.strip()
if not line or line.startswith("#"):
continue
sys.stdout.write(re.split("[>=.<]*", line)[0].strip() + "\n")
# remove pip-style markers
dep = line.split(';')[0]
# remove version requirements
dep = re.split("[>=.<]*", dep)[0].strip()
print(dep)
sys.exit(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment