Permalink
Browse files

[packaging] make a xapi-client library usable with ocmalfind.

Signed-off-by: Thomas Gazagnaire <thomas.gazagnaire@citrix.com>
  • Loading branch information...
1 parent 5831d49 commit 5c2c88e62bd5496ccd7642dec155c80c1e9bbe0a Thomas Gazagnaire committed Nov 11, 2009
Showing with 96 additions and 133 deletions.
  1. +11 −0 Makefile
  2. +1 −2 OMakefile
  3. +53 −45 mk/Makefile
  4. +0 −1 ocaml/OMakefile
  5. +0 −21 ocaml/fdhelper/OMakefile
  6. +0 −57 ocaml/fdhelper/closeandexec.ml
  7. +0 −1 ocaml/idl/ocaml_backend/META.in
  8. +31 −6 ocaml/idl/ocaml_backend/OMakefile
View
@@ -13,6 +13,8 @@ export PRODUCT_VERSION PRODUCT_BRAND BUILD_NUMBER
all:
omake ocaml/util/version.ml
omake phase1 phase2
+ omake lib-uninstall
+ omake lib-install
omake phase3
.PHONY: phase3
@@ -39,6 +41,14 @@ cvm:
install:
omake install
+.PHONY: lib-install
+lib-install:
+ omake DESTDIR=$(DESTDIR) lib-install
+
+.PHONY: lib-uninstall
+lib-uninstall:
+ omake lib-uninstall
+
.PHONY: sdk-install
sdk-install:
omake sdk-install
@@ -50,6 +60,7 @@ patch:
.PHONY: clean
clean:
omake clean
+ omake lib-uninstall
rm -rf dist/staging
rm -f .omakedb .omakedb.lock
View
@@ -82,7 +82,7 @@ if $(not $(defined-env COMPILE_XENSTUFF))
# Ocaml #############################################################################
OCAML_PHASE1=
-OCAML_PHASE2= autogen_idl
+OCAML_PHASE2= autogen_idl ocaml/idl/ocaml_backend/xapi_client.cmxa
# JS ################################################################################
JS_PHASE1=
@@ -124,7 +124,6 @@ OCAML_PHASE3_XEN = \
ocaml/license/v6d-reopen-logs
OCAML_PHASE3_NOXEN = \
- ocaml/fdhelper/closeandexec \
ocaml/auth/testauthx \
ocaml/xe-cli/xe \
ocaml/xsh/xsh \
View
@@ -5,67 +5,70 @@ IMPORT_BRANDING := yes
include $(B_BASE)/common.mk
include $(B_BASE)/rpmbuild.mk
-OUTPUT_PKG := $(MY_MAIN_PACKAGES)/xapi.tar.bz2
-OUTPUT_XAPI := $(MY_OUTPUT_DIR)/xapi
-OUTPUT_CLI := $(MY_OUTPUT_DIR)/xe
-OUTPUT_CLI_RT := $(MY_OUTPUT_DIR)/cli-regress.tar.gz
-OUTPUT_CLI_RT_GENEVA := $(MY_OUTPUT_DIR)/cli-regress-geneva.tar.gz
-OUTPUT_FAKESERVER := $(MY_OUTPUT_DIR)/fakeserver.tar.bz2
-OUTPUT_DOCS := $(MY_OUTPUT_DIR)/sdkiso
-OUTPUT_WEBZIP := $(MY_OUTPUT_DIR)/sdk-html.zip
-OUTPUT_SRC := $(MY_OUTPUT_DIR)/xen-api-src.tar.bz2
-OUTPUT_PATCH := $(MY_OUTPUT_DIR)/testpatch.asc
-OUTPUT_DATAMODEL_DIR := $(MY_OUTPUT_DIR)/datamodel
-
-CLI_RPM_SOURCES :=
-CLI_RPM_SOURCES += $(RPM_SOURCESDIR)/xe
-CLI_RPM_SOURCES += $(RPM_SOURCESDIR)/bash-completion
-
-JQUERY_PACK_DIST=$(CARBON_DISTFILES)/javascript/jquery/jquery-1.1.3.1.pack.js
-JQUERY_TV_DIST=$(CARBON_DISTFILES)/javascript/jquery/treeview/jquery.treeview.zip
+REPO = $(call hg_loc,xen-api)
+
+STAGING = $(REPO)/dist/staging
+OUTPUT_XAPI = $(MY_MAIN_PACKAGES)/xapi.tar.bz2
+OUTPUT_XAPI_DEVEL = $(MY_OUTPUT_DIR)/xapi-devel.tar.gz
+OUTPUT_XAPI_SRC = $(MY_SOURCES)/xen-api-src.tar.bz2
+
+STAGING_CLI_RT = $(REPO)/dist/cli-rt
+OUTPUT_CLI_RT = $(MY_OUTPUT_DIR)/cli-regress.tar.gz
+OUTPUT_CLI_RPM_SOURCES = $(RPM_SOURCESDIR)/xe $(RPM_SOURCESDIR)/bash-completion
+
+OUTPUT_DOCS = $(MY_OUTPUT_DIR)/sdkiso
+OUTPUT_WEBZIP = $(MY_OUTPUT_DIR)/sdk-html.zip
+
+JQUERY_PACK_DIST = $(CARBON_DISTFILES)/javascript/jquery/jquery-1.1.3.1.pack.js
+JQUERY_TV_DIST = $(CARBON_DISTFILES)/javascript/jquery/treeview/jquery.treeview.zip
+
+OUTPUT_P2V_DIR = $(MY_OUTPUT_DIR)
+OUTPUT_DATAMODEL_DIR = $(MY_OUTPUT_DIR)/datamodel
+
+OUTPUT_SDK_DIR = $(MY_OUTPUT_DIR)
+OUTPUT_SDK = $(MY_OUTPUT_DIR)/sdk.tar.gz
export BUILD_NUMBER
export PRODUCT_BRAND
export PRODUCT_VERSION
-REPO=$(call hg_loc,xen-api)
-
.PHONY: build
-build: $(OUTPUT_PKG) $(MY_OBJ_DIR)/.rpmbuild.cli.stamp $(MY_SOURCES)/MANIFEST
+build: $(OUTPUT_XAPI) $(OUTPUT_XAPI_DEVEL) $(OUTPUT_CLI_RT) $(OUTPUT_SDK) $(MY_OBJ_DIR)/.rpmbuild.cli.stamp $(MY_SOURCES)/MANIFEST
$(call mkdir_clean,$(MY_LINUX_CDFILES)/client_install)
install -m 755 -o root -g root $(RPM_RPMSDIR)/i386/xe-cli-*.rpm $(MY_LINUX_CDFILES)/client_install/
-$(MY_SOURCES)/MANIFEST: $(MY_SOURCES_DIRSTAMP) $(OUTPUT_SRC)
- echo api gpl+lgpl-with-linking-exception file $(OUTPUT_SRC) > $@
+$(MY_SOURCES)/MANIFEST: $(MY_SOURCES_DIRSTAMP) $(OUTPUT_XAPI_SRC)
+ echo api gpl+lgpl-with-linking-exception file $(OUTPUT_XAPI_SRC) > $@
echo api gpl file $(JQUERY_PACK_DIST) >> $@
echo api gpl file $(JQUERY_TV_DIST) >> $@
-$(OUTPUT_SRC):
+$(OUTPUT_XAPI_SRC):
cd $(REPO) && hg archive -t tbz2 $(HG_EXCLUDE) $@
-$(OUTPUT_PKG) $(OUTPUT_FAKESERVER) $(OUTPUT_XAPI) $(OUTPUT_CLI): $(call hg_req,xen-api) $(MY_MAIN_PACKAGES)/.dirstamp
- rm -rf $(REPO)/dist
+$(OUTPUT_XAPI) $(OUTPUT_XAPI_DEVEL) $(OUTPUT_CLI_RT) $(OUTPUT_SDK): $(call hg_req,xen-api) $(MY_MAIN_PACKAGES)/.dirstamp
$(MAKE) clean
$(MAKE) -C $(REPO)
- install -m 755 -o root -g root $(REPO)/ocaml/p2v/p2v $(MY_OUTPUT_DIR)/p2v-server
- install -m 755 -o root -g root $(REPO)/ocaml/p2v/closeandexec_static $(MY_OUTPUT_DIR)/closeandexec_static
+
+ rm -rf $(STAGING) $(STAGING_CLI_RT)
$(MAKE) -C $(REPO) install
- mkdir -p $(REPO)/dist/staging/var/xapi
- mkdir -p $(REPO)/dist/staging/var/log/xen
- mkdir -p $(REPO)/dist/staging/var/opt/xen/iso_import
- cp $(REPO)/dist/staging/opt/xensource/bin/xapi $(OUTPUT_XAPI)
- tar -C $(REPO)/dist/staging -jcf $(OUTPUT_PKG) .
- tar -C $(REPO)/dist/cli-rt -zcf $(OUTPUT_CLI_RT) .
- tar -C $(REPO)/dist/cli-regress-geneva -zcf $(OUTPUT_CLI_RT_GENEVA) .
- install -m 755 -o root -g root $(REPO)/dist/staging/opt/xensource/bin/xe $(MY_OUTPUT_DIR)/xe
- rm -rf $(REPO)/dist
+ mkdir -p $(MY_MAIN_PACKAGES)
+ tar -C $(STAGING) -jcf $(OUTPUT_XAPI) .
+ mkdir -p $(MY_OUTPUT_DIR)
+ tar -C $(STAGING_CLI_RT) -zcf $(OUTPUT_CLI_RT) .
+
+ rm -rf $(STAGING)
+ $(MAKE) -C $(REPO) DESTDIR=$(STAGING) lib-install
+ tar -C $(STAGING) -zcf $(OUTPUT_XAPI_DEVEL) .
+
+ rm -rf $(STAGING)
$(MAKE) -C $(REPO) sdk-install
$(call mkdir_clean,$(OUTPUT_DOCS))
- cp $(REPO)/dist/staging/SDK/README.html $(OUTPUT_DOCS)/
- cp -a $(REPO)/dist/staging/SDK/docs $(OUTPUT_DOCS)/
- cd $(REPO)/dist/staging/SDKwww && zip -9rv $(OUTPUT_WEBZIP) .
- tar -C $(REPO)/dist/staging --exclude=etc/xensource/license -jcf $(OUTPUT_FAKESERVER) .
- install -m 644 -o root -g root $(REPO)/ocaml/xe-cli/rt/geneva/testpatch.asc $(OUTPUT_PATCH)
+ cp $(STAGING)/SDK/README.html $(OUTPUT_DOCS)/
+ cp -a $(STAGING)/SDK/docs $(OUTPUT_DOCS)/
+ cd $(STAGING)/SDKwww && zip -9rv $(OUTPUT_WEBZIP) .
+ mkdir -p $(OUTPUT_SDK_DIR)
+ tar -C $(STAGING) -zcf $(OUTPUT_SDK) .
+
rm -rf $(OUTPUT_DATAMODEL_DIR)
mkdir -p $(OUTPUT_DATAMODEL_DIR)
install -m 644 -o root -g root $(REPO)/ocaml/idl/datamodel.a $(OUTPUT_DATAMODEL_DIR)
@@ -76,7 +79,11 @@ $(OUTPUT_PKG) $(OUTPUT_FAKESERVER) $(OUTPUT_XAPI) $(OUTPUT_CLI): $(call hg_req,x
install -m 644 -o root -g root $(REPO)/ocaml/idl/dm_api.cmi $(OUTPUT_DATAMODEL_DIR)
install -m 644 -o root -g root $(REPO)/ocaml/idl/api_messages.cmi $(OUTPUT_DATAMODEL_DIR)
-$(RPM_SOURCESDIR)/xe: $(OUTPUT_CLI)
+ mkdir -p $(OUTPUT_P2V_DIR)
+ install -m 755 -o root -g root $(REPO)/ocaml/p2v/p2v $(OUTPUT_P2V_DIR)/p2v-server
+ install -m 755 -o root -g root $(REPO)/ocaml/p2v/closeandexec_static $(OUTPUT_P2V_DIR)/closeandexec_static
+
+$(RPM_SOURCESDIR)/xe: $(REPO)/ocaml/xe-cli/xe
mkdir -p $(RPM_SOURCESDIR)
cp $< $@
@@ -88,11 +95,12 @@ $(RPM_SPECSDIR)/xe.spec: xe.spec.in
mkdir -p $(RPM_SPECSDIR)
$(call brand,xe.spec.in) > $@
-$(MY_OBJ_DIR)/.rpmbuild.cli.stamp: $(RPM_DIRECTORIES) $(RPM_SPECSDIR)/xe.spec $(CLI_RPM_SOURCES)
+$(MY_OBJ_DIR)/.rpmbuild.cli.stamp: $(RPM_DIRECTORIES) $(RPM_SPECSDIR)/xe.spec $(OUTPUT_CLI_RPM_SOURCES)
$(RPMBUILD) --target i386 -ba $(RPM_SPECSDIR)/xe.spec
touch $@
.PHONY: clean
clean:
- rm -f $(OUTPUT_PKG) $(OUTPUT_FAKESERVER) $(OUTPUT_CLI) $(OUTPUT_WEBZIP) $(OUTPUT_SRC)
+ rm -f $(OUTPUT_XAPI) $(OUTPUT_XAPI_DEVEL) $(OUTPUT_XAPI_SRC) $(OUTPUT_CLI_RT) $(OUTPUT_WEBZIP) $(OUTPUT_SDK)
+ rm -rf $(OUTPUT_DATAMODEL_DIR) $(OUTPUT_P2V_DIR) $(OUTPUT_DOCS) $(OUTPUT_SDK_DIR)
$(MAKE) -C $(REPO) clean
View
@@ -5,7 +5,6 @@ OCAML_LIBS = $(ROOT)/ocaml/util/version $(ROOT)/ocaml/util/stats
OCAMLPACKS = stdext log
.SUBDIRS: \
- fdhelper \
autogen \
xe-cli \
xapimon \
View
@@ -1,21 +0,0 @@
-
-# Don't link with threads
-OCAMLPACKS = stdext
-
-section:
- OCAMLFLAGS += -cclib -static
- OCamlProgram(closeandexec_static, closeandexec)
-
-OCamlProgram(closeandexec, closeandexec)
-
-.PHONY: install
-install:
- mkdir -p $(LIBEXEC)
- $(IPROG) closeandexec $(LIBEXEC)
-
-.PHONY: sdk-install
-sdk-install: install
-
-.PHONY: clean
-clean:
- rm -rf $(CLEAN_OBJS) *.aux *.log *.fig closeandexec
@@ -1,57 +0,0 @@
-(*
- * Copyright (C) 2006-2009 Citrix Systems Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *)
-
-(** Take a list of file descriptors, a program and a set of arguments. Close
- all fds except the set provided and then exec the supplied program. *)
-
-
-let usage () =
- Printf.printf "Usage:\n";
- Printf.printf " %s fd0 .. fdN -- argv0 .. argvN\n" Sys.argv.(0);
- exit 1
-
-let _ =
- let fds = ref [] in
- let args = ref [] in
- let found_dash = ref false in
- for i = 1 to Array.length(Sys.argv) - 1 do
- let x = Sys.argv.(i) in
- if x = "--"
- then found_dash := true
- else if !found_dash then args := x :: !args else fds := x :: !fds
- done;
- let fds = List.map (fun x -> Unixext.file_descr_of_int (int_of_string x)) !fds in
- let args = List.rev !args in
-
- if List.length args < 1 then usage();
-
- Unixext.close_all_fds_except fds;
- let cmd = List.hd args in
- (* CA-18955: xapi now runs with priority -3. We then set his sons priority to 0. *)
- Unix.nice (-(Unix.nice 0));
-
- let rec doit n =
- if n=0 then failwith "Max retries exceeded";
- try
- Unix.execv cmd (Array.of_list args)
- with
- | Unix.Unix_error (Unix.EUNKNOWNERR x,b,c) as e ->
- Printf.fprintf stderr "Unix error: %s (%s,%s)\n" (Unix.error_message (Unix.EUNKNOWNERR x)) b c;
- if x=26 (* ETXTBSY *) then
- (Thread.delay 1.0; doit (n-1)) else raise e
- | Unix.Unix_error (a,b,c) as e ->
- Printf.fprintf stderr "Unix error: %s (%s,%s)\n" (Unix.error_message a) b c;
- raise e
- in
- doit 5
@@ -1,5 +1,4 @@
version = "@VERSION@"
description = "XenAPI client bindings for OCaml"
requires = "xml-light2,stdext,stunnel,http-svr,log"
-archive(byte) = "xapi_client.cma"
archive(native) = "xapi_client.cmxa"
@@ -19,25 +19,25 @@ OCamlProgram(gen_api_main, $(GEN_API_FILES) gen_api_main ../datamodel ../constan
FILTER = closed # or opensource or closed or debug or implementation
-$(AUTOGEN_DIR)/client.ml: gen_api_main
+$(AUTOGEN_DIR)/client.ml: gen_api_main $(AUTOGEN_DIR)/aPI.ml
./gen_api_main -filterinternal true -filter $(FILTER) -mode client > $(AUTOGEN_DIR)/client.ml
$(AUTOGEN_DIR)/aPI.ml: gen_api_main
./gen_api_main -filterinternal true -filter $(FILTER) -mode api > $(AUTOGEN_DIR)/aPI.ml
-$(AUTOGEN_DIR)/server.ml: gen_api_main
+$(AUTOGEN_DIR)/server.ml: gen_api_main $(AUTOGEN_DIR)/aPI.ml
./gen_api_main -filterinternal true -gendebug -filter $(FILTER) -mode server > $(AUTOGEN_DIR)/server.ml
-$(AUTOGEN_DIR)/db_actions.ml: gen_api_main
+$(AUTOGEN_DIR)/db_actions.ml: gen_api_main $(AUTOGEN_DIR)/aPI.ml
./gen_api_main -filterinternal false -filter nothing -mode db > $(AUTOGEN_DIR)/db_actions.ml # note: we do not filter internal fields/messages here
-$(AUTOGEN_DIR)/custom_actions.ml: gen_api_main
+$(AUTOGEN_DIR)/custom_actions.ml: gen_api_main $(AUTOGEN_DIR)/aPI.ml
./gen_api_main -filterinternal true -filter $(FILTER) -mode actions > $(AUTOGEN_DIR)/custom_actions.ml
-$(AUTOGEN_DIR)/rbac_static.ml: gen_api_main
+$(AUTOGEN_DIR)/rbac_static.ml: gen_api_main $(AUTOGEN_DIR)/aPI.ml
./gen_api_main -filterinternal true -filter $(FILTER) -mode rbac > $(AUTOGEN_DIR)/rbac_static.ml
-$(AUTOGEN_DIR)/rbac_static.csv: gen_api_main
+$(AUTOGEN_DIR)/rbac_static.csv: gen_api_main $(AUTOGEN_DIR)/aPI.ml
./gen_api_main -filterinternal true -gendebug -filter $(FILTER) -mode rbac > $(AUTOGEN_DIR)/rbac_static.csv
.PHONY:autogen_idl
@@ -104,12 +104,18 @@ SERVER_OBJS = ../../database/escaping locking_helpers \
../../xapi/helper_process \
../../xapi/xmlrpc_sexpr
+XAPI_CLIENT_OBJS = \
+ ../../util/version \
+ $(COMMON_OBJS) \
+ $(CLIENT_OBJS)
+
_OCAMLPACKS = $(OCAMLPACKS)
OCAMLPACKS =
OCamlLibrary(common, $(COMMON_OBJS))
OCamlLibrary(client, $(CLIENT_OBJS))
OCamlLibrary(server, $(SERVER_OBJS))
+OCamlLibrary(xapi_client, $(XAPI_CLIENT_OBJS))
OCamlLibrary(htmldoc, htmldoc)
@@ -122,3 +128,22 @@ OCamlDocLibrary(server, $(SERVER_OBJS))
.PHONY: clean
clean:
rm -f *~ *.opt *.run *.a *.cma *.cmxa *.cmo *.cmi *.o *.cmx *.omc *.annot doc/* xmlrpc_doc/* aPI.ml client.ml server.ml rbac_static.ml rbac_static.csv gen_api gen_api.run gen_api.opt write_out_api write_out_client write_out_db_actions write_out_server gen_api_main
+
+.PHONY: lib-install
+META: META.in
+ sed 's/@VERSION@/$(PRODUCT_VERSION)/g' < $< > $@
+
+if $(defined DESTDIR)
+ INSTALL_PATH = $(DESTDIR)/$(shell ocamlfind printconf destdir)
+ export
+else
+ INSTALL_PATH = $(shell ocamlfind printconf destdir)
+ export
+
+lib-install: META
+ mkdir -p $(INSTALL_PATH)
+ ocamlfind install -destdir $(INSTALL_PATH) -ldconf ignore xapi-client META xapi_client.{cmxa,a} $(addsuffixes .cmi .cmx, $(XAPI_CLIENT_OBJS))
+
+.PHONY: lib-uninstall
+lib-uninstall:
+ ocamlfind remove xapi-client

0 comments on commit 5c2c88e

Please sign in to comment.