From cfaff762363ad76f95fb6a4b55d0df9fc5427615 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Thu, 31 Jul 2014 20:12:05 +0800 Subject: =?UTF-8?q?=E6=8F=90=E4=BE=9B=E5=A4=9A=E6=95=B8=E9=81=B8=E9=A0=85?= =?UTF-8?q?=E7=9A=84=E9=A0=90=E8=A8=AD=E5=80=BC=EF=BC=8C=E4=B8=A6=E6=8E=A1?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E7=9A=84=20template=20=E8=99=95=E7=90=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/debian-defaults.mk | 11 +++++++++++ debian/debian.control.sh | 45 --------------------------------------------- debian/debian.deps.sh | 14 ++++++++++++++ debian/debian.mk | 22 +++++++++++++++++++--- freebsd/freebsd-defaults.mk | 18 ++++++++++++++++++ freebsd/freebsd.deps.sh | 12 ++++++++++++ freebsd/freebsd.makefile.sh | 42 ------------------------------------------ freebsd/freebsd.mk | 25 ++++++++++++++++++++++--- wspkg-mk/defaults.mk | 12 ++++++++++++ wspkg-mk/packages.mk | 14 +++++++++++++- 10 files changed, 121 insertions(+), 94 deletions(-) create mode 100644 debian/debian-defaults.mk delete mode 100755 debian/debian.control.sh create mode 100755 debian/debian.deps.sh create mode 100644 freebsd/freebsd-defaults.mk create mode 100755 freebsd/freebsd.deps.sh delete mode 100755 freebsd/freebsd.makefile.sh create mode 100644 wspkg-mk/defaults.mk diff --git a/debian/debian-defaults.mk b/debian/debian-defaults.mk new file mode 100644 index 0000000..648e285 --- /dev/null +++ b/debian/debian-defaults.mk @@ -0,0 +1,11 @@ +# vim: set ts=8 sts=8 sw=8 ft=make: +# Default settings for Debian + +# Control files and output packages +DEBIAN_IN_CONTROL_IN= $(INDIR)/$(NAME).control.in +DEBIAN_OUT_CONTROL= $(OUTDIR)/$(NAME).control +DEBIAN_OUT_PKGDIR= $(OUTDIR)/$(PKGNAME) +DEBIAN_OUT_PKG= $(OUTDIR)/$(PKGNAME).deb + +# Repository +DEBIAN_OUT_REPO= $(OUTDIR)/repo diff --git a/debian/debian.control.sh b/debian/debian.control.sh deleted file mode 100755 index f3ccee0..0000000 --- a/debian/debian.control.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -gen_list () { - loop_first=1 - for pkg in `cat "${list_file}"`; do - if [ "${loop_first}" = "1" ]; then - printf "%s" "${pkg}" - else - printf ", %s" "${pkg}" - fi - loop_first=0 - done -} - -control_in_file="$1" -: ${control_in_file:="debian.control.in"} - -list_file="$2" -: ${list_file:="debian.list"} - -exec 3< "${control_in_file}" - -saveIFS="${IFS}" -lineIFS="$(printf "\n")" -IFS="${lineIFS}" - -while read -r control_line 0<&3; do - case "${control_line}" in - "Version:"*) - printf "Version: %s\n" "`date '+%Y.%m.%d'`" - ;; - "Depends:"*) - printf "Depends: " - IFS="${saveIFS}" - gen_list - IFS="${lineIFS}" - printf "\n" - ;; - *) - echo "${control_line}" - ;; - esac -done - -exec 3<&- diff --git a/debian/debian.deps.sh b/debian/debian.deps.sh new file mode 100755 index 0000000..797b437 --- /dev/null +++ b/debian/debian.deps.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +list_file="$1" +: ${list_file:="debian.list"} + +loop_first=1 +for pkg in `cat "${list_file}"`; do + if [ "${loop_first}" = "1" ]; then + printf "%s" "${pkg}" + else + printf ", %s" "${pkg}" + fi + loop_first=0 +done diff --git a/debian/debian.mk b/debian/debian.mk index 698097b..73afff5 100644 --- a/debian/debian.mk +++ b/debian/debian.mk @@ -4,15 +4,19 @@ debian: $(DEBIAN_OUT_PKG) # debian.control.in + debian.list --(debian.control.sh)-> debian.control -control_script = $(BACKENDDIR)/debian.control.sh +control_script = $(BACKENDDIR)/debian.deps.sh control_deps = \ $(control_script) \ $(DEBIAN_IN_CONTROL_IN) \ $(WSPKG_OUT_LIST) $(DEBIAN_OUT_CONTROL): $(control_deps) - $(AT_GEN)$(control_script) $(DEBIAN_IN_CONTROL_IN) $(WSPKG_OUT_LIST) \ - > $(DEBIAN_OUT_CONTROL) $(RM_IF_FAIL) + $(AT_GEN)sed \ + -e "s|@NAME|$(NAME)|g" \ + -e "s|@PKGNAME@|$(PKGNAME)|g" \ + -e "s|@TODAY@|`date '+%Y.%m.%d'`|g" \ + -e "s|@DEPS@|`$(control_script) $(WSPKG_OUT_LIST)`|g" \ + $(DEBIAN_IN_CONTROL_IN) > $(DEBIAN_OUT_CONTROL) $(RM_IF_FAIL) # debian.control -> 217-meta.deb $(DEBIAN_OUT_PKG): $(DEBIAN_OUT_CONTROL) @@ -27,3 +31,15 @@ debian-install: $(DEBIAN_OUT_PKG) $(AT_COPY)cp -pf $(DEBIAN_OUT_PKG) $(DEBIAN_OUT_REPO) $(AT_GEN)cd $(DEBIAN_OUT_REPO) && dpkg-scanpackages . > Packages $(AT_GEN)gzip -9f $(DEBIAN_OUT_REPO)/Packages + +debian-show: + @echo "-- Control file" + @echo "I: DEBIAN_IN_CONTROL_IN (control file template) = $(DEBIAN_IN_CONTROL_IN)" + @echo "O: DEBIAN_OUT_CONTROL (generated control file) = $(DEBIAN_OUT_CONTROL)" + @echo "" + @echo "-- Meta-package" + @echo "O: DEBIAN_OUT_PKGDIR (package source directory) = $(DEBIAN_OUT_PKGDIR)" + @echo "O: DEBIAN_OUT_PKG (built meta-package) = $(DEBIAN_OUT_PKG)" + @echo "" + @echo "-- Repository" + @echo "O: DEBIAN_OUT_REPO = $(DEBIAN_OUT_REPO)" diff --git a/freebsd/freebsd-defaults.mk b/freebsd/freebsd-defaults.mk new file mode 100644 index 0000000..ad14d49 --- /dev/null +++ b/freebsd/freebsd-defaults.mk @@ -0,0 +1,18 @@ +# vim: set ts=8 sts=8 sw=8 ft=make: +# Default settings for FreeBSD + +# Makefile template +FREEBSD_OUT_PORTS= $(OUTDIR)/$(NAME).ports +FREEBSD_IN_MAKEFILE_IN= $(INDIR)/$(NAME).makefile.in +FREEBSD_OUT_MAKEFILE= $(OUTDIR)/$(NAME).makefile + +# Output ports directory +FREEBSD_IN_PKGDESC= $(INDIR)/$(NAME).local.$(PKGNAME).pkg-descr +FREEBSD_OUT_PKGDIR= $(OUTDIR)/$(PKGNAME) +FREEBSD_OUT_PKGDESC= $(FREEBSD_OUT_PKGDIR)/pkg-descr +FREEBSD_OUT_PKG= $(FREEBSD_OUT_PKGDIR)/Makefile + +# Update the ports tree +FREEBSD_OUT_PORTS_CATEGORY_MAKEFILE= $(INDIR)/$(NAME).local.Makefile +FREEBSD_OUT_PORTS_CATEGORY_MAKEFILE_INC= $(INDIR)/$(NAME).local.Makefile.inc +FREEBSD_OUT_PORTS_CATEGORY= local diff --git a/freebsd/freebsd.deps.sh b/freebsd/freebsd.deps.sh new file mode 100755 index 0000000..7330b3b --- /dev/null +++ b/freebsd/freebsd.deps.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +ports_file="$1" +: ${ports_file:="freebsd.ports"} + +exec 4< "${ports_file}" + +while read -r pkg_name pkg_ports 0<&4; do + printf " %s>=0:"'${PORTSDIR}'"/%s ^%%" "${pkg_name}" "${pkg_ports}" +done + +exec 4<&- diff --git a/freebsd/freebsd.makefile.sh b/freebsd/freebsd.makefile.sh deleted file mode 100755 index 4a1c23a..0000000 --- a/freebsd/freebsd.makefile.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -gen_list () { - exec 4< "${ports_file}" - - while read -r pkg_name pkg_ports 0<&4; do - echo " ${pkg_name}>=0:"'${PORTSDIR}'"/${pkg_ports} \\" - done - - exec 4<&- -} - -makefile_in_file="$1" -: ${makefile_in_file:="freebsd.makefile.in"} - -ports_file="$2" -: ${ports_file:="freebsd.ports"} - -exec 3< "${makefile_in_file}" - -saveIFS="${IFS}" -lineIFS="$(printf "\n")" -IFS="${lineIFS}" - -while read -r makefile_line 0<&3; do - case "${makefile_line}" in - "PORTVERSION="*) - printf "PORTVERSION=\t%s\n" "`date '+%Y.%m.%d'`" - ;; - "RUN_DEPENDS+="*) - echo 'RUN_DEPENDS+= \' - IFS="${saveIFS}" - gen_list - IFS="${lineIFS}" - ;; - *) - echo "${makefile_line}" - ;; - esac -done - -exec 3<&- diff --git a/freebsd/freebsd.mk b/freebsd/freebsd.mk index 6c9a788..2d9ed19 100644 --- a/freebsd/freebsd.mk +++ b/freebsd/freebsd.mk @@ -16,15 +16,20 @@ $(FREEBSD_OUT_PORTS): $(ports_deps) > $(FREEBSD_OUT_PORTS) $(RM_IF_FAIL) # freebsd.makefile.in + freebsd.ports --(freebsd.makefile.sh)-> freebsd.makefile -makefile_script = $(BACKENDDIR)/freebsd.makefile.sh +makefile_script = $(BACKENDDIR)/freebsd.deps.sh makefile_deps = \ $(makefile_script) \ $(FREEBSD_IN_MAKEFILE_IN) \ $(FREEBSD_OUT_PORTS) $(FREEBSD_OUT_MAKEFILE): $(makefile_deps) - $(AT_GEN)$(makefile_script) \ - $(FREEBSD_IN_MAKEFILE_IN) $(FREEBSD_OUT_PORTS) \ + $(AT_GEN)sed \ + -e "s|@NAME|$(NAME)|g" \ + -e "s|@PKGNAME@|$(PKGNAME)|g" \ + -e "s|@TODAY@|`date '+%Y.%m.%d'`|g" \ + -e "s|@DEPS@|`$(makefile_script) $(FREEBSD_OUT_PORTS)`|g" \ + $(FREEBSD_IN_MAKEFILE_IN) | \ + tr '^' '\\' | tr '%' '\n' \ > $(FREEBSD_OUT_MAKEFILE) $(RM_IF_FAIL) # freebsd.makefile -> 217/Makefile @@ -45,3 +50,17 @@ freebsd-install: freebsd $(FREEBSD_OUT_PORTS_CATEGORY_MAKEFILE) \ $(FREEBSD_OUT_PORTS_CATEGORY_MAKEFILE_INC) \ $(FREEBSD_OUT_PKGDIR) + +freebsd-show: + @echo "-- Ports mapping" + @echo "O: FREEBSD_OUT_PORTS (generated ports mapping) = $(FREEBSD_OUT_PORTS)" + @echo "" + @echo "-- Meta-ports Makefile" + @echo "I: FREEBSD_IN_MAKEFILE_IN (Makefile template) = $(FREEBSD_IN_MAKEFILE_IN)" + @echo "O: FREEBSD_OUT_MAKEFILE (generated Makefile) = $(FREEBSD_OUT_MAKEFILE)" + @echo "" + @echo "-- Meta-ports" + @echo "I: FREEBSD_IN_PKGDESC (meta-ports description) = $(FREEBSD_IN_PKGDESC)" + @echo "O: FREEBSD_OUT_PKGDIR (meta-ports) = $(FREEBSD_OUT_PKGDIR)" + @echo "O: FREEBSD_OUT_PKGDESC (copied meta-ports description) = $(FREEBSD_OUT_PKGDESC)" + @echo "O: FREEBSD_OUT_PKG (copied meta-ports Makefile) = $(FREEBSD_OUT_PKG)" diff --git a/wspkg-mk/defaults.mk b/wspkg-mk/defaults.mk new file mode 100644 index 0000000..8ab771f --- /dev/null +++ b/wspkg-mk/defaults.mk @@ -0,0 +1,12 @@ +# vim: set ts=8 sts=8 sw=8 ft=make: + +# Default input and output directories +INDIR= $(NAME) +OUTDIR= $(NAME)/out + +# Default platform-independent settings +WSPKG_IN_PLATFORM_PKG= $(INDIR)/$(NAME).pkg +WSPKG_IN_PLATFORM_SED= $(INDIR)/$(NAME).sed +WSPKG_OUT_LIST= $(OUTDIR)/$(NAME).list + +include $(WSPKGDIR)/$(BACKEND)/$(BACKEND)-defaults.mk diff --git a/wspkg-mk/packages.mk b/wspkg-mk/packages.mk index 3766fe2..090b9d2 100644 --- a/wspkg-mk/packages.mk +++ b/wspkg-mk/packages.mk @@ -34,10 +34,22 @@ DEPLIST_m4= $(DEPLIST_regular) # Do tasks all: $(WSPKG_OUT_LIST) $(BACKEND) -install: $(BACKEND)-install $(WSPKG_OUT_LIST): $(DEPLIST) @mkdir -p $(INDIR) $(OUTDIR) $(MKLIST) +clean: + rm -rf $(OUTDIR) +show-basic: + @echo "-- V: regular variable / I: input / O: output" + @echo "V: NAME (project name) = $(NAME)" + @echo "V: PKGNAME (package name) = $(PKGNAME)" + @echo "I: WSPKG_IN_COMMON (shared package list) = $(WSPKG_IN_COMMON)" + @echo "I: WSPKG_IN_PLATFORM_PKG (platform-specific package list) = $(WSPKG_IN_PLATFORM_PKG)" + @echo "I: WSPKG_IN_PLATFORM_SED (platform-specific package mask) = $(WSPKG_IN_PLATFORM_SED)" + @echo "O: WSPKG_OUT_LIST (generated package list) = $(WSPKG_OUT_LIST)" + @echo "" +show: show-basic $(BACKEND)-show +install: $(BACKEND)-install # Include backend-specific makefiles include $(BACKENDDIR)/$(BACKEND).mk -- cgit v1.2.3