Makefile: deb and rpm targets for PR testing

This commit adds an rpm specfile and debian packaging files
(currently ubuntu zesty) to build packages using HEAD,
meant to be run for PR testing.

Includes contributions from Ed Santiago and Chris Evich.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
Signed-off-by: Chris Evich <cevich@redhat.com>
Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Lokesh Mandvekar 2018-01-03 19:48:26 +05:30
parent a34038350c
commit 361337001c
No known key found for this signature in database
GPG key ID: 1C1EDD7CC7C3A0DD
8 changed files with 385 additions and 1 deletions

View file

@ -87,7 +87,28 @@ crio: .gopathok $(shell hack/find-godeps.sh $(GOPKGDIR) cmd/crio $(PROJECT))
crio.conf: crio
./bin/crio --config="" config --default > crio.conf
clean:
tarball-prep:
git archive --format=tar.gz --prefix=cri-o-testonly/ HEAD > ../cri-o-testonly_1.8.0.orig.tar.gz
# -E needed to preserve CRIO_GIT_* and DEBUG envariables used in script
test-rpm: tarball-prep
sudo -E ./contrib/rpm/make-testonly-rpms \
../cri-o-testonly_1.8.0.orig.tar.gz
test-deb: tarball-prep
sudo apt-add-repository -y ppa:projectatomic/ppa
sudo sed -i '/deb-src/s/# //g' /etc/apt/sources.list.d/projectatomic-ubuntu-ppa-zesty.list
sudo apt update
sudo apt build-dep cri-o
dpkg-buildpackage -us -uc
clean-rpm:
rm -rf cri-o*.rpm ../cri-o-testonly*.tar.gz
clean-deb:
rm -rf debian/cri-o ../*ppa*
clean: clean-rpm clean-deb
ifneq ($(GOPATH),)
rm -f "$(GOPATH)/.gopathok"
endif

141
contrib/rpm/make-testonly-rpms Executable file
View file

@ -0,0 +1,141 @@
#!/bin/bash
#
# make-testonly-rpms - build cri-o testing rpms
#
# Invocation: run this while cd'ed to a checked-out copy of cri-o from git.
#
SCRIPT=$(basename $0)
# Default settings.
#
# Where to fetch the rpm spec + extras. Can be overridden, see $usage
DEFAULT_GIT_REPO_URL=https://src.fedoraproject.org/rpms/cri-o.git
DEFAULT_GIT_REPO_BRANCH=master
# Special case for CI: if this subdirectory exists and contains a specfile,
# its contents will be used for building instead of the git repo.
TEST_SPEC_DIR=spec-dir-for-ci--DO-NOT-MERGE
# boilerplate: command-line option and arg processing
missing=" argument is missing; see $SCRIPT --help for details"
usage="Usage: $SCRIPT [--help] TARBALL_PATH
--help display usage message
$SCRIPT builds installable cri-o RPMs
Command-line arguments:
TARBALL_PATH is a path (relative is OK) to a tarball containing
cri-o sources. It should unpack into a subdirectory
named 'cri-o-testonly'.
Environment:
CRIO_GIT_REPO_URL if present in environment, is a URL to a git repo
containing an RPM spec file and all other files (e.g.
patches) needed to build and package cri-o.
Default: $DEFAULT_GIT_REPO_URL
Special case for CI: if the subdirectory
$TEST_SPEC_DIR exists
under the current directory, and contains a file
with the extension .spec, this subdirectory
will be used as the base from which to build.
GIT_BRANCH is a branch to use on the above git repo. This
allows testing spec PRs, e.g. 'pull/1/head'
Default: $DEFAULT_GIT_REPO_BRANCH
"
for i
do
value=`expr "$i" : '[^=]*=\(.*\)'`
case "$i" in
-h*|--help) echo "$usage"; exit 0;;
-*) echo "$SCRIPT: unrecognized option $i" >&2
echo "$usage" >&2
exit 1;;
*) break;;
esac
done
# First arg: path to tarball. Get its full path now, before we cd out.
# ${...?...} means: if arg is missing, abort with given error message.
TARBALL_PATH=${1?TARBALL_PATH$missing}
full_tarball_path=$(realpath $TARBALL_PATH)
# fedpkg/rhpkg repo containing specfile, patches, what's needed for build
GIT_REPO_URL=${CRIO_GIT_REPO_URL-$DEFAULT_GIT_REPO_URL}
# If present, final arg is a git branch
GIT_BRANCH=${CRIO_GIT_REPO_BRANCH-$DEFAULT_GIT_REPO_BRANCH}
# Special case for CI. If certain well-known not-for-real-world-use
# subdirectory exists and contains a specfile, override the git repo.
if [ -d $TEST_SPEC_DIR ]; then
if [ -f $TEST_SPEC_DIR/*.spec ]; then
echo "$ME: WARNING: Using specfile in $TEST_SPEC_DIR" >&2
GIT_REPO_URL=$(realpath $TEST_SPEC_DIR)
GIT_BRANCH=
else
echo "$ME: WARNING: no specfile found in $TEST_SPEC_DIR" >&2
echo "$ME: Please delete that directory if you are done with it." >&2
fi
fi
# Done with boilerplate. Start working.
set -e
orig_dir=$(realpath .)
# Pull the RPM-building components
workdir=$(mktemp --tmpdir -d $SCRIPT.XXXXXXX)
trap 'test -z "$DEBUG" && cd / && rm -rf $workdir' EXIT
cd $workdir
# The usual case is that we fetch the spec and associated files from
# a git repo, probably the fedpkg or rhpkg one. But for debugging, if
# the repo arg is a local directory, just copy it as-is.
if [[ "$GIT_REPO_URL" =~ ^/ && -d $GIT_REPO_URL ]]; then
cp -r $GIT_REPO_URL rpm_spec_dir
cd rpm_spec_dir
else
# The usual case.
git clone $GIT_REPO_URL rpm_spec_dir
cd rpm_spec_dir
git fetch origin $GIT_BRANCH:rpm_spec_branch
git checkout rpm_spec_branch
fi
# "testonl" (no "y") because this is a pretend git hash; specfile uses abbrev.
cp $full_tarball_path ./cri-o-testonl.tar.gz
# Grab the other source tarball (cri-tools). Adding %dump to a specfile
# causes it to list all defined macros; this gives us a full URL to source1
SPEC=$(echo *.spec)
tmpspec=$(mktemp --suffix=.spec $SCRIPT.XXXXXXX)
sed -e '/^%description/ a%dump\nexit 1\n' <$SPEC >$tmpspec
url=$(rpm -q --specfile $tmpspec 2>&1 |awk '/SOURCEURL1/ { print $3 }'|tail -1)
if [ -z "$url" ]; then
echo "$ME: FATAL: No SOURCEURL1 found in $tmpspec"
exit 1
fi
rm -f $tmpspec
wget $url
# Update source0 to point to the tarball we created above
sed -i -e 's/^\(%global[ ]\+commit0[ ]\+\)[0-9a-f]\+/\1 testonly/' $SPEC
# Build it
yum-builddep -y $SPEC
rpmbuild -ba --define "_topdir $(pwd)" \
--define "_sourcedir $(pwd)" $SPEC
# Move rpms back into the directory from which we were invoked
mv RPMS/*/*.rpm $orig_dir/
# Clean up
cd /
rm -rf $workdir

