summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-10-23 14:56:25 +0200
committerAlon Levy <alevy@redhat.com>2011-10-23 16:34:28 +0200
commitdd34dfb8fa572a9f112cd0210556f31ace689ba7 (patch)
tree51077dcf11383956346d5c52fb2e21bd7042c4c3
parent40640a3f30bd6ab6978601f08835235ba9029f86 (diff)
server/redhat: brew automation, from qemu-kvm
adds targets for building an srpm and initiating a brew scratchbuild: echo my.bz123456 > server/localversion make -C server/redhat rh-srpm make -C server/redhat rh-brew pyparsing dependency is solved by wget-ing it, and adding it as Source1. This should be removed once RHEL gets it.
-rw-r--r--server/redhat/Makefile217
-rw-r--r--server/redhat/Makefile.common51
-rwxr-xr-xserver/redhat/create-patches.sh326
-rw-r--r--server/redhat/lastcommit1
-rw-r--r--server/redhat/rpm/BUILD/.gitignore2
-rw-r--r--server/redhat/rpm/BUILDROOT/.gitignore2
-rw-r--r--server/redhat/rpm/RPMS/.gitignore2
-rw-r--r--server/redhat/rpm/SOURCES/.gitignore2
-rw-r--r--server/redhat/rpm/SPECS/.gitignore2
-rw-r--r--server/redhat/rpm/SRPMS/.gitignore2
-rwxr-xr-xserver/redhat/scripts/spice-make-release54
-rw-r--r--server/redhat/spice-server.spec.template264
12 files changed, 925 insertions, 0 deletions
diff --git a/server/redhat/Makefile b/server/redhat/Makefile
new file mode 100644
index 00000000..28eedb32
--- /dev/null
+++ b/server/redhat/Makefile
@@ -0,0 +1,217 @@
+include Makefile.common
+
+LOCVERFILE:=../localversion
+LANG=C
+BUILD_DEFAULT_TARGET = RHEL-6-test
+BUILD_SCRATCH_TARGET = RHEL-6-test
+
+#ifeq ($(shell git diff --quiet HEAD && git describe --exact-match 2>/dev/null && echo ok),)
+BUILD_TARGET ?= --scratch $(BUILD_SCRATCH_TARGET)
+#else
+#BUILD_TARGET ?= $(BUILD_DEFAULT_TARGET)
+#endif
+
+RELEASE:=$(shell sed -ne 's/^[^\#]*define release \(.*\)%.*%.*/\1/p' $(REDHAT)/$(SPECFILE).template)
+
+# create an empty localversion file if you don't want a local buildid
+ifneq ($(wildcard $(LOCVERFILE)),)
+LOCALVERSION:=$(shell cat $(LOCVERFILE))
+else
+LOCALVERSION:=test
+endif
+ifneq ($(LOCALVERSION),)
+BUILDID:=.$(LOCALVERSION)
+$(info BUILDID is "$(BUILDID)". Update '$(shell dirname $(REDHAT))/localversion' to change.)
+endif
+
+# this section is needed in order to make O= and KBUILD_OUTPUT to work
+ifeq ($(KBUILD_OUTPUT),)
+ifeq ("$(origin O)", "command line")
+ KBUILD_OUTPUT := $(O)
+endif
+ifeq ($(KBUILD_OUTPUT),)
+ KBUILD_OUTPUT := $(REDHAT)/..
+endif
+endif
+
+PKGRELEASE=$(BUILD)
+PKG_FULL_VR = $(STAMP_VERSION)-$(PKGRELEASE)$(DIST)$(BUILDID)
+PKG_FULL_NVR = $(PKGNAME)-$(PKG_FULL_VR)
+
+RPMBUILD_DEFS = --define "_sourcedir $(SOURCES)" --define "_builddir $(RPM)/BUILD" --define "_srcrpmdir $(RPM)/SRPMS" --define "_rpmdir $(RPM)/RPMS" --define "_specdir $(RPM)/SPECS" --define "dist $(DIST)"
+
+default: rh-help
+
+rh-configs:
+ cd $(REDHAT)/configs; $(MAKE) VERSION=$(KVERSION) configs
+
+rh-configs-prep:
+ cd $(REDHAT)/configs; $(MAKE) VERSION=$(KVERSION) O=$(KBUILD_OUTPUT) configs-prep
+
+rh-clean-configs:
+ cd $(REDHAT)/configs; $(MAKE) VERSION=$(KVERSION) clean
+
+rh-clean-sources:
+ @for i in $(SOURCES)/*; do \
+ rm -f $$i; \
+ done;
+
+rh-pull-configs:
+ cd $(REDHAT)/configs; $(MAKE) VERSION=$(KVERSION) pull-configs
+
+rh-key:
+ echo "Creating a new module signing key...";
+ @cd $(KBUILD_OUTPUT); \
+ /sbin/rngd -r /dev/urandom; \
+ gpg --homedir . --batch --gen-key $(REDHAT)/genkey; \
+ if [ -s $(REDHAT)/extrakeys.pub ]; then \
+ gpg --homedir . --no-default-keyring --keyring $(COMMON_NAME).pub --import $(REDHAT)/extrakeys.pub; \
+ fi; \
+ gpg --homedir . --export --keyring $(COMMON_NAME).pub Red > extract.pub; \
+ mkdir -p crypto/signature/ scripts/; \
+ gcc -o scripts/bin2c $(REDHAT)/../scripts/bin2c.c; \
+ scripts/bin2c ksign_def_public_key __initdata < extract.pub >crypto/signature/key.h;
+
+$(TARBALL):
+ @if [ -n "$(TARURL)" ];then \
+ echo "Downloading $(TARBALL) from $(TARURL)"; \
+ wget -O $(TARBALL) $(TARURL) || exit; \
+ else \
+ echo "Creating archive $(TARBALL)"; \
+ rm -f $(TARBALL); \
+ scripts/spice-make-release --formal $(MARKER) $(COMMON_BASE_NAME)-$(KVERSION) $(TARBALL); \
+ fi
+
+$(RC_PATCH):
+ @if [ -n "$(RCREV)" ]; then \
+ git diff $(COMMON_NAME)-$(KVERSION)..$(COMMON_NAME)-$(SUBLEVEL)-rc$(RCREV) | \
+ gzip >$(REDHAT)/$(RC_PATCH); \
+ fi
+
+$(GIT_PATCH):
+ @if [ -n "$(GITREV)" ]; then \
+ git diff $(COMMON_NAME)-$(SUBLEVEL)-rc$(RCREV)..$(MARKER) | \
+ gzip >$(REDHAT)/$(GIT_PATCH); \
+ fi
+
+setup-source: rh-clean-sources
+ @cp $(REDHAT)/$(SPECFILE).template $(SOURCES)/$(SPECFILE)
+
+$(PYPARSING_TARBALL):
+ wget $(PYPARSING_URL)
+
+sources-rh: $(PYPARSING_TARBALL) $(TARBALL) $(RC_PATCH) $(GIT_PATCH) $(REDHAT)/create-patches.sh Makefile lastcommit
+ @if [ -n "$(TARSHA1)" -a "$$(sha1sum < $(TARBALL) | cut -d' ' -f1)" != "$(TARSHA1)" ];then \
+ echo "$(TARBALL) sha1sum does not match (expected: $(TARSHA1))" >&2; \
+ exit 1; \
+ fi
+ @if [ -n "$(TARSHA256)" -a "$$(tar -oxjf $(TARBALL) | sha256sum | cut -d' ' -f1)" != "$(TARSHA256)" ];then \
+ echo "$(TARBALL) sha256sum $(TARSHA256) does not match (expected: $(TARSHA256))" >&2; \
+ exit 1; \
+ fi
+ @cp $(PYPARSING_TARBALL) $(SOURCES)/
+ @cp $(TARBALL) $(SOURCES)/
+ @(if [ -n "$(RCREV)" ]; then \
+ cp $(RC_PATCH) $(SOURCES)/; \
+ fi)
+ @(if [ -n "$(GITREV)" ]; then \
+ cp $(GIT_PATCH) $(SOURCES)/; \
+ fi)
+ @touch $(TESTPATCH)
+ @git diff --no-renames HEAD > $(TESTPATCH).tmp
+ @diff $(TESTPATCH).tmp $(TESTPATCH) > /dev/null || \
+ echo "WARNING: There are uncommitted changes in your tree or the changes are not in sync with the $(COMMON_NAME)-test.patch. Either commit the changes or run 'make rh-test-patch'"
+ @rm $(TESTPATCH).tmp
+ @$(REDHAT)/create-patches.sh $(MARKER) $(SOURCES) $(SOURCES)/$(SPECFILE) $(PKGRELEASE) $(BUILD) $(BUILDID)
+ @cp $(SOURCES)/$(SPECFILE) $(SOURCES)/../SPECS
+ @cp $(TESTPATCH) $(SOURCES)/$(COMMON_NAME)-test.patch
+# @cp configs/Makefile $(SOURCES)/Makefile.config
+ @cp Makefile.common $(SOURCES)/
+ @(if [ -n "$(EXTRA_SOURCES)" ]; then \
+ @cp $(EXTRA_SOURCES) $(SOURCES)/; \
+ fi)
+# @cp genkey perf Makefile.common kabi/{find-provides,kabitool,check-kabi} kabi/Module.kabi_{i686,ppc64,s390x,x86_64} configs/{config-*,merge.pl} extrakeys.pub $(SOURCES)/
+
+rh-sources: setup-source sources-rh
+
+rh-test-patch:
+ git diff --no-renames HEAD > $(TESTPATCH);
+ filterdiff -x '*redhat/*' -x '*/.gitignore' -x '*/makefile' $(TESTPATCH) >$(TESTPATCH).tmp;
+ mv $(TESTPATCH).tmp $(TESTPATCH);
+
+rh-all-rpms: rh-sources
+ $(RPMBUILD) $(RPMBUILD_DEFS) --target $(MACH) -ba $(RPM)/SOURCES/$(SPECFILE)
+
+rh-srpm: rh-sources
+ $(RPMBUILD) $(RPMBUILD_DEFS) --nodeps -bs $(RPM)/SOURCES/$(SPECFILE)
+
+rh-rpms: rh-sources
+ $(RPMBUILD) $(RPMBUILD_DEFS) --target $(MACH) -bb $(RPM)/SOURCES/$(SPECFILE)
+
+rh-$(COMMON_NAME)-%: rh-sources
+ $(RPMBUILD) $(RPMBUILD_DEFS) --target $(MACH) --with $* --without vdso_install --with firmware -bb $(RPM)/SOURCES/$(SPECFILE)
+
+rh-prep: rh-sources
+ $(RPMBUILD) $(RPMBUILD_DEFS) --nodeps --target $(MACH) -bp $(RPM)/SOURCES/$(SPECFILE)
+
+# we could just print the version number to stderr, but make dumps too much junk
+# to stdout to make it usable, so a 'verrel' file is created
+rh-verrel:
+ @echo $(PKG_FULL_NVR) > verrel
+
+# unless you know what you're doing, you don't want to use the next two ones
+rh-release: rh-clean-sources
+ @$(REDHAT)/scripts/new_release.sh $(KVERSION) $(BUILD) $(REDHAT)
+ @make rh-srpm
+ # this will be use the new BUILD definition from Makefile.common:
+ @$(MAKE) rh-update-changelog
+
+rh-release-commit:
+ @git commit -s Makefile.common $(SPECFILE).template -m "[redhat] tagging $(PKG_FULL_VR)"
+ @git tag $(PKG_FULL_NVR)
+ @git log --max-count=1 --pretty=format:%H >$(REDHAT)/lastcommit;
+ @git commit -s lastcommit -m "[redhat] updating lastcommit for $(PKG_FULL_VR)"
+
+rh-update-changelog:
+ @$(REDHAT)/scripts/update_changelog.sh $(KVERSION) $(PKG_FULL_VR)
+
+.PHONY: rh-brew rh-koji
+rh-brew : BUILD_FLAGS ?= $(BREW_FLAGS) $(TEST_FLAGS)
+rh-koji : BUILD_FLAGS ?= $(KOJI_FLAGS) $(TEST_FLAGS)
+rh-brew rh-koji: rh-%: rh-srpm
+ $* build $(BUILD_FLAGS) $(BUILD_TARGET) $(SRPMS)/$(PKG_FULL_NVR).src.rpm $(OUTPUT_FILE)
+
+rh-help:
+ @echo 'Cleaning targets:'
+ @echo ' rh-clean-sources - Clean the redhat/rpm/SOURCES/ directory'
+ @echo ' rh-clean-configs - Clean the redhat/configs/ directory'
+ @echo ''
+ @echo 'Building targets:'
+ @echo ' All RPM/SRPM files will be put under the redhat/rpm/ directory'
+ @echo ''
+ @echo ' rh-srpm - Create a source RPM and put it into the redhat/rpm/SRPMS/ directory'
+ @echo ' rh-brew - Create a $(COMMON_NAME) SRPM and then call brew to build the created SRPM'
+ @echo ' rh-koji - Create a $(COMMON_NAME) SRPM and then call koji to build the created SRPM'
+ @echo ' rh-rpms - Create the binary RPMS for the $(COMMON_NAME)'
+ @echo ' rh-$(COMMON_NAME)-<type> - Create binary RPMS for a particular $(COMMON_NAME) type'
+ @echo ' - <type> can be: baseonly, smponly, dbgonly'
+
+ @echo ' rh-all-rpms - Create the binary RPMS and the SRPM for the $(COMMON_NAME)'
+ @echo ' rh-prep - Setup the redhat/rpm/BUILD/ directory with the $(COMMON_NAME) source'
+ @echo ' rh-test-patch - Create a diff against HEAD and put it in $(COMMON_NAME)-test.patch.'
+ @echo ' Then $(COMMON_NAME)-test.patch will be added to the $(COMMON_NAME) build'
+ @echo ' rh-key - Generate the required files for compiling with module signing enabled'
+ @echo ''
+ @echo 'Configuration targets:'
+ @echo
+ @echo ' rh-configs-prep Creates config files for RHEL 6 architectures, cleans them'
+ @echo ' by running make nonint_oldconfig, and copies them to'
+ @echo ' configs/ directory. This is the target to use for a config!'
+ @echo ' Copy the config file you want from the configs/ directory'
+ @echo ' to .config'
+ @echo ''
+ @echo ' Most developers will NOT use the following config targets.'
+ @echo ' See the redhat/README file for more info'
+ @echo ' rh-configs Creates config files in the redhat/configs/ directory,'
+ @echo ' these will be used by other Makefile targets and are not'
+ @echo ' intended for developer use'
diff --git a/server/redhat/Makefile.common b/server/redhat/Makefile.common
new file mode 100644
index 00000000..3902719a
--- /dev/null
+++ b/server/redhat/Makefile.common
@@ -0,0 +1,51 @@
+RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
+ else echo rpm; fi)
+MACH := $(shell uname -m)
+
+# just used to define the other name variables
+COMMON_NAME=spice-server
+# package and repository are spice, not spice-server.
+COMMON_BASE_NAME=spice
+
+
+KVERSION:=0.8.2
+# marker is git tag
+MARKER:=$(KVERSION)
+SPECFILE:=$(COMMON_NAME).spec
+REDHAT:=$(shell pwd)
+RPM:=$(REDHAT)/rpm
+SRPMS:=$(RPM)/SRPMS
+SOURCES:=$(RPM)/SOURCES
+BUILD:=4
+DIST=.el6
+PKGNAME=$(COMMON_NAME)
+
+#TARFILE:=$(subst _,.,$(MARKER)).tar.bz2
+TARFILE:=$(COMMON_BASE_NAME)-$(KVERSION).tar.bz2
+#TARURL:=http://downloads.sourceforge.net/sourceforge/kvm/$(COMMON_NAME)-$(KVERSION).tar.gz
+#TARSHA1:=dee7359094757af77ea839bbfd9dca8826edcbd2
+TARSHA256:=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+
+TARBALL:=$(REDHAT)/$(TARFILE)
+TESTPATCH:=$(REDHAT)/$(COMMON_NAME)-test.patch
+
+PYPARSING_URL=http://downloads.sourceforge.net/pyparsing/pyparsing-1.5.6.tar.gz
+PYPARSING_TARBALL=pyparsing-1.5.6.tar.gz
+
+EXTRA_SOURCES =
+
+SUBLEVEL := $(shell echo $(MARKER) | cut -f 3 -d '-')
+#RCREV := $(shell echo $(MARKER) | cut -f 2 -d '-' -s | sed -e "s/rc//")
+RCREV :=
+GITREV := $(shell echo $(MARKER) | cut -f 4 -d '-' -s | sed -e "s/git//")
+
+ifneq ($(RCREV),)
+ RELEASED_KERNEL := 0
+ STAMP_VERSION := $(shell echo $(MARKER) | cut -f 1 -d '-' | sed -e "s/v//")
+else
+ RELEASED_KERNEL := 1
+ STAMP_VERSION := $(KVERSION)
+endif
+RC_PATCH := patch-$(SUBLEVEL)-rc$(RCREV).gz
+GIT_PATCH := patch-$(SUBLEVEL)-rc$(RCREV)-git$(GITREV).gz
+
diff --git a/server/redhat/create-patches.sh b/server/redhat/create-patches.sh
new file mode 100755
index 00000000..3ab2dc09
--- /dev/null
+++ b/server/redhat/create-patches.sh
@@ -0,0 +1,326 @@
+#! /bin/bash
+
+MARKER=$1
+SOURCES=$2
+SPECFILE=$3
+PKGRELEASE=$4
+
+# BUILD* are legacy variables: please use PKGRELEASE instead
+BUILD=$5
+BUILDID=$6
+
+PATCHF="$SOURCES/Patch.include"
+patchf="$SOURCES/patch.include"
+SERIESF="$SOURCES/series"
+clogf="$SOURCES/changelog"
+# hide [redhat] entries from changelog
+HIDE_REDHAT=1;
+# include "From <commit> <commit-date>" line on patches
+PRINT_COMMITLINE=1;
+# add an extra empty line between headers and "meta" data
+META_EXTRALINE=1;
+# prefix for all patch files:
+PATCHPREFIX='spice-';
+# strips all redhat/ and .gitignore patches
+# This was requested in order to avoid the contents of the redhat/ directory
+# to be included on the packages (arozansk, orders of lwang)
+STRIP_REDHAT=1;
+# override LC_TIME to avoid date conflicts when building the srpm
+LC_TIME=
+SUBLEVEL=$(echo $MARKER | cut -f 3 -d '-')
+#RCREV := $(shell echo $(MARKER) | cut -f 2 -d '-' -s | sed -e "s/rc//")
+RCREV=
+GITREV=$(echo $MARKER | cut -f 4 -d '-' -s | sed -e "s/git//")
+LASTCOMMIT=$(cat lastcommit);
+#STAMP=$(echo $MARKER | cut -f 1 -d '-' | sed -e "s/v//");
+STAMP=$(echo $MARKER | cut -f 3 -d '-')
+if [ -n "$RCREV" ]; then
+ RELEASED_KERNEL="0";
+ SUBLEVEL=$(($SUBLEVEL - 1));
+else
+ RELEASED_KERNEL="1";
+ RCREV=0;
+fi
+if [ -z "$GITREV" ]; then
+ GITREV=0;
+fi
+RPM_VERSION="$STAMP-$PKGRELEASE.el6$BUILDID";
+
+touch $PATCHF $patchf
+echo >$clogf
+
+total="$(git log --first-parent --pretty=oneline $MARKER.. |wc -l)"
+git format-patch --first-parent --no-renames -k --stdout $MARKER..|tee debug0 | awk '
+BEGIN{TYPE="PATCHJUNK"; count=1; dolog=0; pnum=1000}
+
+ #convert subject line to a useable filename
+ function subj_to_name(subject)
+ {
+ #strip off "Subject: "
+ subject = substr(subject, 10);
+
+ #need to get first word
+ split(subject, a);
+ pre = a[1];
+
+ #if word matches foo: or [foo], then the patch is
+ #good, otherwise stick a misc in front of it
+ if (! match(pre, /:$|^\[.*\]$/)) {
+ subject = "misc " subject;
+ }
+
+ name = subject;
+ #keep cvs name all lower case, I forgot why
+ if (SPECFILE == "") { name = tolower(name); }
+
+ #do the actual filename conversion
+ gsub(/[^a-zA-Z0-9_-]/,"-", name);
+ gsub(/--*/, "-", name);
+ gsub(/^[.-]*/, "", name);
+ gsub(/[.-]*$/, "", name);
+
+ if (!match(name, "^" PATCHPREFIX)) {
+ name = PATCHPREFIX name;
+ }
+
+ #check for duplicate files and append a number to it
+ patchname=name;
+ num=2;
+ while (! system("test -f " SOURCES "/" patchname ".patch")) {
+ patchname=name "-" num;
+ num=num+1;
+ }
+ patchname = patchname ".patch";
+ }
+
+ # add an entry to changelog
+ function changelog(subjectline, nameline)
+ {
+ subj = substr(subjectline, 10);
+ gsub(/%/, "", subj)
+ name = substr(nameline, 7);
+ pos=match(name, /</);
+ name=substr(name,1,pos-2);
+ if ( HIDE_REDHAT == 1 ) {
+ if ( subj ~ /^[\[]?redhat[:\]]/ ) {
+ if ( COMMIT == LASTCOMMIT ) {
+ dolog = 1;
+ }
+ return;
+ }
+ if ( subj ~ /^Revert/ ) {
+ if ( COMMIT == LASTCOMMIT ) {
+ dolog = 1;
+ }
+ return;
+ }
+ # keep Fedora on the patch name but not on the changelog
+ if ( subj ~ /^\[Fedora\]/ ) {
+ gsub(/\[Fedora\] /, "", subj)
+ }
+ }
+ bz=substr(BZ,11);
+ meta = "";
+ if (bz != "") {
+ meta = " [" bz "]";
+ }
+ cve = substr(CVE, 6);
+ if (cve != "") {
+ if (meta != "") {
+ meta = meta " {" cve "}";
+ } else {
+ meta = " {" cve "}";
+ }
+ }
+ if ( COMMIT == LASTCOMMIT ) {
+ dolog=1;
+ } else {
+ if (dolog == 1) {
+ clog = "- " subj " (" name ")" meta;
+ print clog >> CLOGF;
+ }
+ }
+ }
+
+ #special separator, close previous patch
+ /^From / { if (TYPE=="PATCHJUNK") {
+ COMMIT=substr($0, 6, 40);
+ SEPLINE=$0;
+ TYPE="HEADER";
+ close(OUTF);
+ next;
+ } }
+
+ #interesting header stuff
+ /^From: / { if (TYPE=="HEADER") {
+ namestr=$0;
+ #check for mime encoding on the email headers
+ #git uses utf-8 q encoding
+ if ( $0 ~ /=\?utf-8\?q/ ) {
+ #get rid of the meta utf-8 junk
+ gsub(/=\?utf-8\?q\?/, "");
+ gsub(/\?=/, "");
+
+ #translate each char
+ n=split($0, a, "=");
+ namestr = sprintf("%s", a[1]);
+ for (i = 2; i <= n; ++i) {
+ utf = substr(a[i], 0, 2);
+ c = strtonum("0x" utf);
+ namestr = sprintf("%s%c%s", namestr, c, substr(a[i],3));
+ }
+ }
+ NAMELINE=namestr; next;
+ }
+ }
+ /^Date: / {if (TYPE=="HEADER") {DATELINE=$0; next; } }
+ /^Subject: / { if (TYPE=="HEADER") {SUBJECTLINE=$0; next; } }
+ /^Bugzilla: / { if (TYPE=="META") {BZ=$0; } }
+ /^CVE: / { if (TYPE=="META") {CVE=$0; } }
+
+ #blank line triggers end of header and to begin processing
+ /^$/ {
+ if (TYPE=="META") {
+ #create the dynamic changelog entry
+ changelog(SUBJECTLINE, NAMELINE);
+ #reset cve values because they do not always exist
+ CVE="";
+ BZ="";
+ TYPE="BODY";
+ }
+ if (TYPE=="HEADER") {
+ subj_to_name(SUBJECTLINE);
+ OUTF= SOURCES "/" patchname;
+
+ #output patch commands for specfile
+ print "Patch" pnum": " patchname >> PATCHF;
+ #print "ApplyPatch " patchname >> patchf;
+ print "%patch" pnum " -p1" >> patchf;
+ pnum=pnum+1;
+
+ if (SPECFILE == "") { print patchname >> SERIESF; }
+
+ printf "Creating spice patches - (" count "/" total ")\r";
+ count=count+1;
+
+ printf "" > OUTF;
+ if (PRINT_COMMITLINE == 1)
+ print SEPLINE >> OUTF;
+ print NAMELINE >> OUTF;
+ print DATELINE >> OUTF;
+ print SUBJECTLINE >> OUTF;
+ if (META_EXTRALINE == 1)
+ print >> OUTF;
+ TYPE="META"; next;
+ }
+ }
+
+ #in order to handle overlapping keywords, we keep track of each
+ #section of the patchfile and only process keywords in the correct section
+ /^---$/ {
+ if (TYPE=="META") {
+ # no meta data found, just use the subject line to fill
+ # the changelog
+ changelog(SUBJECTLINE, NAMELINE);
+ #reset cve values because they do not always exist
+ CVE="";
+ BZ="";
+ TYPE="BODY";
+ }
+ if (TYPE=="BODY") {
+ TYPE="PATCHSEP";
+ }
+ }
+ /^diff --git/ { if (TYPE=="PATCHSEP") {print "" >> OUTF; TYPE="PATCH"; } }
+ /^-- $/ { if (TYPE=="PATCH") { TYPE="PATCHJUNK"; } }
+
+ #filter out stuff we do not care about
+ { if (TYPE == "PATCHSEP") { next; } }
+ { if (TYPE == "PATCHJUNK") { next; } }
+ { if (TYPE == "HEADER") { next; } }
+
+ #print the rest
+ { print $0 >> OUTF; }
+' SOURCES=$SOURCES PATCHF=$PATCHF patchf=$patchf SPECFILE=$SPECFILE \
+ SERIESF=$SERIESF CLOGF=$clogf total=$total LASTCOMMIT=$LASTCOMMIT \
+ HIDE_REDHAT=$HIDE_REDHAT STRIP_REDHAT=$STRIP_REDHAT \
+ PRINT_COMMITLINE=$PRINT_COMMITLINE PATCHPREFIX=$PATCHPREFIX \
+ META_EXTRALINE=$META_EXTRALINE
+
+echo cp $clogf debug > debug1
+cp $clogf debug
+# strip all redhat/ code
+if [ $STRIP_REDHAT = 1 ]; then
+ which filterdiff >/dev/null 2>&1;
+ if [ ! $? = 0 ]; then
+ echo "patchutils is required (filterdiff)" >&2;
+ exit 1;
+ fi
+ which lsdiff >/dev/null 2>&1;
+ if [ ! $? = 0 ]; then
+ echo "patchutils is required (lsdiff)" >&2;
+ exit 1;
+ fi
+ for patch in $(find $SOURCES/ -name \*.patch); do
+ filterdiff -x '*redhat/*' -x '*/.gitignore' -x '*/makefile' $patch >$SOURCES/.tmp;
+ mv $SOURCES/.tmp $patch;
+ if [ -z "$(lsdiff $patch)" ]; then
+ pnum=`grep -e "^Patch.*: $(basename $patch)$" $PATCHF| sed -e "s/^Patch//" | sed -e "s/:.*//"`
+ grep -v -e "^Patch.*: $(basename $patch)$" $PATCHF >$SOURCES/.tmp;
+ mv $SOURCES/.tmp $PATCHF;
+ grep -v -e "^%patch$pnum -p1$" $patchf >$SOURCES/.tmp;
+ mv $SOURCES/.tmp $patchf;
+ rm -f $patch;
+ fi
+ done
+ if [ ! "$(cat $PATCHF | wc -l)" = "$(cat $patchf | wc -l)" ]; then
+ echo "Internal error: different number of patches between two lists" >&2;
+ exit 1;
+ fi
+fi
+
+#CONFIGS=configs/config.include
+#CONFIGS2=configs/config2.include
+#find configs/ -mindepth 1 -maxdepth 1 -name config-\* | grep -v merged | cut -f 2 -d '/' >$CONFIGS;
+## Set this to a nice high starting point
+#count=50;
+#rm -f $CONFIGS2;
+#for i in $(cat $CONFIGS); do
+# echo "Source$count: $i" >>$CONFIGS2;
+# count=$((count+1));
+#done
+
+printf "Creating spice patches - Done. \n"
+
+#the changelog was created in reverse order
+#also remove the blank on top, if it exists
+#left by the 'print version\n' logic above
+cname="$(git var GIT_COMMITTER_IDENT |sed 's/>.*/>/')"
+cdate="$(date +"%a %b %d %Y")"
+cversion="[$RPM_VERSION]";
+tac $clogf | sed "1{/^$/d; /^- /i\
+* $cdate $cname $cversion
+ }" > $clogf.rev
+
+test -n "$SPECFILE" &&
+ sed -i -e "/%%PATCH_LIST%%/r $PATCHF
+ /%%PATCH_LIST%%/d
+ /%%CONFIGS%%/r $CONFIGS2
+ /%%CONFIGS%%/d
+ /%%PATCH_APPLICATION%%/r $patchf
+ /%%PATCH_APPLICATION%%/d
+ /%%CHANGELOG%%/r $clogf.rev
+ /%%CHANGELOG%%/d
+ s/%%BUILD%%/$BUILD/
+ s/%%BUILDID%%/$BUILDID/
+ s/%%PKGRELEASE%%/$PKGRELEASE/
+ s/%%SUBLEVEL%%/$SUBLEVEL/
+ s/%%RCREV%%/$RCREV/
+ s/%%GITREV%%/$GITREV/
+ s/%%RELEASED_KERNEL%%/$RELEASED_KERNEL/" $SPECFILE
+if [ -n "$BUILDID" ]; then
+ sed -i -e "s/# % define buildid .local/%define buildid $BUILDID/" $SPECFILE;
+fi
+
+rm $PATCHF $patchf $clogf $clogf.rev $CONFIGS $CONFIGS2;
+
diff --git a/server/redhat/lastcommit b/server/redhat/lastcommit
new file mode 100644
index 00000000..730572fe
--- /dev/null
+++ b/server/redhat/lastcommit
@@ -0,0 +1 @@
+f0e5a3cb77625b32050f052a8ede7ab0ca008224 \ No newline at end of file
diff --git a/server/redhat/rpm/BUILD/.gitignore b/server/redhat/rpm/BUILD/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/server/redhat/rpm/BUILD/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/server/redhat/rpm/BUILDROOT/.gitignore b/server/redhat/rpm/BUILDROOT/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/server/redhat/rpm/BUILDROOT/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/server/redhat/rpm/RPMS/.gitignore b/server/redhat/rpm/RPMS/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/server/redhat/rpm/RPMS/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/server/redhat/rpm/SOURCES/.gitignore b/server/redhat/rpm/SOURCES/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/server/redhat/rpm/SOURCES/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/server/redhat/rpm/SPECS/.gitignore b/server/redhat/rpm/SPECS/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/server/redhat/rpm/SPECS/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/server/redhat/rpm/SRPMS/.gitignore b/server/redhat/rpm/SRPMS/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/server/redhat/rpm/SRPMS/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/server/redhat/scripts/spice-make-release b/server/redhat/scripts/spice-make-release
new file mode 100755
index 00000000..f424471b
--- /dev/null
+++ b/server/redhat/scripts/spice-make-release
@@ -0,0 +1,54 @@
+#!/bin/bash -e
+
+usage() {
+ echo "usage: $0 [--upload] [--formal] commit [name] [tarball] [user]"
+ exit 1
+}
+
+[[ -f ~/.kvmreleaserc ]] && . ~/.kvmreleaserc
+
+upload=
+formal=
+
+releasedir=~/sf-release
+[[ -z "$TMP" ]] && TMP="/tmp"
+tmpdir=`mktemp -d "$TMP/spice-make-release.XXXXXXXXXX"`
+while [[ "$1" = -* ]]; do
+ opt="$1"
+ shift
+ case "$opt" in
+ --upload)
+ upload="yes"
+ ;;
+ --formal)
+ formal="yes"
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+commit="$1"
+name="$2"
+
+if [[ -z "$commit" ]]; then
+ usage
+fi
+
+if [[ -z "$name" ]]; then
+ name="$commit"
+fi
+
+tarball="$3"
+if [[ -z "$tarball" ]]; then
+ tarball="$releasedir/$name.tar.gz"
+fi
+
+cd "$(dirname "$0")"/../../..
+pwd
+git archive --prefix="$name/" --format=tar "$commit" | (cd $tmpdir; tar x)
+echo $tmpdir/$name
+(cd $tmpdir/$name; ./autogen.sh && make dist) || (echo build failed in configure or make dist; exit -1)
+mv $tmpdir/$name/$name.tar.bz2 $tarball || (echo failure; exit 1)
+rm -R $tmpdir
diff --git a/server/redhat/spice-server.spec.template b/server/redhat/spice-server.spec.template
new file mode 100644
index 00000000..bff9c7c9
--- /dev/null
+++ b/server/redhat/spice-server.spec.template
@@ -0,0 +1,264 @@
+
+%global tarname spice
+
+%define buildid %{nil}%%BUILDID%%
+%define sublevel %%SUBLEVEL%%
+%define pkgrelease %%PKGRELEASE%%
+%define rpmversion %{sublevel}
+%define full_release %{pkgrelease}%{?dist}%{?buildid}
+
+Name: spice-server
+Version: %{rpmversion}
+Release: %{full_release}
+Summary: Implements the server side of the SPICE protocol
+Group: System Environment/Libraries
+License: LGPLv2+
+URL: http://www.spice-space.org/
+Source0: http://spice-space.org/download/releases/%{tarname}-%{version}.tar.bz2
+Source1: http://downloads.sourceforge.net/pyparsing/pyparsing-1.5.6.tar.gz
+
+%%CONFIGS%%
+
+%%PATCH_LIST%%
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+ExclusiveArch: x86_64
+
+BuildRequires: pkgconfig
+BuildRequires: gcc-c++
+BuildRequires: alsa-lib-devel
+BuildRequires: pixman-devel >= 0.18
+BuildRequires: libjpeg-devel
+BuildRequires: libXrandr-devel
+BuildRequires: libXext-devel
+BuildRequires: libXfixes-devel
+BuildRequires: openssl-devel
+BuildRequires: celt051-devel
+BuildRequires: libcacard-devel >= 0.1.2
+BuildRequires: spice-protocol >= 0.8.1
+BuildRequires: autoconf automake libtool
+BuildRequires: cyrus-sasl-devel
+
+Requires: pixman >= 0.18
+Requires: pkgconfig
+
+%package devel
+Summary: Header files, libraries and development documentation for %{name}
+Group: Development/Libraries
+
+Requires: %{name} = %{version}-%{release}
+Requires: alsa-lib-devel
+Requires: pixman-devel >= 0.18
+Requires: libjpeg-devel
+Requires: openssl-devel
+Requires: celt051-devel
+Requires: spice-protocol >= 0.8.1
+
+
+%description
+The Simple Protocol for Independent Computing Environments (SPICE) is
+a remote display system built for virtual environments which allows
+you to view a computing 'desktop' environment not only on the machine
+where it is running, but from anywhere on the Internet and from a wide
+variety of machine architectures.
+
+This package contains the runtime libraries for any application that wishes
+to be a SPICE server.
+
+%description devel
+This package contains the header files, static libraries and development
+documentation for %{name}. If you like to develop programs
+using %{name},you will need to install %{name}-devel.
+
+%prep
+%setup -q -n %{tarname}-%{version}
+# extract pyparsing. assumes: using python2, and that pyparsing remains a
+# single python source file named pyparsing_py2.py
+%setup -T -D -a 1 -n %{tarname}-%{version}
+cp pyparsing-1.5.6/pyparsing_py2.py pyparsing.py
+
+%%PATCH_APPLICATION%%
+
+%build
+#CFLAGS="%{optflags}"; CFLAGS="${CFLAGS/-Wall/}"; export CFLAGS;
+#CXXFLAGS="%{optflags}"; CXXFLAGS="${CXXFLAGS/-Wall/}"; export CXXFLAGS;
+#FFLAGS="%{optflags}"; FFLAGS="${FFLAGS/-Wall/}"; export FFLAGS;
+%configure --enable-smartcard --with-sasl
+#sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
+#sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
+make -C server %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make -C server install DESTDIR=$RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/%{_libdir}/pkgconfig
+install -m 00644 %{name}.pc $RPM_BUILD_ROOT/%{_libdir}/pkgconfig
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-, root, root, 0755)
+%doc COPYING README
+%{_libdir}/libspice-server.so.*
+
+%files devel
+%defattr(-, root, root, 0755)
+%doc COPYING README
+%{_includedir}/spice-server/
+%{_libdir}/libspice-server.so
+%{_libdir}/pkgconfig/spice-server.pc
+%exclude %{_libdir}/*.a
+%exclude %{_libdir}/*.la
+
+%changelog
+%%CHANGELOG%%
+* Mon Aug 01 2011 Uri Lublin <uril@redhat.com> - 0.8.2-3
+- Drop unnecessary X11 and alsa requires from spice-server.pc
+ + Fix a rpmdiff warning
+Related: rhbz#723676
+- server/red_dispatcher: fix wrong resolution set for tablet
+Resolves: rhbz#726973
+
+* Wed Jul 28 2011 Uri Lublin <uril@redhat.com> - 0.8.2-2
+- On migration, do not read command rings before RED_WORKER_MESSAGE_START
+Resolves: rhbz#718713
+
+* Fri Jul 22 2011 Uri Lublin <uril@redhat.com> - 0.8.2-1
+- Rebase to upstream 0.8.2, including
+ + sasl support (fdo bz 34795)
+ + support guest async io
+ + support guest suspend and hibernate
+ + add symbol versioning to libspice-server.so
+ + prevent running an old spice-server with a newer qemu
+ + Bug fixes (RHBZ): 714801, 713474, 674532, 653545
+ + BuildRequires spice-protocol >= 0.8.1 and cyrus-sasl-devel
+Resolves: #723676
+
+* Mon Jun 27 2011 Uri Lublin <uril@redhat.com> - 0.8.1-2
+- Remove Obsolete lines (added in 0.7.2-3)
+Resolves: #707119
+
+* Mon Jun 05 2011 Uri Lublin <uril@redhat.com> - 0.8.1-1
+- Rebase to upstream 0.8.1, including
+ + Make copy/paste support configurable
+ + Some server/vdagent bugs fixed
+Resolves: #710200
+
+* Mon Mar 07 2011 Uri Lublin <uril@redhat.com> - 0.8.0-1
+- Rebase to upstream 0.8.0
+ + Includes "Fix segfault on migration" patch
+ + Some spice-client bug fixes.
+Resolves: #672035
+
+* Mon Feb 21 2011 Uri Lublin <uril@redhat.com> - 0.7.3-2
+- Fix segfault on migration
+Resolves: #674451
+
+* Thu Feb 17 2011 Uri Lublin <uril@redhat.com> - 0.7.3-1
+- Rebase to upstream 0.7.3:
+ + Mostly smart-card updates:
+ - including all the changes in 0.7.2.4
+ + Some gcc warning cleanups.
+- Fix permissions of spice-server.pc
+Resolves: #672035
+
+* Fri Feb 04 2011 Uri Lublin <uril@redhat.com> - 0.7.2-4
+- smartcard -- libcacard 0.1.2 updates:
+ - server
+ - use network byte order when talking to device.
+ - both
+ - no more reader_id_t, uint32_t instead
+ - no more ReaderAddResponse, use VSC_Error with
+ code==VSC_SUCCESS instead.
+ - change an assert to a red_printf("error:..")
+ if got an unexpectedly undefined reader id.
+ - client (not part of this package)
+ - track number of expected reader insertions
+Resolves: #674937
+
+* Fri Feb 04 2011 Uri Lublin <uril@redhat.com> - 0.7.2-3
+- Obsolete old packages that are not needed now
+Resolves: #674171
+
+* Mon Jan 24 2011 Uri Lublin <uril@redhat.com> - 0.7.2-2
+- Rebase to spice upstream release 0.7.2
+- Drop all patches (all upstreamed)
+- Enable smartcard (CAC) support
+Resolves: #672035
+
+* Fri Jul 30 2010 Uri Lublin <uril@redhat.com> - 0.4.2-15
+ - Fix unsafe accesses
+ + fix unsafe guest data accessing.
+ + fix unsafe free() call.
+ + fix unsafe cursor items handling.
+ + add missing overflow check.
+Resolves: #568811
+
+* Wed Jun 30 2010 Uri Lublin <uril@redhat.com> - 0.4.2-14
+- make opengl optional - add a missing patch
+ ifdef out some opengl calls.
+Resolves: #482556
+
+* Wed Jun 30 2010 Uri Lublin <uril@redhat.com> - 0.4.2-13
+- remove Requires and BuildRequires mesa-libGLU-devel
+ + open-gl is now disabled.
+- bumped release to -13 due to tag issue
+Related: #482556
+
+* Wed Jun 30 2010 Uri Lublin <uril@redhat.com> - 0.4.2-11
+- make opengl optional, disabled by default (2 patches)
+Resolves: #482556
+
+* Thu Apr 22 2010 Uri Lublin <uril@redhat.com> - 0.4.2-10
+- spice: server: new-api (4 more patches)
+ + streaming-video, agent-mouse, playback-compression.
+Related: #571286
+
+* Sun Apr 4 2010 Uri Lublin <uril@redhat.com> - 0.4.2-9
+ - generate auto* generated files (e.g. Makefile.in)
+Resolves: #579329
+
+* Tue Mar 23 2010 Uri Lublin <uril@redhat.com> - 0.4.2-8
+ - spice server: renaming library and includedir
+Resolves: #573349
+
+* Tue Mar 23 2010 Uri Lublin <uril@redhat.com> - 0.4.2-7
+ - fix wrong access to ring item
+Resolves: #575556
+
+* Tue Mar 23 2010 Uri Lublin <uril@redhat.com> - 0.4.2-6
+ - more permissive video identification
+Resolves: #575576
+
+* Tue Mar 23 2010 Uri Lublin <uril@redhat.com> - 0.4.2-5
+ - new migration process
+Resolves: #576029
+
+* Wed Mar 17 2010 Uri Lublin <uril@redhat.com> - 0.4.2-4
+- spice: server: new-api (2 more patches)
+Related: #571286
+
+* Mon Mar 7 2010 Uri Lublin <uril@redhat.com> - 0.4.2-3
+ - Use default configure macro (remove _prefix and _libdir)
+Related: #543948
+
+* Sun Mar 07 2010 Uri Lublin <uril@redhat.com> - 0.4.2-2
+- spice: server: new-api (10 patches)
+Related: #571286
+
+* Sun Mar 07 2010 Uri Lublin <uril@redhat.com> - 0.4.2-1
+- spice: server: avoid video streaming of small images
+Resolves: #571283
+
+* Mon Jan 11 2009 Uri Lublin <uril@redhat.com> - 0.4.2-0
+ - first spec for 0.4.2
+Related: #549807