diff options
Diffstat (limited to 'mk')
51 files changed, 1303 insertions, 0 deletions
diff --git a/mk/Citrix.repo b/mk/Citrix.repo new file mode 100644 index 0000000..b55385d --- /dev/null +++ b/mk/Citrix.repo @@ -0,0 +1,7 @@ +[citrix] +name=@PRODUCT_BRAND@ @PRODUCT_VERSION@ updates for @DISTRO@ +mirrorlist=http://updates.vmd.citrix.com/@PRODUCT_BRAND@/@PRODUCT_VERSION@/@DISTRO@/mirrorlist +#baseurl=http://updates.vmd.citrix.com/@PRODUCT_BRAND@/@PRODUCT_VERSION@/@DISTRO@/ +gpgcheck=1 +gpgkey=http://updates.vmd.citrix.com/@PRODUCT_BRAND@/RPM-GPG-KEY-@PRODUCT_VERSION@ +enabled=1 diff --git a/mk/Makefile b/mk/Makefile new file mode 100644 index 0000000..2767384 --- /dev/null +++ b/mk/Makefile @@ -0,0 +1,11 @@ +ifeq ($(COMPONENT),guest-utilities-rpm) +include Makefile.rpm +endif + +ifeq ($(COMPONENT),guest-utilities-deb) +include Makefile.deb +endif + +ifeq ($(COMPONENT),guest-utilities-tgz) +include Makefile.tgz +endif diff --git a/mk/Makefile.deb b/mk/Makefile.deb new file mode 100644 index 0000000..3b0617b --- /dev/null +++ b/mk/Makefile.deb @@ -0,0 +1,172 @@ +# -*- makefile -*- +USE_BRANDING := yes +IMPORT_VERSIONS := yes +include $(B_BASE)/common.mk + +REPO= $(call git_loc,xe-guest-utilities) +REPOSTAMP= $(call git_req,xe-guest-utilities) + +ARCHS = i386 amd64 +DISTROS = lenny + +DEB_BUILT_COOKIE = $(MY_OBJ_DIR)/.deb_built_cookie +DEB_REPO_COOKIE = $(MY_OBJ_DIR)/.deb_%_repo_cookie +DEB_REPO_COOKIES = $(DISTROS:%=$(DEB_REPO_COOKIE)) + +STAGING_DIR = $(MY_OBJ_DIR)/staging +INSTALL_DIR = $(STAGING_DIR)/Linux/ +VERSIONS_FILE = $(MY_OBJ_DIR)/versions +TOOLS_TARBALL = $(MY_OUTPUT_DIR)/tools-files.tar.bz2 + + +PACKAGE = xe-guest-utilities +VERSION = $(PRODUCT_VERSION) +RELEASE := $(shell git --git-dir="$(REPO)/.git" rev-list HEAD | wc -l) + +SOURCEDIR := $(MY_OBJ_DIR)/$(PACKAGE)-$(VERSION)/ +DEBIANDIR := $(SOURCEDIR)/debian/ + +DEBPOOLDIR := debian/pool/main/x/xe-guest-utilities + +GOTARBALL = /distfiles/golang/go1.4.2.linux-386.tar.gz +GOROOT = $(MY_OBJ_DIR)/go +GOBIN = GOROOT=$(GOROOT) $(GOROOT)/bin/go +GOFLAGS = -a -x +GOBUILDDIR = $(MY_OBJ_DIR)/gobuild +GO_SOURCE_REPO = $(call git_loc,xe-guest-utilities) + +XE_DAEMON_GO_SOURCES := +XE_DAEMON_GO_SOURCES += ./xe-daemon/xe-daemon.go # this should be the first one +XE_DAEMON_GO_SOURCES += ./guestmetric/guestmetric.go +XE_DAEMON_GO_SOURCES += ./guestmetric/guestmetric_linux.go +XE_DAEMON_GO_SOURCES += ./xenstoreclient/xenstore.go + +XENSTORE_GO_SOURCES := +XENSTORE_GO_SOURCES += ./xenstore/xenstore.go # this should be the first one +XENSTORE_GO_SOURCES += ./xenstoreclient/xenstore.go + +SOURCES := +SOURCES += $(SOURCEDIR)/xe-linux-distribution +SOURCES += $(SOURCEDIR)/xe-daemon +SOURCES += $(SOURCEDIR)/xenstore +SOURCES += $(SOURCEDIR)/LICENSE +SOURCES += $(SOURCEDIR)/citrix.list +SOURCES += $(SOURCEDIR)/xen-vcpu-hotplug.rules +SOURCES += $(DEBIANDIR)/xe-linux-distribution.init +SOURCES += $(DEBIANDIR)/xe-guest-utilities.postinst +SOURCES += $(DEBIANDIR)/xe-guest-utilities.prerm +SOURCES += $(DEBIANDIR)/control +SOURCES += $(DEBIANDIR)/changelog +SOURCES += $(DEBIANDIR)/rules +SOURCES += $(DEBIANDIR)/compat +SOURCES += $(DEBIANDIR)/copyright +SOURCES += $(DEBIANDIR)/$(PACKAGE).dirs + +822_DATE := $(shell date -R) + +.PHONY: build +build: $(TOOLS_TARBALL) $(DEB_BUILT_COOKIE) $(DEB_REPO_COOKIES) $(ARCHS:%=$(MY_OUTPUT_DIR)/xe-guest-utilities.%.inc) $(MY_SOURCES)/MANIFEST + @ : + +.PHONY: clean +clean: + rm -f $(DEB_BUILT_COOKIE) + rm -f $(DEB_REPO_COOKIES) + rm -rf $(GOROOT) + rm -rf $(SOURCEDIR) + rm -rf $(DEBIANDIR) + rm -f $(MY_OBJ_DIR)/overrides + +local-brand := sed -e 's,@VERSION@,$(VERSION),g' \ + -e 's,@RELEASE@,$(RELEASE),g' \ + -e "s!@822DATE@!$(822_DATE)!g" + +$(DEBIANDIR)/%: $(REPO)/% + mkdir -p $(DEBIANDIR) + $(call brand,$<) | $(call local-brand) > $@ + +$(DEBIANDIR)/xe-linux-distribution.init: $(REPO)/mk/xe-linux-distribution.init + mkdir -p $(DEBIANDIR) + $(call brand,$<) | $(call local-brand) > $@ + +$(SOURCEDIR)/%: $(REPO)/mk/% + mkdir -p $(SOURCEDIR) + $(call brand,$<) | $(call local-brand) > $@ + +$(SOURCEDIR)/citrix.list: citrix.list + $(call brand,$<) > $@ + +$(SOURCEDIR)/xe-daemon: $(XE_DAEMON_GO_SOURCES:%=$(REPO)/%) $(GOROOT) + $(GOBIN) build $(GOFLAGS) -o $@ $< + +$(SOURCEDIR)/xenstore: $(XENSTORE_GO_SOURCES:%=$(REPO)/%) $(GOROOT) + $(GOBIN) build $(GOFLAGS) -o $@ $< + +$(SOURCEDIR)/LICENSE: $(REPO)/LICENSE + $(call brand,$<) > $@ + +$(GOBUILDDIR)/%: $(GO_SOURCE_REPO)/% + mkdir -p $$(dirname $@) + $(call brand,$<) > $@ + +$(MY_OUTPUT_DIR)/xe-guest-utilities.%.inc: $(MY_OUTPUT_DIR)/.dirstamp + ( echo XE_GUEST_UTILITIES_PKG_NAME := xe-guest-utilities ; \ + echo XE_GUEST_UTILITIES_PKG_VERSION := $(VERSION)-$(RELEASE) ; \ + echo XE_GUEST_UTILITIES_PKG_ARCH := $* ; \ + echo XE_GUEST_UTILITIES_PKG_FILE := $(DEBPOOLDIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_all.deb ; \ + )>$@ + +$(DEB_BUILT_COOKIE): $(SOURCES) + mkdir -p $(MY_OUTPUT_DIR)/$(DEBPOOLDIR) + chmod +x $(DEBIANDIR)/rules + cd $(SOURCEDIR) && dpkg-buildpackage -Zgzip -S -us -uc + cp $(MY_OBJ_DIR)/$(PACKAGE)_$(VERSION)-$(RELEASE).dsc $(MY_OUTPUT_DIR)/$(DEBPOOLDIR) + cp $(MY_OBJ_DIR)/$(PACKAGE)_$(VERSION)-$(RELEASE).tar.gz $(MY_OUTPUT_DIR)/$(DEBPOOLDIR) + set -xe ; for arch in $(ARCHS) ; do \ + ( cd $(SOURCEDIR) && dpkg-buildpackage -Zgzip -b -a$${arch} -us -uc ) ; \ + cp $(MY_OBJ_DIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_all.deb $(MY_OUTPUT_DIR)/$(DEBPOOLDIR) ; \ + done + touch $@ + +$(MY_SOURCES)/MANIFEST: $(MY_SOURCES_DIRSTAMP) + ( echo "$(COMPONENT) BSD file $(MY_OUTPUT_DIR)/$(DEBPOOLDIR)/$(PACKAGE)_$(VERSION)-$(RELEASE).dsc" ; \ + echo "$(COMPONENT) BSD file $(MY_OUTPUT_DIR)/$(DEBPOOLDIR)/$(PACKAGE)_$(VERSION)-$(RELEASE).tar.gz" ; \ + ) >$@ + +.PHONY: sources +sources: $(MY_SOURCES)/MANIFEST + @ : + +$(MY_OBJ_DIR)/overrides: + echo xe-guest-utilities optional base >$@ + +$(DEB_REPO_COOKIE): $(DEB_BUILT_COOKIE) $(MY_OBJ_DIR)/overrides + mkdir -p $(MY_OUTPUT_DIR)/$(DEBPOOLDIR) + cp -La $(MY_OBJ_DIR)/*.deb $(MY_OUTPUT_DIR)/$(DEBPOOLDIR) + set -ex ; for arch in $(ARCHS) ; do \ + bindir=debian/dists/$*/main/binary-$${arch} ; \ + mkdir -p $(MY_OUTPUT_DIR)/$${bindir} ; \ + ( cd $(MY_OUTPUT_DIR)/debian/ && \ + dpkg-scanpackages -a$${arch} pool $(MY_OBJ_DIR)/overrides \ + ) > $(MY_OUTPUT_DIR)/$${bindir}/Packages ; \ + done + mkdir -p $(MY_OUTPUT_DIR)/debian/dists/$*/main/source + ( cd $(MY_OUTPUT_DIR)/debian/ && \ + dpkg-scansources pool \ + ) > $(MY_OUTPUT_DIR)/debian/dists/$*/main/source/Sources + touch $@ + +# package up in a tools tarball so it gets on the ISO +$(TOOLS_TARBALL): $(DEB_BUILT_COOKIE) + mkdir -p $(INSTALL_DIR) + rm -f $(INSTALL_DIR)/versions.deb + $(foreach arch,$(ARCHS),\ + echo XE_GUEST_UTILITIES_PKG_FILE_$(arch)=\'xe-guest-utilities_$(VERSION)-$(RELEASE)_all.deb\' >> $(INSTALL_DIR)/versions.deb ; cp -v $(MY_OBJ_DIR)/xe-guest-utilities_$(VERSION)-$(RELEASE)_all.deb $(INSTALL_DIR)/ ;) + tar -C $(STAGING_DIR) -cjf $@ . + +$(GOROOT): + mkdir -p $(GOROOT) + ( cd $(GOROOT)/.. ; \ + tar xf $(GOTARBALL) ;\ + ) + diff --git a/mk/Makefile.rpm b/mk/Makefile.rpm new file mode 100644 index 0000000..5cdedcb --- /dev/null +++ b/mk/Makefile.rpm @@ -0,0 +1,128 @@ +# -*- makefile -*- +USE_BRANDING := yes +IMPORT_VERSIONS := yes +include $(B_BASE)/common.mk + +RPM_LOCAL_RPMBUILD_OPTIONS := -D '_source_payload w9.gzdio' -D '_binary_payload w9.gzdio' \ + -D '_source_filedigest_algorithm 0' -D '_binary_filedigest_algorithm 0' +include $(B_BASE)/rpmbuild.mk + +RPM_BUILT_COOKIE = $(MY_OBJ_DIR)/.rpm_built_cookie + +REPO= $(call git_loc,xe-guest-utilities) +REPOSTAMP= $(call git_req,xe-guest-utilities) + +STAGING_DIR = $(MY_OBJ_DIR)/staging +INSTALL_DIR = $(STAGING_DIR)/Linux/ +VERSIONS_FILE = $(MY_OBJ_DIR)/versions + +ARCHS = i386 x86_64 + +VERSION = $(PRODUCT_VERSION) +RELEASE := $(shell git --git-dir="$(REPO)/.git" rev-list HEAD | wc -l) + +SPEC= xe-guest-utilities.spec +SRPM= xe-guest-utilities-$(VERSION)-$(RELEASE).src.rpm + +GOTARBALL = /distfiles/golang/go1.4.2.linux-386.tar.gz +GOROOT = $(MY_OBJ_DIR)/go +GOBIN = GOROOT=$(GOROOT) $(GOROOT)/bin/go +GOFLAGS = -a -x +GOBUILDDIR = $(MY_OBJ_DIR)/gobuild + +GO_SOURCE_REPO = $(call git_loc,xe-guest-utilities) + +XE_DAEMON_GO_SOURCES := +XE_DAEMON_GO_SOURCES += ./xe-daemon/xe-daemon.go # this should be the first one +XE_DAEMON_GO_SOURCES += ./guestmetric/guestmetric.go +XE_DAEMON_GO_SOURCES += ./guestmetric/guestmetric_linux.go +XE_DAEMON_GO_SOURCES += ./xenstoreclient/xenstore.go + +XENSTORE_GO_SOURCES := +XENSTORE_GO_SOURCES += ./xenstore/xenstore.go # this should be the first one +XENSTORE_GO_SOURCES += ./xenstoreclient/xenstore.go + +SOURCES := +SOURCES += $(RPM_SOURCESDIR)/xe-linux-distribution +SOURCES += $(RPM_SOURCESDIR)/xe-linux-distribution.init +SOURCES += $(RPM_SOURCESDIR)/xe-daemon +SOURCES += $(RPM_SOURCESDIR)/xenstore + +SOURCES += $(RPM_SOURCESDIR)/Citrix.repo +SOURCES += $(RPM_SOURCESDIR)/xen-vcpu-hotplug.rules +SOURCES += $(RPM_SOURCESDIR)/LICENSE + +TOOLS_TARBALL = $(MY_OUTPUT_DIR)/tools-files.tar.bz2 + +.PHONY: build +build: $(RPM_BUILT_COOKIE) $(RPM_DIRECTORIES) $(TOOLS_TARBALL) $(ARCHS:%=$(MY_OUTPUT_DIR)/xe-guest-utilities.%.inc) $(MY_SOURCES)/MANIFEST + @ : + +.PHONY: clean +clean: + rm -f $(RPM_SPECSDIR)/$(SPEC) + rm -rf $(RPM_BUILDDIR) $(RPM_SOURCESDIR) $(RPM_SPECSDIR) + rm -f $(RPM_BUILT_COOKIE) + rm -rf $(GOROOT) + rm -rf $(DESTDIR) + +$(RPM_SPECSDIR)/$(SPEC): $(SPEC).in + $(call brand,$<) | \ + sed -e 's,@VERSION@,$(VERSION),g' \ + -e 's,@RELEASE@,$(RELEASE),g' \ + > $@ + +$(MY_OUTPUT_DIR)/xe-guest-utilities.%.inc: $(MY_OUTPUT_DIR)/.dirstamp + ( echo XE_GUEST_UTILITIES_PKG_NAME := xe-guest-utilities ; \ + echo XE_GUEST_UTILITIES_PKG_VERSION := $(VERSION)-$(RELEASE) ; \ + echo XE_GUEST_UTILITIES_PKG_ARCH := $* ; \ + echo XE_GUEST_UTILITIES_PKG_FILE := RPMS/$*/xe-guest-utilities-$(VERSION)-$(RELEASE).$*.rpm ; \ + )>$@ + +$(RPM_BUILT_COOKIE): $(RPM_DIRECTORIES) $(RPM_SPECSDIR)/$(SPEC) $(SOURCES) + $(RPMBUILD) -bs $(RPM_SPECSDIR)/$(SPEC) + set -ex ; for arch in $(ARCHS) ; do \ + $(RPMBUILD) --target=$${arch} --rebuild $(RPM_SRPMSDIR)/$(SRPM) ; \ + done + +$(MY_SOURCES)/MANIFEST: $(MY_SOURCES_DIRSTAMP) + ( echo "$(COMPONENT) BSD file $(RPM_SRPMSDIR)/$(SRPM)" ; \ + ) >$@ + +.PHONY: sources +sources: $(MY_SOURCES)/MANIFEST + @ : + +$(RPM_SOURCESDIR)/%: $(REPO)/mk/% + mkdir -p $(RPM_SOURCESDIR) + $(call brand,$<) > $@ + +$(RPM_SOURCESDIR)/xe-daemon: $(XE_DAEMON_GO_SOURCES:%=$(REPO)/%) $(GOROOT) + $(GOBIN) build $(GOFLAGS) -o $@ $< + +$(RPM_SOURCESDIR)/xenstore: $(XENSTORE_GO_SOURCES:%=$(REPO)/%) $(GOROOT) + $(GOBIN) build $(GOFLAGS) -o $@ $< + +$(RPM_SOURCESDIR)/LICENSE: $(REPO)/LICENSE + $(call brand,$<) > $@ + +$(GOBUILDDIR)/%: $(GO_SOURCE_REPO)/% + mkdir -p $$(dirname $@) + $(call brand,$<) > $@ + +$(TOOLS_TARBALL): $(RPM_BUILT_COOKIE) + mkdir -p $(INSTALL_DIR) + rm -f $(INSTALL_DIR)/versions.rpm + $(foreach arch,$(ARCHS),\ + echo XE_GUEST_UTILITIES_PKG_FILE_$(arch)=\'xe-guest-utilities-$(VERSION)-$(RELEASE).$(arch).rpm xe-guest-utilities-xenstore-$(VERSION)-$(RELEASE).$(arch).rpm\' >> $(INSTALL_DIR)/versions.rpm ;\ + cp -v $(MY_OUTPUT_DIR)/RPMS/$(arch)/xe-guest-utilities-$(VERSION)-$(RELEASE).$(arch).rpm $(INSTALL_DIR)/ ;\ + cp -v $(MY_OUTPUT_DIR)/RPMS/$(arch)/xe-guest-utilities-xenstore-$(VERSION)-$(RELEASE).$(arch).rpm $(INSTALL_DIR)/ ;\ + ) + tar -C $(STAGING_DIR) -cjf $@ . + +$(GOROOT): + mkdir -p $(GOROOT) + ( cd $(GOROOT)/.. ; \ + tar xf $(GOTARBALL) ;\ + ) + diff --git a/mk/Makefile.tgz b/mk/Makefile.tgz new file mode 100644 index 0000000..e710224 --- /dev/null +++ b/mk/Makefile.tgz @@ -0,0 +1,143 @@ +# -*- makefile -*- +USE_BRANDING := yes +IMPORT_VERSIONS := yes +include $(B_BASE)/common.mk + +REPO= $(call git_loc,xe-guest-utilities) +REPOSTAMP= $(call git_req,xe-guest-utilities) + +ARCHS = i386 amd64 +DISTROS = linux + +TGZ_BUILT_COOKIE = $(MY_OBJ_DIR)/.tgz_built_cookie +TGZ_REPO_COOKIE = $(MY_OBJ_DIR)/.tgz_%_repo_cookie +TGZ_REPO_COOKIES = $(DISTROS:%=$(TGZ_REPO_COOKIE)) + +STAGING_DIR = $(MY_OBJ_DIR)/staging +INSTALL_DIR = $(STAGING_DIR)/Linux/ +VERSIONS_FILE = $(MY_OBJ_DIR)/versions +TOOLS_TARBALL = $(MY_OUTPUT_DIR)/tools-files.tar.bz2 + + +PACKAGE = xe-guest-utilities +VERSION = $(PRODUCT_VERSION) +RELEASE := $(shell git --git-dir="$(REPO)/.git" rev-list HEAD | wc -l) + +SOURCEDIR := $(MY_OBJ_DIR)/$(PACKAGE)-$(VERSION)/ +DESTDIR := $(MY_OBJ_DIR)/$(PACKAGE)/ + + +GOTARBALL = /distfiles/golang/go1.4.2.linux-386.tar.gz +GOROOT = $(MY_OBJ_DIR)/go +GOBIN = GOROOT=$(GOROOT) $(GOROOT)/bin/go +GOFLAGS = -a -x +GOBUILDDIR = $(MY_OBJ_DIR)/gobuild + +GO_SOURCE_REPO = $(call git_loc,xe-guest-utilities) + +XE_DAEMON_GO_SOURCES := +XE_DAEMON_GO_SOURCES += ./xe-daemon/xe-daemon.go # this should be the first one +XE_DAEMON_GO_SOURCES += ./guestmetric/guestmetric.go +XE_DAEMON_GO_SOURCES += ./guestmetric/guestmetric_linux.go +XE_DAEMON_GO_SOURCES += ./xenstoreclient/xenstore.go + +XENSTORE_GO_SOURCES := +XENSTORE_GO_SOURCES += ./xenstore/xenstore.go # this should be the first one +XENSTORE_GO_SOURCES += ./xenstoreclient/xenstore.go + +SOURCES := +SOURCES += $(REPO)/LICENSE +SOURCES += $(SOURCEDIR)/xe-linux-distribution +SOURCES += $(SOURCEDIR)/xe-linux-distribution.init +SOURCES += $(SOURCEDIR)/xe-daemon +SOURCES += $(SOURCEDIR)/xenstore +SOURCES += $(SOURCEDIR)/citrix.list +SOURCES += $(SOURCEDIR)/xen-vcpu-hotplug.rules + +822_DATE := $(shell date -R) + +.PHONY: build +build: $(TOOLS_TARBALL) $(TGZ_BUILT_COOKIE) $(TGZ_REPO_COOKIES) $(ARCHS:%=$(MY_OUTPUT_DIR)/xe-guest-utilities.%.inc) $(MY_SOURCES)/MANIFEST + @ : + +.PHONY: clean +clean: + rm -f $(TGZ_BUILT_COOKIE) + rm -f $(TGZ_REPO_COOKIES) + rm -rf $(GOROOT) + rm -rf $(SOURCEDIR) + rm -rf $(DESTDIR) + +local-brand := sed -e 's,@VERSION@,$(VERSION),g' \ + -e 's,@RELEASE@,$(RELEASE),g' \ + -e "s!@822DATE@!$(822_DATE)!g" + +$(SOURCEDIR)/%: $(REPO)/mk/% + mkdir -p $(SOURCEDIR) + $(call brand,$<) | $(call local-brand) > $@ + +$(SOURCEDIR)/citrix.list: citrix.list + $(call brand,$<) > $@ + +$(SOURCEDIR)/xe-daemon: $(XE_DAEMON_GO_SOURCES:%=$(REPO)/%) $(GOROOT) + $(GOBIN) build $(GOFLAGS) -o $@ $< + +$(SOURCEDIR)/xenstore: $(XENSTORE_GO_SOURCES:%=$(REPO)/%) $(GOROOT) + $(GOBIN) build $(GOFLAGS) -o $@ $< + +$(GOBUILDDIR)/%: $(GO_SOURCE_REPO)/% + mkdir -p $$(dirname $@) + $(call brand,$<) > $@ + +$(MY_OUTPUT_DIR)/xe-guest-utilities.%.inc: $(MY_OUTPUT_DIR)/.dirstamp + ( echo XE_GUEST_UTILITIES_PKG_NAME := xe-guest-utilities ; \ + echo XE_GUEST_UTILITIES_PKG_VERSION := $(VERSION)-$(RELEASE) ; \ + echo XE_GUEST_UTILITIES_PKG_ARCH := $* ; \ + echo XE_GUEST_UTILITIES_PKG_FILE := $(MY_OBJ_DIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_all.tgz ; \ + )>$@ + +$(TGZ_BUILT_COOKIE): $(SOURCES) + ( cd $(SOURCEDIR) ; \ + install -d $(DESTDIR)/etc/init.d/ ; \ + install -m 755 xe-linux-distribution.init $(DESTDIR)/etc/init.d/xe-linux-distribution ; \ + install -d $(DESTDIR)/usr/sbin/ ; \ + install -m 755 xe-linux-distribution $(DESTDIR)/usr/sbin/xe-linux-distribution ; \ + install -m 755 xe-daemon $(DESTDIR)/usr/sbin/xe-daemon ; \ + install -d $(DESTDIR)/usr/bin/ ; \ + install -m 755 xenstore $(DESTDIR)/usr/bin/xenstore ; \ + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-read ; \ + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-write ; \ + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-exists ; \ + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-rm ; \ + install -d $(DESTDIR)/etc/udev/rules.d/ ; \ + install -m 644 xen-vcpu-hotplug.rules $(DESTDIR)/etc/udev/rules.d/z10_xen-vcpu-hotplug.rules ; \ + install -d $(DESTDIR)/usr/share/doc/$(PACKAGE)_$(VERSION)/ ; \ + install -m 644 $(REPO)/LICENSE $(DESTDIR)/usr/share/doc/$(PACKAGE)_$(VERSION)/LICENSE ; \ + cd $(DESTDIR) ; \ + tar cvf $(MY_OBJ_DIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_all.tgz * \ + )>$@ + +$(MY_SOURCES)/MANIFEST: $(MY_SOURCES_DIRSTAMP) + echo >$@ + +.PHONY: sources +sources: $(MY_SOURCES)/MANIFEST + @ : + +$(TGZ_REPO_COOKIE): $(TGZ_BUILT_COOKIE) + touch $@ + +# package up in a tools tarball so it gets on the ISO +$(TOOLS_TARBALL): $(TGZ_BUILT_COOKIE) + mkdir -p $(INSTALL_DIR) + rm -f $(INSTALL_DIR)/versions.tgz + $(foreach arch,$(ARCHS),\ + echo XE_GUEST_UTILITIES_PKG_FILE_$(arch)=\'xe-guest-utilities_$(VERSION)-$(RELEASE)_all.tgz\' >> $(INSTALL_DIR)/versions.tgz ; cp -v $(MY_OBJ_DIR)/xe-guest-utilities_$(VERSION)-$(RELEASE)_all.tgz $(INSTALL_DIR)/ ;) + tar -C $(STAGING_DIR) -cjf $@ . + +$(GOROOT): + mkdir -p $(GOROOT) + ( cd $(GOROOT)/.. ; \ + tar xf $(GOTARBALL) ;\ + ) + diff --git a/mk/citrix.list b/mk/citrix.list new file mode 100644 index 0000000..3dbc4f5 --- /dev/null +++ b/mk/citrix.list @@ -0,0 +1,2 @@ +deb http://updates.vmd.citrix.com/@PRODUCT_BRAND@/@PRODUCT_VERSION@/debian/ @DISTRO@ main +deb-src http://updates.vmd.citrix.com/@PRODUCT_BRAND@/@PRODUCT_VERSION@/debian/ @DISTRO@ main diff --git a/mk/debian/changelog b/mk/debian/changelog new file mode 100644 index 0000000..c348f51 --- /dev/null +++ b/mk/debian/changelog @@ -0,0 +1,5 @@ +xe-guest-utilities (@VERSION@-@RELEASE@) etch; urgency=low + + * Build for @PRODUCT_NAME@ @PRODUCT_VERSION@-@BUILD_NUMBER@. + + -- @COMPANY_NAME_LEGAL@ <www.citrix.com> @822DATE@ diff --git a/mk/debian/compat b/mk/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/mk/debian/compat @@ -0,0 +1 @@ +5 diff --git a/mk/debian/control b/mk/debian/control new file mode 100644 index 0000000..4ffdb45 --- /dev/null +++ b/mk/debian/control @@ -0,0 +1,15 @@ +Source: xe-guest-utilities +Section: main/admin +Priority: optional +Maintainer: Citrix Systems, Inc. <www.citrix.com> +Standards-Version: 3.7.2 +Build-Depends: debhelper (>= 4.0.0) + +Package: xe-guest-utilities +Architecture: all +Conflicts: xengmond +Replaces: xengmond +Description: @BRAND_GUEST@ Monitoring Scripts + Scripts for monitoring @BRAND_GUESTS@. + . + Writes distribution version information and IP address to XenStore. diff --git a/mk/debian/copyright b/mk/debian/copyright new file mode 100644 index 0000000..0e9cb3d --- /dev/null +++ b/mk/debian/copyright @@ -0,0 +1 @@ +See the LICENSE file in the /usr/share/doc/xe-guest-utilities diff --git a/mk/debian/overrides b/mk/debian/overrides new file mode 100644 index 0000000..e1ed710 --- /dev/null +++ b/mk/debian/overrides @@ -0,0 +1 @@ +xengmond optional non-free/admin diff --git a/mk/debian/rules b/mk/debian/rules new file mode 100644 index 0000000..061411d --- /dev/null +++ b/mk/debian/rules @@ -0,0 +1,55 @@ +#!/usr/bin/make -f + +build: build-stamp +build-stamp: + touch $@ + +clean: + dh_testdir + dh_testroot + + dh_clean + +binary: binary-arch binary-indep + +binary-arch: DESTDIR=debian/xe-guest-utilities +binary-arch: build + dh_testdir + dh_testroot + + dh_clean -k + + dh_installdirs + + cp xe-linux-distribution $(DESTDIR)/usr/sbin/xe-linux-distribution + chmod 0755 $(DESTDIR)/usr/sbin/xe-linux-distribution + + install -d $(DESTDIR)/usr/bin/ + install -m 755 xenstore $(DESTDIR)/usr/bin/xenstore + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-read + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-write + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-exists + ln -s /usr/bin/xenstore $(DESTDIR)/usr/bin/xenstore-rm + + cp xe-daemon $(DESTDIR)/usr/sbin/xe-daemon + chmod 0755 $(DESTDIR)/usr/sbin/xe-daemon + + cp xen-vcpu-hotplug.rules $(DESTDIR)/lib/udev/rules.d/z10_xen-vcpu-hotplug.rules + + dh_installinit --name xe-linux-distribution + + dh_install citrix.list /usr/share/xe-guest-utilities + + dh_installdocs LICENSE + + dh_strip + dh_compress + dh_fixperms + dh_makeshlibs + dh_shlibdeps + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-indep: diff --git a/mk/debian/xe-guest-utilities.dirs b/mk/debian/xe-guest-utilities.dirs new file mode 100644 index 0000000..f7cc935 --- /dev/null +++ b/mk/debian/xe-guest-utilities.dirs @@ -0,0 +1,3 @@ +etc/init.d +lib/udev/rules.d +usr/sbin diff --git a/mk/debian/xe-guest-utilities.postinst b/mk/debian/xe-guest-utilities.postinst new file mode 100755 index 0000000..208aaa0 --- /dev/null +++ b/mk/debian/xe-guest-utilities.postinst @@ -0,0 +1,20 @@ +#!/bin/sh + +#DEBHELPER# + +if [ X"$1" = X"configure" ] ; then + eval $(/usr/sbin/xe-linux-distribution) + if [ -d /etc/apt/sources.list.d ] && [ X"${os_distro}" = X"debian" ] \ + && [ -n "${os_majorver}" ] && [ -n "${os_minorver}" ] ; then + case "${os_majorver}${os_minorver}" in + 50) distro="lenny" ;; + *) ;; + esac + if [ -n "${distro}" ] ; then + rm -f /etc/apt/sources.list.d/xensource.list # contains deprecated urls + sed -e "s/@DISTRO@/${distro}/g" \ + < /usr/share/xe-guest-utilities/citrix.list \ + > /etc/apt/sources.list.d/citrix.list + fi + fi +fi diff --git a/mk/debian/xe-guest-utilities.prerm b/mk/debian/xe-guest-utilities.prerm new file mode 100755 index 0000000..68f2184 --- /dev/null +++ b/mk/debian/xe-guest-utilities.prerm @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ X"$1" = X"remove" ] && [ -e /etc/apt/sources.list.d/citrix.list ] ; then + rm /etc/apt/sources.list.d/citrix.list +fi + +#DEBHELPER# diff --git a/mk/testcases/centos4 b/mk/testcases/centos4 new file mode 100644 index 0000000..34c6a8a --- /dev/null +++ b/mk/testcases/centos4 @@ -0,0 +1 @@ +CentOS release 4.0 (Final) diff --git a/mk/testcases/centos5 b/mk/testcases/centos5 new file mode 100644 index 0000000..e1d8ca0 --- /dev/null +++ b/mk/testcases/centos5 @@ -0,0 +1 @@ +CentOS release 5 (Final) diff --git a/mk/testcases/ddk-0.5.6-2991c b/mk/testcases/ddk-0.5.6-2991c new file mode 100644 index 0000000..1151864 --- /dev/null +++ b/mk/testcases/ddk-0.5.6-2991c @@ -0,0 +1 @@ +Rio DDK release 0.5.6-2991c (xenenterprise) diff --git a/mk/testcases/debian-sarge b/mk/testcases/debian-sarge new file mode 100644 index 0000000..8c50098 --- /dev/null +++ b/mk/testcases/debian-sarge @@ -0,0 +1 @@ +3.1 diff --git a/mk/testcases/debian-sid b/mk/testcases/debian-sid new file mode 100644 index 0000000..9ded89b --- /dev/null +++ b/mk/testcases/debian-sid @@ -0,0 +1 @@ +lenny/sid diff --git a/mk/testcases/fc3 b/mk/testcases/fc3 new file mode 100644 index 0000000..a42cc82 --- /dev/null +++ b/mk/testcases/fc3 @@ -0,0 +1 @@ +Fedora Core release 3 (Heidelberg) diff --git a/mk/testcases/lsb b/mk/testcases/lsb new file mode 100755 index 0000000..c691772 --- /dev/null +++ b/mk/testcases/lsb @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +if [ $1 != "--short" ] ; then + echo "Invalid parameter: $1" 1>&2 + exit 1 +fi + +if [ ! -f "${TESTCASE}" ] ; then + echo "Testcase ${TESTCASE} not found" 1>&2 + exit 1 +fi + +case $(basename ${TESTCASE}) in + lsb-*) ;; + *) exit 1 +esac + +. ${TESTCASE} + +if [ -z "$ID" ] ; then + ID="$DISTRIB_ID" +fi +if [ -z "$DESCRIPTION" ] ; then + DESCRIPTION="$DISTRIB_DESCRIPTION" +fi +if [ -z "$RELEASE" ] ; then + RELEASE="$DISTRIB_RELEASE" +fi + +case $2 in + --id) echo ${ID} ;; + --description) echo ${DESCRIPTION} ;; + --release) echo ${RELEASE} ;; + *) + echo "Invalid paramter: $2" 1>&2 + exit 1;; +esac + +exit 0 diff --git a/mk/testcases/lsb-coreos-367.1.0 b/mk/testcases/lsb-coreos-367.1.0 new file mode 100644 index 0000000..b5ebcc7 --- /dev/null +++ b/mk/testcases/lsb-coreos-367.1.0 @@ -0,0 +1,4 @@ +DISTRIB_ID=CoreOS +DISTRIB_RELEASE=367.1.0 +DISTRIB_CODENAME="Red Dog" +DISTRIB_DESCRIPTION="CoreOS 367.1.0"
\ No newline at end of file diff --git a/mk/testcases/lsb-ubuntu-6.10 b/mk/testcases/lsb-ubuntu-6.10 new file mode 100644 index 0000000..5a6f488 --- /dev/null +++ b/mk/testcases/lsb-ubuntu-6.10 @@ -0,0 +1,3 @@ +ID="Ubuntu" +DESCRPITON="Ubuntu 6.10" +RELEASE="6.10" diff --git a/mk/testcases/lsb-ubuntu-7.04 b/mk/testcases/lsb-ubuntu-7.04 new file mode 100644 index 0000000..c857156 --- /dev/null +++ b/mk/testcases/lsb-ubuntu-7.04 @@ -0,0 +1,3 @@ +ID="Ubuntu" +DESCRIPTION="Ubuntu 7.04" +RELEASE="7.04" diff --git a/mk/testcases/oracle-5 b/mk/testcases/oracle-5 new file mode 100644 index 0000000..542c826 --- /dev/null +++ b/mk/testcases/oracle-5 @@ -0,0 +1 @@ +Enterprise Linux Enterprise Linux Server release 5 (Carthage) diff --git a/mk/testcases/oracle-5u1 b/mk/testcases/oracle-5u1 new file mode 100644 index 0000000..fad6c3c --- /dev/null +++ b/mk/testcases/oracle-5u1 @@ -0,0 +1 @@ +Enterprise Linux Enterprise Linux Server release 5.1 (Carthage) diff --git a/mk/testcases/rhel-3u6 b/mk/testcases/rhel-3u6 new file mode 100644 index 0000000..97004ce --- /dev/null +++ b/mk/testcases/rhel-3u6 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 3 (Taroon Update 6) diff --git a/mk/testcases/rhel-3u8 b/mk/testcases/rhel-3u8 new file mode 100644 index 0000000..0d75450 --- /dev/null +++ b/mk/testcases/rhel-3u8 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 3 (Taroon Update 8) diff --git a/mk/testcases/rhel-4 b/mk/testcases/rhel-4 new file mode 100644 index 0000000..62e7d40 --- /dev/null +++ b/mk/testcases/rhel-4 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 4 (Nahant) diff --git a/mk/testcases/rhel-4u1 b/mk/testcases/rhel-4u1 new file mode 100644 index 0000000..cf62351 --- /dev/null +++ b/mk/testcases/rhel-4u1 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 4 (Nahant Update 1) diff --git a/mk/testcases/rhel-4u2 b/mk/testcases/rhel-4u2 new file mode 100644 index 0000000..76100de --- /dev/null +++ b/mk/testcases/rhel-4u2 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 4 (Nahant Update 2) diff --git a/mk/testcases/rhel-4u3 b/mk/testcases/rhel-4u3 new file mode 100644 index 0000000..a258c65 --- /dev/null +++ b/mk/testcases/rhel-4u3 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 4 (Nahant Update 3) diff --git a/mk/testcases/rhel-4u4 b/mk/testcases/rhel-4u4 new file mode 100644 index 0000000..50ace04 --- /dev/null +++ b/mk/testcases/rhel-4u4 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 4 (Nahant Update 4) diff --git a/mk/testcases/rhel-4u5 b/mk/testcases/rhel-4u5 new file mode 100644 index 0000000..cf83112 --- /dev/null +++ b/mk/testcases/rhel-4u5 @@ -0,0 +1 @@ +Red Hat Enterprise Linux ES release 4 (Nahant Update 5) diff --git a/mk/testcases/rhel-4u6 b/mk/testcases/rhel-4u6 new file mode 100644 index 0000000..51ad006 --- /dev/null +++ b/mk/testcases/rhel-4u6 @@ -0,0 +1 @@ +Red Hat Enterprise Linux AS release 4 (Nahant Update 6) diff --git a/mk/testcases/rhel-5 b/mk/testcases/rhel-5 new file mode 100644 index 0000000..515506f --- /dev/null +++ b/mk/testcases/rhel-5 @@ -0,0 +1 @@ +Red Hat Enterprise Linux Server release 5 (Tikanga) diff --git a/mk/testcases/rhel-5beta b/mk/testcases/rhel-5beta new file mode 100644 index 0000000..1cb8fcf --- /dev/null +++ b/mk/testcases/rhel-5beta @@ -0,0 +1 @@ +Red Hat Enterprise Linux Server release 4.92 (Tikanga) diff --git a/mk/testcases/rhel-5u1 b/mk/testcases/rhel-5u1 new file mode 100644 index 0000000..5b6c571 --- /dev/null +++ b/mk/testcases/rhel-5u1 @@ -0,0 +1 @@ +Red Hat Enterprise Linux Server release 5.1 (Tikanga) diff --git a/mk/testcases/rhel-5u1beta b/mk/testcases/rhel-5u1beta new file mode 100644 index 0000000..65824b5 --- /dev/null +++ b/mk/testcases/rhel-5u1beta @@ -0,0 +1 @@ +Red Hat Enterprise Linux Server release 5.1 Beta (Tikanga) diff --git a/mk/testcases/sdk-0.5.6-2991c b/mk/testcases/sdk-0.5.6-2991c new file mode 100644 index 0000000..595adc5 --- /dev/null +++ b/mk/testcases/sdk-0.5.6-2991c @@ -0,0 +1 @@ +Rio SDK release 0.5.6-2991c (xenenterprise) diff --git a/mk/testcases/sles-10sp2 b/mk/testcases/sles-10sp2 new file mode 100644 index 0000000..a01febe --- /dev/null +++ b/mk/testcases/sles-10sp2 @@ -0,0 +1,3 @@ +SUSE Linux Enterprise Server 10 (i586) +VERSION = 10 +PATCHLEVEL = 2 diff --git a/mk/testcases/sles-11 b/mk/testcases/sles-11 new file mode 100644 index 0000000..d2ec72d --- /dev/null +++ b/mk/testcases/sles-11 @@ -0,0 +1,3 @@ +SUSE Linux Enterprise Server 11 (i586) +VERSION = 11 +PATCHLEVEL = 0 diff --git a/mk/testcases/sles-9 b/mk/testcases/sles-9 new file mode 100644 index 0000000..0418afa --- /dev/null +++ b/mk/testcases/sles-9 @@ -0,0 +1,2 @@ +SUSE LINUX Enterprise Server 9 (i586) +VERSION = 9 diff --git a/mk/testcases/sles-9sp3 b/mk/testcases/sles-9sp3 new file mode 100644 index 0000000..8f66b47 --- /dev/null +++ b/mk/testcases/sles-9sp3 @@ -0,0 +1,3 @@ +SUSE LINUX Enterprise Server 9 (i586) +VERSION = 9 +PATCHLEVEL = 3 diff --git a/mk/xe-guest-utilities.spec.in b/mk/xe-guest-utilities.spec.in new file mode 100644 index 0000000..512a47c --- /dev/null +++ b/mk/xe-guest-utilities.spec.in @@ -0,0 +1,124 @@ +# -*- rpm-spec -*- + +Summary: @BRAND_GUEST@ Monitoring Scripts +Name: xe-guest-utilities +Version: @VERSION@ +Release: @RELEASE@ +License: BSD +Group: Xen +URL: http://www.citrix.com +Vendor: @COMPANY_NAME_LEGAL@ +Source0: xe-linux-distribution +Source1: xe-linux-distribution.init +Source3: xe-daemon +Source5: Citrix.repo +Source6: xenstore +Source8: LICENSE +Source9: xen-vcpu-hotplug.rules +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot +BuildRequires: golang +Obsoletes: xengmond + +%description +Scripts for monitoring @BRAND_GUESTS@. + +Writes distribution version information and IP address to XenStore. + +%package xenstore +Summary: @BRAND_GUEST@ XenStore utilities +Group: Xen +%description xenstore +Utilities for interacting with XenStore from with a Xen virtual machine + +%prep +# Nothing to do +%build +# Nothing to do + +%install +rm -rf %{buildroot} + +mkdir -p %{buildroot}/usr/sbin/ +mkdir -p %{buildroot}/usr/share/doc/%{name}-%{version}/examples/ +mkdir -p %{buildroot}/etc/init.d +mkdir -p %{buildroot}/etc/udev/rules.d + +cp %{SOURCE0} %{buildroot}/usr/sbin/xe-linux-distribution +chmod 755 %{buildroot}/usr/sbin/xe-linux-distribution + +cp %{SOURCE1} %{buildroot}/etc/init.d/xe-linux-distribution +chmod 755 %{buildroot}/etc/init.d/xe-linux-distribution + +cp %{SOURCE3} %{buildroot}/usr/sbin/xe-daemon +chmod 755 %{buildroot}/usr/sbin/xe-daemon + +cp %{SOURCE5} %{buildroot}/usr/share/doc/%{name}-%{version}/examples/ + +install -d %{buildroot}/usr/bin/ +install -m 755 %{SOURCE6} %{buildroot}/usr/bin/xenstore +ln -s /usr/bin/xenstore %{buildroot}/usr/bin/xenstore-read +ln -s /usr/bin/xenstore %{buildroot}/usr/bin/xenstore-write +ln -s /usr/bin/xenstore %{buildroot}/usr/bin/xenstore-exists +ln -s /usr/bin/xenstore %{buildroot}/usr/bin/xenstore-rm + +cp %{SOURCE9} %{buildroot}/etc/udev/rules.d/z10-xen-vcpu-hotplug.rules + +cp %{SOURCE8} %{buildroot}/usr/share/doc/%{name}-%{version}/ + +mkdir -p %{buildroot}/usr/share/doc/%{name}-xenstore-%{version} +cp %{SOURCE8} %{buildroot}/usr/share/doc/%{name}-xenstore-%{version}/ + +%clean +rm -rf %{buildroot} + +%post +/sbin/chkconfig --add xe-linux-distribution >/dev/null +[ -n "${EXTERNAL_P2V}" ] || service xe-linux-distribution start >/dev/null 2>&1 + +eval $(/usr/sbin/xe-linux-distribution) + +if [ -d /etc/yum.repos.d ] && [ -n "${os_distro}" ] && [ -n "${os_majorver}" ] ; then + distro="${os_distro}${os_majorver}x" + case "${distro}" in + rhel4x|centos4x) + if [ -f /etc/yum.repos.d/XenSource.repo ] ; then + rm -f /etc/yum.repos.d/XenSource.repo # contains deprecated urls + fi + sed -e "s/@DISTRO@/${distro}/g" \ + < /usr/share/doc/%{name}-%{version}/examples/Citrix.repo \ + > /etc/yum.repos.d/Citrix.repo + ;; + rhel3x|rhel5x|centos5x|oracle5x) # No vendor kernel any more. Remove Citrix.repo + if [ -f /etc/yum.repos.d/Citrix.repo ] ; then + rm -f /etc/yum.repos.d/Citrix.repo + fi + ;; + *) ;; + esac +fi + +%preun +if [ $1 -eq 0 ] ; then + service xe-linux-distribution stop >/dev/null 2>&1 + /sbin/chkconfig --del xe-linux-distribution >/dev/null + rm -f /etc/yum.repos.d/Citrix.repo || /bin/true +fi + +%files +%defattr(-,root,root,-) +/usr/sbin/xe-linux-distribution +/etc/init.d/xe-linux-distribution +/usr/sbin/xe-daemon +/etc/udev/rules.d/z10-xen-vcpu-hotplug.rules +/usr/share/doc/%{name}-%{version}/examples/Citrix.repo +/usr/share/doc/%{name}-%{version}/LICENSE + +%files xenstore +%defattr(-,root,root,-) +/usr/bin/xenstore-* +/usr/bin/xenstore +/usr/share/doc/%{name}-xenstore-%{version}/LICENSE + +%changelog +* Tue Jun 5 2007 <citrix.com> +- Xen monitor scripts diff --git a/mk/xe-linux-distribution b/mk/xe-linux-distribution new file mode 100755 index 0000000..5013e4f --- /dev/null +++ b/mk/xe-linux-distribution @@ -0,0 +1,315 @@ +#! /bin/sh + +# Copyright (c) 2015, Citrix Systems +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# Script to write information about the current distribution to stdout or a file. +# Information collected: +# - Distribution name +# - Distribution version (major and minor) +# - Kernel version (uname) + +LANG="C" +export LANG + + +write_to_output() +{ + local distro="$1" + local major="$2" + local minor="$3" + local name="$4" + local uname=$(uname -r) + + if [ -n "${TEST_RESULT}" ] ; then + MAJOR=$major + MINOR=$minor + DISTRO=$distro + UNAME=$uname + return 0 + fi + + echo "os_distro=\"${distro}\"" + echo "os_majorver=\"${major}\"" + echo "os_minorver=\"${minor}\"" + echo "os_uname=\"${uname}\"" + echo "os_name=\"${name}\"" + + return 0 +} + +identify_debian() +{ + local debian_version="$1" + local major + local minor + + # 3.1 + # 4.0 + # Ignores testing and unstable which contain ".*/sid". + + if [ ! -f "${debian_version}" ] ; then + return 1 + fi + + eval $(awk -F. '/^[0-9]*\.[0-9]*/ \ + { print "major="$1 ; print "minor="$2 ; exit 0 }' \ + "${debian_version}") + + if [ -z "${major}" ] && [ -z "${minor}" ] && ! grep -q /sid "${debian_version}" ; then + return 1 + fi + + write_to_output "debian" "${major}" "${minor}" "Debian $(head -n 1 $debian_version)" + + return 0 +} + +identify_redhat() +{ + redhat_release="$1" + local distro + local major + local minor + local beta + + # distro=rhel + # Red Hat Enterprise Linux AS release 3 (Taroon Update 6) + # Red Hat Enterprise Linux AS release 3 (Taroon Update 8) + # Red Hat Enterprise Linux AS release 4 (Nahant) + # Red Hat Enterprise Linux AS release 4 (Nahant Update 1) + # Red Hat Enterprise Linux AS release 4 (Nahant Update 2) + # Red Hat Enterprise Linux AS release 4 (Nahant Update 3) + # Red Hat Enterprise Linux AS release 4 (Nahant Update 4) + # Red Hat Enterprise Linux Server release 4.92 (Tikanga) + # Red Hat Enterprise Linux Server release 5 (Tikanga) + # Red Hat Enterprise Linux Server release 5.1 Beta (Tikanga) + # Red Hat Enterprise Linux release 6.0 Beta (Santiago) + + # distro=xe-ddk + # \@PRODUCT_BRAND\@ DDK release \@PRODUCT_VERSION\@-\@BUILD_NUMBER\@ (\@PRODUCT_NAME\@) + # Rio DDK release 0.5.6-2991c (xenenterprise) + + # distro=xe-sdk + # \@PRODUCT_BRAND\@ SDK release \@PRODUCT_VERSION\@-\@BUILD_NUMBER\@ (\@PRODUCT_NAME\@) + # Rio SDK release 0.5.6-2991c (xenenterprise) + + # distro=fedora + # Fedora Core release 3 (Heidelberg) + + # distro=centos + # CentOS release 4.0 (Final) + # CentOS release 5 (Final) + # CentOS Linux release 7.0.1406 (Core) + + # distro=scientific + # Scientific Linux release 6.5 (Carbon) + + # distro=oracle + # Enterprise Linux Enterprise Linux Server release 5 (Carthage) + # Enterprise Linux Enterprise Linux Server release 5.5 (Carthage) + # Oracle Linux Server release 5.6 + + if [ ! -f "${redhat_release}" ] ; then + return 1 + fi + + eval $(sed -n \ + -e 's/^\(.*\) DDK release \(.*\)-\(.*\) (.*)$/distro=xe-ddk;major=\2;minor=\3/gp;' \ + -e 's/^\(.*\) SDK release \(.*\)-\(.*\) (.*)$/distro=xe-sdk;major=\2;minor=\3/gp;' \ + -e 's/^Red Hat Enterprise Linux.* release \([0-9]*\) (.* Update \(.*\))$/distro=rhel;major=\1;minor=\2/gp;'\ + -e 's/^Red Hat Enterprise Linux.* release \([0-9]*\) (.*)$/distro=rhel;major=\1/gp;' \ + -e 's/^Red Hat Enterprise Linux.* release \([0-9]*\)\.\([0-9]*\) \([Bb]eta \)\?(.*)$/distro=rhel;major=\1;minor=\2;beta=\3;/gp;' \ + -e 's/^Fedora.*release \([0-9]*\) (.*)$/distro=fedora;major=\1/gp;' \ + -e 's/^CentOS release \([0-9]*\)\.\([0-9]*\) (.*)/distro=centos;major=\1;minor=\2/gp;' \ + -e 's/^CentOS release \([0-9]*\) (.*)/distro=centos;major=\1/gp;' \ + -e 's/^CentOS Linux release \([0-9]*\)\.\([0-9]*\)\(\.[0-9]*\)\? (.*)/distro=centos;major=\1;minor=\2/gp;' \ + -e 's/^Enterprise Linux Enterprise Linux .* release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=oracle;major=\1;minor=\2;/gp;' \ + -e 's/^Enterprise Linux Enterprise Linux .* release \([0-9]*\) (.*)$/distro=oracle;major=\1/gp;' \ + -e 's/^Oracle Linux Server release \([0-9]*\)\.\([0-9]*\)$/distro=oracle;major=\1;minor=\2/gp;' \ + -e 's/^Scientific Linux SL release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=scientific;major=\1;minor=\2;/gp;' \ + -e 's/^Scientific Linux release \([0-9]*\)\.\([0-9]*\) (.*)$/distro=scientific;major=\1;minor=\2;/gp;' \ + "${redhat_release}") + + if [ -z "${major}" -o -z "${distro}" ] ; then + return 1 + fi + + if [ -z "${minor}" ] ; then + minor=0 + fi + + # HACK to handle RHEL betas + if [ "${distro}" == "rhel" ] && [ ${minor} -gt 90 ] ; then + major=$(expr ${major} + 1 ) + minor=0 + beta=Beta + fi + + if [ -n "${beta}" ] ; then + minor="${minor}beta" + fi + + write_to_output "${distro}" "${major}" "${minor}" "$(head -n 1 ${redhat_release})" + +} + +identify_sles() +{ + suse_release="$1" + local major + local minor + local _major + + # SUSE LINUX Enterprise Server 9 (i586) + # VERSION = 9 + # + # SUSE LINUX Enterprise Server 9 (i586) + # VERSION = 9 + # PATCHLEVEL = 2 + # + # SUSE LINUX Enterprise Server 9 (i586) + # VERSION = 9 + # PATCHLEVEL = 3 + # + # SUSE Linux Enterprise Server 10 (i586) + # VERSION = 10 + # + # SUSE Linux Enterprise Server 10 (i586) + # VERSION = 10 + # PATCHLEVEL = 1 + # + # SUSE Linux Enterprise Server 11 (i586) + # VERSION = 11 + # PATCHLEVEL = 0 + + if [ ! -f "${suse_release}" ] ; then + return 1 + fi + + eval $(sed -n \ + -e 's/^SUSE L\(inux\|INUX\) Enterprise \([a-zA-Z0-9_]*\) \([0-9]*\) (.*)/_major=\3;/gp;' \ + -e 's/^VERSION = \([0-9]*\)$/major=\1;/gp;' \ + -e 's/^PATCHLEVEL = \([0-9]*\)$/minor=\1;/gp;' \ + "${suse_release}") + + if [ -z "${major}" -o -z "${_major}" ] ; then + return 1 + fi + + if [ "${major}" != "${_major}" ] ; then + return 1 + fi + + if [ -z "${minor}" ] ; then + minor=0 + fi + + write_to_output "sles" "${major}" "${minor}" "$(head -n 1 ${suse_release})" + +} + +identify_lsb() +{ + lsb_release="$1" + + if [ ! -x "${lsb_release}" ] ; then + saved_IFS=$IFS + IFS=: + for i in $PATH ; do + if [ -x "${i}/${lsb_release}" ] ; then + lsb_release="${i}/${lsb_release}" + break + fi + done + IFS=$saved_IFS + fi + + if [ -x "${lsb_release}" ] ; then + distro=$(${lsb_release} --short --id | tr 'A-Z' 'a-z') + description=$(${lsb_release} --short --description | sed -e 's/^"\(.*\)"$/\1/g') + release=$(${lsb_release} --short --release) + else + if [ -f /etc/lsb-release ] ; then + source /etc/lsb-release + distro="$DISTRIB_ID" + description="$DISTRIB_DESCRIPTION" + release="$DISTRIB_RELEASE" + else + return 1 + fi + fi + + if [ -z "${distro}" -o -z "${release}" ] ; then + return 1 + fi + + eval $(echo $release | awk -F. -- '{ subindex = index($0,"."); \ + print "major=" $1 ; \ + print "minor=" substr($0,subindex+1) }') + + if [ -z "${major}" -o -z "${distro}" ] ; then + return 1 + fi + + write_to_output "${distro}" "${major}" "${minor}" "${description}" +} + +identify_boot2docker() +{ + boot2docker_release="$1" + local major + local minor + + if [ ! -f "${boot2docker_release}" ] ; then + return 1 + fi + + major=$(awk -F. '{printf("%s", $1)}' /etc/version) + minor=$(awk -F. '{printf("%s.%s", $2, $3)}' /etc/version) + + write_to_output "boot2docker" "${major}" "${minor}" "boot2docker $(head -n 1 /etc/version)" + +} + +if [ $# -eq 1 ] ; then + exec 1>"$1" +fi + +if [ -z "${TEST}" ] ; then + identify_redhat /etc/oracle-release && exit 0 + identify_redhat /etc/enterprise-release && exit 0 + identify_redhat /etc/centos-release && exit 0 + identify_redhat /etc/redhat-release && exit 0 + identify_sles /etc/SuSE-release && exit 0 + identify_lsb lsb_release && exit 0 + identify_debian /etc/debian_version && exit 0 + identify_boot2docker /etc/boot2docker && exit 0 + + if [ $# -eq 1 ] ; then + rm -f "$1" + fi + + exit 1 +fi diff --git a/mk/xe-linux-distribution-test b/mk/xe-linux-distribution-test new file mode 100755 index 0000000..1d6dfcf --- /dev/null +++ b/mk/xe-linux-distribution-test @@ -0,0 +1,82 @@ +#!/bin/sh + +LANG="C" +export LANG + + +TEST=yes + +. xe-linux-distribution + +test_identify() +{ + export TESTCASE=$1 + identify_lsb testcases/lsb || \ + identify_debian "${1}" || \ + identify_redhat "${1}" || \ + identify_sles "${1}" || \ + return 1 +} + +do_test() +{ + TC=$1 ; shift + TEST_RESULT=$@ + if test_identify ${TC} ; then + if [ X"${TEST_RESULT}" = X"FAIL" ] ; then + echo "FAILED: ${TC}: should fail to parse" 1>&2 + else + set ${TEST_RESULT} + if [ "$1" != "${DISTRO}" ] ; then + echo "FAILED: ${TC}: $1 $2.$3: distro ${DISTRO} != $1" 1>&2 + exit 1 + fi + if [ "$2" != "${MAJOR}" ] ; then + echo "FAILED: ${TC}: $1 $2.$3: major ${MAJOR} != $2" 1>&2 + exit 1 + fi + if [ "$3" != "${MINOR}" ] ; then + echo "FAILED: ${TC} $1 $2.$3: minor ${MINOR} != $3" 1>&2 + exit 1 + fi + echo "PASSED: ${TC}: ${DISTRO} ${MAJOR} ${MINOR} correctly detected" 1>&2 + fi + else + if [ X"${TEST_RESULT}" = X"FAIL" ] ; then + echo "PASSED: ${TC}: correctly failed to parse" 1>&2 + else + echo "FAILED: ${TC}: unable to parse" 1>&2 + fi + fi +} + +do_test "testcases/debian-sid" "debian" +do_test "testcases/rhel-3u6" "rhel 3 6" +do_test "testcases/rhel-3u8" "rhel 3 8" +do_test "testcases/rhel-4" "rhel 4 0" +do_test "testcases/rhel-4u1" "rhel 4 1" +do_test "testcases/rhel-4u2" "rhel 4 2" +do_test "testcases/rhel-4u3" "rhel 4 3" +do_test "testcases/rhel-4u4" "rhel 4 4" +do_test "testcases/rhel-4u5" "rhel 4 5" +do_test "testcases/rhel-4u6" "rhel 4 6" +do_test "testcases/rhel-5beta" "rhel 5 0beta" +do_test "testcases/rhel-5" "rhel 5 0" +do_test "testcases/rhel-5u1beta" "rhel 5 1beta" +do_test "testcases/rhel-5u1" "rhel 5 1" +do_test "testcases/fc3" "fedora 3 0" +do_test "testcases/sles-9" "sles 9 0" +do_test "testcases/sles-9sp3" "sles 9 3" +do_test "testcases/sles-10sp2" "sles 10 2" +do_test "testcases/sles-11" "sles 11 0" +do_test "testcases/ddk-0.5.6-2991c" "xe-ddk 0.5.6 2991c" +do_test "testcases/sdk-0.5.6-2991c" "xe-sdk 0.5.6 2991c" +do_test "testcases/centos4" "centos 4 0" +do_test "testcases/centos5" "centos 5 0" +do_test "testcases/lsb-ubuntu-6.10" "ubuntu 6 10" +do_test "testcases/lsb-ubuntu-7.04" "ubuntu 7 04" +do_test "testcases/oracle-5" "oracle 5 0" +do_test "testcases/oracle-5u1" "oracle 5 1" +do_test "testcases/lsb-coreos-367.1.0" "coreos 367 1.0" + +exit 0 diff --git a/mk/xe-linux-distribution.init b/mk/xe-linux-distribution.init new file mode 100644 index 0000000..c2c9c03 --- /dev/null +++ b/mk/xe-linux-distribution.init @@ -0,0 +1,117 @@ +#!/bin/sh +# +# xe-linux-distribution Write Linux distribution information to XenStore. +# +# chkconfig: 2345 14 86 +# description: Writes Linux distribution version information to XenStore. +# +### BEGIN INIT INFO +# Provides: xe-linux-distribution +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: XenServer Virtual Machine daemon providing host integration services +# Description: Writes Linux distribution version information to XenStore. +### END INIT INFO + +LANG="C" +export LANG + +if [ -f /etc/init.d/functions ] ; then +. /etc/init.d/functions +else +action() +{ + descr=$1 ; shift + cmd=$@ + echo -n "$descr " + $cmd + ret=$? + if [ $ret -eq 0 ] ; then + echo "OK" + else + echo "Failed" + fi + return $ret +} +fi + +XE_LINUX_DISTRIBUTION=/usr/sbin/xe-linux-distribution +XE_LINUX_DISTRIBUTION_CACHE=/var/cache/xe-linux-distribution +XE_DAEMON=/usr/sbin/xe-daemon +XE_DAEMON_PIDFILE=/var/run/xe-daemon.pid + +if [ ! -x "${XE_LINUX_DISTRIBUTION}" ] ; then + exit 0 +fi + +start() +{ + if [ ! -e /proc/xen/xenbus ] ; then + if [ ! -d /proc/xen ] ; then + action $"Mounting xenfs on /proc/xen:" /bin/false + echo "Could not find /proc/xen directory." + echo "You need a post 2.6.29-rc1 kernel with CONFIG_XEN_COMPAT_XENFS=y and CONFIG_XENFS=y|m" + exit 1 + else + # This is needed post 2.6.29-rc1 when /proc/xen support was pushed upstream as a xen filesystem + action $"Mounting xenfs on /proc/xen:" mount -t xenfs none /proc/xen + fi + fi + + if [ -e /proc/xen/capabilities ] && grep -q control_d /proc/xen/capabilities ; then + # Do not want daemon in domain 0 + exit 0 + fi + + action $"Detecting Linux distribution version:" \ + ${XE_LINUX_DISTRIBUTION} ${XE_LINUX_DISTRIBUTION_CACHE} + + action $"Starting xe daemon: " /bin/true + mkdir -p $(dirname ${XE_DAEMON_PIDFILE}) + if start-stop-daemon --start --background --exec ${XE_DAEMON} -- -p ${XE_DAEMON_PIDFILE} 1>/dev/null 2>/dev/null; then + exit 0 + else + # This is equivalent to daemon() in C + ( exec &>/dev/null ; ${XE_DAEMON} -p ${XE_DAEMON_PIDFILE} 2>/dev/null & ) + fi +} + +stop() +{ + action $"Stopping xe daemon: " kill -TERM $(cat ${XE_DAEMON_PIDFILE}) +} + +status() +{ + cat ${XE_LINUX_DISTRIBUTION_CACHE} +} + +# fail silently if not running xen +if [ ! -d /proc/xen ]; then + exit +fi + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + force-reload|restart) + stop + start + ;; + *) + # do not advertise unreasonable commands that there is no reason + # to use with this device + echo $"Usage: $0 start|restart|status" + exit 1 +esac + +exit $? diff --git a/mk/xe-linux-distribution.service b/mk/xe-linux-distribution.service new file mode 100644 index 0000000..0e87583 --- /dev/null +++ b/mk/xe-linux-distribution.service @@ -0,0 +1,9 @@ +[Unit] +Description=XenServer Linux Guest Agent + +[Service] +ExecStartPre=/usr/share/oem/xs/xe-linux-distribution /var/cache/xe-linux-distribution +ExecStart=/usr/share/oem/xs/xe-daemon + +[Install] +WantedBy=multi-user.target
\ No newline at end of file diff --git a/mk/xen-vcpu-hotplug.rules b/mk/xen-vcpu-hotplug.rules new file mode 100644 index 0000000..ecb200e --- /dev/null +++ b/mk/xen-vcpu-hotplug.rules @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEM=="cpu", RUN+="/bin/sh -c '[ ! -e /sys$devpath/online ] || echo 1 > /sys$devpath/online'" |