109
debian/changelog vendored Normal file
View file

@ -0,0 +1,109 @@
cri-o-testonly (1.8.0-1~ubuntu17.04~ppa1) zesty; urgency=medium
* test bump to v1.8.0-dev
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Fri, 22 Sep 2017 08:33:33 -0400
cri-o (1.0.0-rc1-1~ubuntu17.04~ppa6) zesty; urgency=medium
* include golang as build dep to make dh_golang happy
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Mon, 11 Sep 2017 10:27:25 -0400
cri-o (1.0.0-rc1-1~ubuntu17.04~ppa5) zesty; urgency=medium
* bump to v1.0.0-rc1
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Mon, 11 Sep 2017 09:20:57 -0400
cri-o (1.0.0-alpha.0.1-1~ubuntu17.04~ppa4) zesty; urgency=medium
* include golang as build dep to make dh_golang happy
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Tue, 29 Aug 2017 14:49:33 -0400
cri-o (1.0.0-alpha.0.1-1~ubuntu17.04~ppa3) zesty; urgency=medium
* bump to ppa3, should build successfully now
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Tue, 29 Aug 2017 14:32:46 -0400
cri-o (1.0.0-alpha.0.1-1~ubuntu17.04~ppa1) zesty; urgency=medium
* append ".1" to version to get PPA to shut up about prior tarballs
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Fri, 25 Aug 2017 18:58:42 -0400
cri-o (1.0.0-alpha.0-1~ubuntu17.04~ppa2) zesty; urgency=medium
* built commit a38419a
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Fri, 25 Aug 2017 15:52:13 -0400
cri-o (1.0.0-alpha.0-1~ubuntu17.04~ppa1) zesty; urgency=medium
* bump to v1.0.0-alpha
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Tue, 18 Jul 2017 16:19:44 -0400
cri-o (0.3-1~ubuntu17.04~ppa10) zesty; urgency=medium
* update release tag format to mention distro version
* remove ppa9 build from PPA and rebuild
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Tue, 04 Jul 2017 23:12:07 -0400
cri-o (0.3-1ppa9) zesty; urgency=medium
* correct conmon install location
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Fri, 30 Jun 2017 00:57:34 -0400
cri-o (0.3-1ppa8) zesty; urgency=medium
* update release tag cause previous release exists already
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Fri, 30 Jun 2017 00:33:44 -0400
cri-o (0.3-1ppa7) zesty; urgency=medium
* correct crio.conf file and install paths for binaries and unitfiles
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 14:50:03 -0400
cri-o (0.3-1ppa6) zesty; urgency=medium
* add additional config files and correct unitfile
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 13:45:10 -0400
cri-o (0.3-1ppa5) zesty; urgency=medium
* include skopeo-containers as install-time dep
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 11:01:54 -0400
cri-o (0.3-1ppa4) zesty; urgency=medium
* use correct path for runc executable from cri-o-runc in /etc/crio.conf
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 00:47:38 -0400
cri-o (0.3-1ppa3) zesty; urgency=medium
* add dh-golang as build dep
* upstream commit 88037b1 used for building package
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 00:23:57 -0400
cri-o (0.3-1ppa2) zesty; urgency=medium
* update debian/control Section field
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 00:18:16 -0400
cri-o (0.3-1ppa1) zesty; urgency=medium
* Initial package
-- Lokesh Mandvekar <lsm5@fedoraproject.org> Thu, 29 Jun 2017 00:07:46 -0400

