commit:     f7b9302ecf014c0699f9114556755a7294ef2974
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Mar 31 17:51:40 2014 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Tue Apr  1 16:36:36 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=f7b9302e

Makefile: $ROVERLAY_TARGET_TYPE

ROVERLAY_TARGET_TYPE controls which files get installed:

when gentoo:
=> config/R-overlay.conf.install
=> no licenses file

when others:
=> config/R-overlay.conf.install.others
=> install files/licenses to $DATADIR/licenses

Also added a "generate-licenses" target for creating files/licenses.

---
 Makefile                   | 32 ++++++++++++++++++++++------
 bin/build/make-licenses.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 9a41011..06933f8 100644
--- a/Makefile
+++ b/Makefile
@@ -9,13 +9,16 @@ CONFDIR  := $(DESTDIR)etc
 
 BUILDDIR := ./tmp
 
+ROVERLAY_TARGET_TYPE := gentoo
+
 
 PYMOD_FILE_LIST := ./roverlay_files.list
 
-MANIFEST      := MANIFEST
-MANIFEST_TMP  := $(MANIFEST).tmp
+MANIFEST      := $(CURDIR)/MANIFEST
+LICENSES_FILE := $(CURDIR)/files/licenses
 
 MANIFEST_GEN  := ./bin/build/create_manifest.sh
+LICENSES_GEN  := ./bin/build/make-licenses.sh
 
 RV_SETUP      := ./bin/roverlay-setup
 
@@ -90,10 +93,18 @@ htmldoc: $(SRC_DOCDIR)/rst/usage.rst
 PHONY += generate-doc
 generate-doc: htmldoc
 
+$(MANIFEST): $(MANIFEST_GEN) FORCE
+       $< > $@
+
 PHONY += generate-manifest
-generate-manifest: $(MANIFEST_GEN)
-       $(MANIFEST_GEN) > $(MANIFEST_TMP)
-       mv -- $(MANIFEST_TMP) $(MANIFEST)
+generate-manifest: $(MANIFEST)
+
+$(LICENSES_FILE): $(LICENSES_GEN) FORCE | $(CURDIR)/files
+       $< $@
+
+PHONY += generate-licenses
+generate-licenses: $(CURDIR)/files/licenses
+
 
 
 $(CURDIR)/config/R-overlay.conf.install: $(RV_SETUP) FORCE | $(CURDIR)/config
@@ -133,7 +144,7 @@ generate-config: \
 
 
 PHONY += generate-files
-generate-files: generate-config generate-doc generate-manifest
+generate-files: generate-config generate-doc generate-manifest 
generate-licenses
 
 # creates a src tarball (.tar.bz2)
 #  !!! does not include config files
@@ -167,8 +178,13 @@ install-config-common:
        install -m 0644 -t $(CONFDIR)/roverlay \
                config/description_fields.conf config/repo.list \
                config/package_rules config/hookrc
+ifeq ($(ROVERLAY_TARGET_TYPE),gentoo)
        install -m 0644 -T \
                config/R-overlay.conf.install $(CONFDIR)/roverlay/R-overlay.conf
+else
+       install -m 0644 -T \
+               config/R-overlay.conf.install.others 
$(CONFDIR)/roverlay/R-overlay.conf
+endif
 
 PHONY += install-config-compressed
 install-config-compressed: install-config-common
@@ -187,9 +203,13 @@ install-config: install-config-common
 PHONY += install-data
 install-data:
        install -m 0755 -d \
+               $(DATADIR)/roverlay \
                $(DATADIR)/roverlay/shlib $(DATADIR)/roverlay/hooks \
                $(DATADIR)/roverlay/eclass $(DATADIR)/roverlay/mako_templates
 
+ifneq ($(ROVERLAY_TARGET_TYPE),gentoo)
+       install -m 0644 -- $(LICENSES_FILE) $(DATADIR)/roverlay/licenses
+endif
        install -m 0644 -t $(DATADIR)/roverlay/hooks files/hooks/*.sh
        install -m 0644 -t $(DATADIR)/roverlay/shlib files/shlib/*.sh
        chmod 0775 $(DATADIR)/roverlay/hooks/mux.sh

diff --git a/bin/build/make-licenses.sh b/bin/build/make-licenses.sh
new file mode 100755
index 0000000..77ae1d0
--- /dev/null
+++ b/bin/build/make-licenses.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+#  Creates a license list file for roverlay.
+#
+#  Usage: make-licenses [dest_file] [compression]
+#
+#  Environment variables:
+#  * PORTDIR: path to the main tree (= root of the "licenses" dir)
+#
+set -u
+
+die() { echo "${1:-error}" 1>&2; exit ${2:-2}; }
+
+mkmap() {
+   local x
+   # find -type f, ls -1, ...
+   set +f
+   for x in "${PORTDIR}/licenses/"*; do
+      [ ! -f "${x}" ] || echo "${x##*/}"
+   done
+}
+
+mkmap_bz2() { mkmap | bzip2 -c; }
+mkmap_xz()  { mkmap | xz -c; }
+mkmap_gz()  { mkmap | gzip -c; }
+
+get_mkmap_func() {
+   case "${1-}" in
+      '') func=mkmap ;;
+      bz2|xz|gz) func=mkmap_${1} ;;
+      *) die "unknown compression '${1-}'." 64 ;;
+   esac
+}
+
+if [ -z "${PORTDIR-}" ]; then
+   PORTDIR="$(portageq get_repo_path / gentoo)"
+   #PORTDIR="$(portageq get_repo_path $(portageq envvar EROOT) gentoo)"
+   [ -n "${PORTDIR}" ] || PORTDIR="$(portageq envvar PORTDIR)"
+   [ -n "${PORTDIR}" ] || die "failed to get \$PORTDIR"
+fi
+
+case "${1-}" in
+   ''|'-')
+      get_mkmap_func "${2-}" && ${func}
+   ;;
+   *.bz2|*.xz|*.gz)
+      [ -z "${2-}" ] || [ "${2}" = "${1##*.}" ] || die
+      get_mkmap_func "${1##*.}" && ${func} > "${1}"
+   ;;
+   *)
+      get_mkmap_func "${2-}" && ${func} > "${1}"
+   ;;
+esac

Reply via email to