1
debian/compat vendored Normal file
View file

@ -0,0 +1 @@
9

31
debian/control vendored Normal file
View file

@ -0,0 +1,31 @@
Source: cri-o-testonly
Section: devel
Priority: optional
Maintainer: Lokesh Mandvekar <lsm5@fedoraproject.org>
Build-Depends: debhelper (>=9),
rsync,
libdevmapper-dev,
libgpgme11-dev,
libseccomp-dev,
golang,
golang-1.8,
btrfs-tools,
libglib2.0-dev,
go-md2man,
dh-golang,
git,
libostree-dev
Standards-Version: 3.9.6
Homepage: https://github.com/kubernetes-incubator/cri-o
#Vcs-Git: git://anonscm.debian.org/collab-maint/cri-o.git
#Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/cri-o.git
Package: cri-o-testonly
Architecture: all
Depends: ${misc:Depends},
libdevmapper1.02.1,
libgpgme11,
cri-o-runc,
skopeo
Suggests: containernetworking-plugins
Description: OCI-based implementation of Kubernetes Container Runtime Interface.

9
debian/copyright vendored Normal file
View file

@ -0,0 +1,9 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: cri-o
Source: https://github.com/kubernetes-incubator/cri-o.git
Comment:
All golang deps bundled.
FIles under vendor/ could have their own independent licenses.
Files: *
License: Apache-2.0

71
debian/rules vendored Executable file
View file

@ -0,0 +1,71 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export DH_VERBOSE=1
export DH_GOPKG := github.com/kubernetes-incubator/cri-o
# Include test fixtures.
#export DH_GOLANG_INSTALL_EXTRA := discovery/file/fixtures \
storage/local/fixtures config/testdata promql/testdata retrieval/testdata \
promql/fuzz-data
# Do not build examples.
#export DH_GOLANG_EXCLUDES := documentation vendor
# Lots of shameless copy-paste from the debian package for prometheus
BUILDDIR := $(shell pwd)
GO := /usr/lib/go-1.8/bin/go
DESTDIR := $(BUILDDIR)/debian/cri-o
BUILDTAGS := 'selinux seccomp $(shell $(BUILDDIR)/hack/btrfs_tag.sh) $(shell $(BUILDDIR)/hack/libdm_tag.sh) containers_image_ostree_stub'
%:
dh_clean
make clean
rm -rf $(BUILDDIR)/src $(BUILDDIR)/crio.conf
dh $@ --buildsystem=golang --with=golang --builddirectory=$(BUILDDIR)
override_dh_auto_configure:
dh_auto_configure -O--buildsystem=golang
# Include vendored dependencies.
cp -rp $(BUILDDIR)/vendor $(BUILDDIR)/src
mkdir -p $(BUILDDIR)/src/$(DH_GOPKG)
rsync -a $(BUILDDIR)/* $(BUILDDIR)/src/$(DH_GOPKG) --exclude src
override_dh_auto_build:
GOPATH=$(BUILDDIR) GO=$(GO) BUILDTAGS=$(BUILDTAGS) make binaries docs crio.conf
$(BUILDDIR)/crio --storage-driver=overlay2 --runtime /usr/lib/cri-o-runc/sbin/runc \
--conmon /usr/lib/crio/bin/conmon \
--cgroup-manager=systemd config > $(BUILDDIR)/crio.conf
override_dh_auto_test:
override_dh_auto_install:
PREFIX=$(DESTDIR)/usr ETCDIR_CRIO=$(DESTDIR)/etc/crio \
make install.config install.completions
# install binaries
install -dp $(DESTDIR)/usr/bin
install -p -m 755 crio $(DESTDIR)/usr/bin
install -p -m 755 crioctl $(DESTDIR)/usr/bin
install -p -m 755 kpod $(DESTDIR)/usr/bin
install -dp $(DESTDIR)/usr/lib/crio/bin
install -p -m 755 conmon/conmon $(DESTDIR)/usr/lib/crio/bin
install -p -m 755 pause/pause $(DESTDIR)/usr/lib/crio/bin
install -dp $(DESTDIR)/etc/cni/net.d
install -p -m 644 contrib/cni/10-crio-bridge.conf $(DESTDIR)/etc/cni/net.d/100-crio-bridge.conf
install -p -m 644 contrib/cni/99-loopback.conf $(DESTDIR)/etc/cni/net.d/200-loopback.conf
install -dp $(DESTDIR)/lib/systemd/system
install -p -m 644 contrib/systemd/crio.service $(DESTDIR)/lib/systemd/system
install -p -m 644 contrib/systemd/crio-shutdown.service $(DESTDIR)/lib/systemd/system
sed -i 's/\/usr\/local\/bin\/crio/\/usr\/bin\/crio/g' $(DESTDIR)/lib/systemd/system/crio.service
rm -rf $(BUILDDIR)/obj-x86_64-linux-gnu

1
debian/source/format vendored Normal file
View file

@ -0,0 +1 @@
3.0 (quilt)