phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] old/packages Makefile, 1.1 conf, 1.1 version, 1.1 php


From: skwashd
Subject: [Phpgroupware-cvs] old/packages Makefile, 1.1 conf, 1.1 version, 1.1 phpgw-pkgs-do.pl, 1.1 do, 1.1
Date: Thu, 5 May 2005 02:56:00 +0200

Update of old/packages

Added Files:
     Branch: MAIN
            Makefile 
            conf 
            version 
            phpgw-pkgs-do.pl 
            do 

Log Message:
cvs clean up

====================================================
Index: Makefile
# -----------------------------------------------------------------------------
# First coded by Luca - De Whiskey's - De Vitis <address@hidden> on 2002.6.26
# -----------------------------------------------------------------------------
# $Id: Makefile,v 1.1 2005/05/05 00:56:39 skwashd Exp $
#
#   The phpgroupware packages utilities.
#   Copyright (C) 2002  Luca - De Whiskey's - De Vitis <address@hidden>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   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 General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

INCLUDES ?= /usr/share/phpgroupware-packages
CONF = $(INCLUDES)/conf

include $(CONF)

# -----------------------------------------------------------------------------
# _NON_ editable options: do _NOT_ edit, unless you are _ABSOLUTELY_ sure.
# -----------------------------------------------------------------------------
CVS = -path \*CVS\* -or -name .cvs\*
EXCLUDED_MODULES += cron
EXCLUDED_MODULES += debian
EXCLUDED_MODULES += transy
EXCLUDED_MODULES += felamimail
EXCLUDED_MODULES += squirrelmail
EXCLUDED_MODULES += syncml-server
EXCLUDED_MODULES += old
EXCLUDED_MODULES_PATHS = -path \. -or $(CVS) -or -path \*$(BUILD_DIRECTORY)\*
EXCLUDED_MODULES_PATHS += $(patsubst %,-or -path \*%\*,$(EXCLUDED_MODULES))
MODULES_PATHS = -type d -maxdepth 1 -not \( $(EXCLUDED_MODULES_PATHS) \)
MODULES := $(shell find $(MODULES_PATHS) -printf "%f ")

EXCLUDED_SOURCE_FILES = -name \*.sgml -or $(CVS) -or -path 
\*$(BUILD_DIRECTORY)\*
SOURCE_FILES = -type f -not \( $(EXCLUDED_SOURCE_FILES) \)

VERSION := $(shell $(SEDN) 's/\$Name: \([^ ]\+\)/\1/p' < packages/version)
ifndef VERSION
VERSION := $(shell date +"%Y%m%d")
CHANGELOG_VERSION = '/^Version/ s/^[^ ]\+ \([^ ]\+\)/\1/p'
UPSTREAM_VERSION = 's/^\([^-]\+\)-.*$$/\1/p'
else
UPSTREAM_VERSION := 's/_/./g ; s/^[^-]\+-\(.*\)$$/\1/p'
endif
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Documents backends and extensions.
# -----------------------------------------------------------------------------
# - txt:                Plain text file format.
# - onehtml:    HTML file format (single file output).
# - rtf:                RTF file format.
# - ps:                 PostScript file format.
#
# We could actually use more kinds of formats, but i don't see the need.

BACKENDS := txt onehtml rtf

# Mapipng backends in extensions is simple:
# txt           => .txt
# onehtml       => .html
# rtf           => .rtf
# ps            => .ps

txt     = txt
onehtml = html
rtf     = rtf

# jadetex is not required by sgmltools, so, if present, add the ps backend and
# extension.
ifneq ($(shell which jadetex),)
BACKENDS += ps
ps = ps
endif
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Packages rules.
# -----------------------------------------------------------------------------

build: $(PACKAGES)

$(PACKAGES): % : %.requirements $(foreach module,$(MODULES),$(module).%.builded)

ALL_BUILDED = $(foreach format,$(PACKAGES),%.$(format).builded)

$(MODULES): % : %.all.builded

$(MODULES:%=%.all.builded): %.all.builded : requirements $(ALL_BUILDED)

# -----------------------------------------------------------------------------
# Rules to check requirements
# -----------------------------------------------------------------------------
require = $(if $(shell which $(1)),,$(error Command not found: `$(1)'))

requirements: $(PACKAGES:%=%.requirements)

default.requirements:
        $(call require,find)
        $(call require,install)
        $(call require,sgmltools)
        $(call require,tidy)
        $(call require,dpkg-parsechangelog)
        touch $(@)

tar.gz.requirements: default.requirements
        $(call require,tar)
        $(call require,gzip)
        touch $(@)

tar.bz2.requirements: default.requirements
        $(call require,tar)
        $(call require,bzip2)
        touch $(@)

orig.tar.gz.requirements: tar.gz.requirements
        touch $(@)

deb.requirements: orig.tar.gz.requirements
        $(call require,fakeroot)
        $(call require,dch)
        touch $(@)

$(foreach format,rpm tgz slp,$(format).requirements): deb.requirements
        $(call require,alien)
        touch $(@)

pkg.requirements: deb.requirements
        $(call require,pkginfo)
        $(call require,pkgtrans)
        touch $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variable and targets to compile source files (SGML documents)
# -----------------------------------------------------------------------------

compile: $(MODULES:%=%.source.files.compiled)

$(MODULES:%=%.source.files.compiled): \
        %.source.files.compiled : %.source.files.sgml %.source.files
        for sgml in $(shell cat $(@:compiled=sgml)) ; do \
                dirname=$$(dirname $$sgml) ;\
                doc=$$(basename $$dirname);\
                for backend in $(BACKENDS) ; do \
                        $(SGMLTOOLS) --backend=$${backend} $${sgml} ;\
                        if [ -f $$dirnme/index.$$backend ] ; then \
                                $(INSTALL_FILE) \
                                        $$dirname/index.$$backend \
                                        
$$dirname/../../$$backend/$$doc.$$backend ;\
                                $(RM) $$dirname/index.$$backend ;\
                                echo $$dirname/../../$$backend/$$doc.$$backend 
>> $(@) ;\
                        elif [ -d $$dirname/index ] ; then \
                                $(INSTALL_DIRECTORY) 
$$dirname/../../html/$$doc/ ;\
                                for html in $$dirname/index/* ; do \
                                        $(TIDY) < $$html > 
$$dirname/../../html/$$doc/$$(basename $$html) ;\
                                        echo 
$$dirname/../../html/$$doc/$$(basename $$html) >> $(@) ;\
                                done ;\
                                $(RM) -r $$dirname/index/ ;\
                        fi ;\
                done ;\
        done
        touch $(@)

$(MODULES:%=%.source.files.sgml):
        find $(@:.source.files.sgml=)/doc -name index.sgml -fprint $(@)

$(MODULES:%=%.source.files):
        find $(@:.source.files=) $(SOURCE_FILES) -fprint $(@)

$(MODULES:%=%.source.version):
        $(if $(CHANGELOG_VERSION), \
                cd $(@:.source.version=) && \
                        $(DPKG_PARSECHANGELOG) | $(SEDN) $(CHANGELOG_VERSION) > 
../$(@) \
        , \
                echo $(VERSION) > $(@) \
        )
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .tar.gz archives.
# -----------------------------------------------------------------------------
TAR_GZ_ARCHIVES = %-$(VERSION).tar.gz
TAR_GZ_REQUIRED = tar.gz.requirements %.source.files

$(MODULES:%=%.tar.gz.builded): %.tar.gz.builded : $(TAR_GZ_ARCHIVES)
        echo $(@:%.tar.gz.builded=$(TAR_GZ_ARCHIVES)) > $(@)

$(MODULES:%=$(TAR_GZ_ARCHIVES)): $(TAR_GZ_ARCHIVES) : $(TAR_GZ_REQUIRED)
        $(TAR) --files-from $(@:$(TAR_GZ_ARCHIVES)=%.source.files) | \
                $(GZIP) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .tar.bz2 archives.
# -----------------------------------------------------------------------------
TAR_BZ2_ARCHIVES = %-$(VERSION).tar.bz2
TAR_BZ2_REQUIRED = tar.bz2.requirements %.source.files

$(MODULES:%=%.tar.bz2.builded): %.tar.bz2.builded : $(TAR_BZ2_ARCHIVES)
        echo $(@:%.tar.bz2.builded=$(TAR_BZ2_ARCHIVES)) > $(@)

$(MODULES:%=$(TAR_BZ2_ARCHIVES)): $(TAR_BZ2_ARCHIVES) : $(TAR_BZ2_REQUIRED)
        $(TAR) --files-from $(@:$(TAR_BZ2_ARCHIVES)=%.source.files) | \
                $(BZIP2) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .orig.tar.gz archives.
# -----------------------------------------------------------------------------
ORIG_BUILDED = .orig.tar.gz.builded
ORIG_REQUIRED = orig.tar.gz.requirements %.source.clean %.source.version
ORIG_MODULE = $(@:$(ORIG_BUILDED)=)
ORIG_VERSION = \
        $(shell $(SEDN) $(UPSTREAM_VERSION) < 
$(@:$(ORIG_BUILDED)=.source.version))
ORIG_PACKAGE_NAME = $(subst _,-,$(ORIG_MODULE))
ORIG_SOURCE_DIRECTORY = $(ORIG_PACKAGE_NAME)-$(ORIG_VERSION).orig
ORIG_BUILD_DIRECTORY = $(BUILD_DIRECTORY)/$(ORIG_SOURCE_DIRECTORY)
ORIG_TAR_GZ = $(ORIG_PACKAGE_NAME)_$(ORIG_VERSION).orig.tar.gz

$(MODULES:%=%$(ORIG_BUILDED)): %$(ORIG_BUILDED) : $(ORIG_REQUIRED)
        cd $(ORIG_MODULE) && find $(SOURCE_FILES) -exec \
                $(INSTALL_FILE) {} ../$(ORIG_BUILD_DIRECTORY)/{} \;
        $(TAR) -C $(BUILD_DIRECTORY) $(ORIG_SOURCE_DIRECTORY) | \
                $(GZIP) > $(ORIG_TAR_GZ)
        echo $(ORIG_TAR_GZ) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .deb packages.
# -----------------------------------------------------------------------------
DEB_PACKAGE_NAME = phpgroupware-$(subst _,-,$(@:.deb.builded=))
ifdef CHANGELOG_VERSION
DEB_VERSION = $(shell cat $(@:.deb.builded=.source.version))
DEB_UPSTREAM_VERSION = $(shell echo $(DEB_VERSION) | $(SEDN) 
$(UPSTREAM_VERSION))
DEB_NEW_VERSION = $(DEB_VERSION).$(VERSION)
else
DEB_VERSION = \
        $(shell $(SEDN) $(UPSTREAM_VERSION) < $(@:.deb.builded=.source.version))
DEB_NEW_VERSION = $(DEB_VERSION)-0
endif
DEB_SOURCE_DIRECTORY = $(DEB_PACKAGE_NAME)-$(DEB_UPSTREAM_VERSION)
DEB_BUILD_DIRECTORY = $(BUILD_DIRECTORY)/$(DEB_SOURCE_DIRECTORY)
DEB_LIST = "s/^[^']\+' in \`\.\.\/\([^']\+\).*/\1/p"
DEB_BUILDED = $(DEB_BUILD_DIRECTORY)/debian/.builded

DEB_FILES = -type f -not \( $(CVS) \)

DEB_REQUIRED = deb.requirements %.source.clean %.source.version

$(MODULES:%=%.deb.builded): %.deb.builded : $(DEB_REQUIRED)
        if grep -q ^Description $(@:.deb.builded=)/debian/control ; then \
                cd $(@:.deb.builded=) ;\
                        find $(DEB_FILES)  -exec $(INSTALL_FILE) \
                                {} ../$(DEB_BUILD_DIRECTORY)/{} \; ;\
                cd - ;\
                cd $(DEB_BUILD_DIRECTORY) ;\
                        $(DCH) $(DEB_NEW_VERSION) \
                                "Automatically builded on $(shell date 
+"%Y.%m.%d")" ;\
                cd - ;\
                $(CHMOD) +x $(DEB_BUILD_DIRECTORY)/debian/rules ;\
                cd $(DEB_BUILD_DIRECTORY) ;\
                        $(DEBIAN_RULES) binary ;\
                cd - ;\
                $(RM) $(@) ;\
                for package in $$($(SEDN) $(DEB_LIST) < $(DEB_BUILDED)) ; do \
                        $(MV) $(BUILD_DIRECTORY)/$${package} . && \
                        echo $${package} >> $(@) ;\
                done ;\
        else \
                touch $(@) ;\
        fi
# -----------------------------------------------------------------------------

COMPILED = 's/^\([^ ]\+\).*$$/\1/p'
compiled = \
        if [ -s $(1).deb.builded ] ; then \
                $(ALIEN) --to-$(2) $(shell cat $(1).deb.builded) | $(SEDN) 
$(COMPILED) ;\
        fi

# -----------------------------------------------------------------------------
# Specific variables and targets to build .rpm packages.
# -----------------------------------------------------------------------------
$(MODULES:%=%.rpm.builded): %.rpm.builded : rpm.requirements %.deb.builded
        $(call compiled,$(@:.rpm.builded=),rpm) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .tgz packages.
# -----------------------------------------------------------------------------
$(MODULES:%=%.tgz.builded): %.tgz.builded : tgz.requirements %.deb.builded
        $(call compiled,$(@:.tgz.builded=),tgz) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .slp packages.
# -----------------------------------------------------------------------------
$(MODULES:%=%.slp.builded): %.slp.builded : slp.requirements %.deb.builded
        $(call compiled,$(@:.slp.builded=),slp) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build .pkg packages.
# -----------------------------------------------------------------------------
$(MODULES:%=%.pkg.builded): %.pkg.builded : pkg.requirements %.deb.builded
        $(call compiled,pkg) > $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Specific variables and targets to build core package.
# -----------------------------------------------------------------------------
CORE_MODULES  = addressbook
CORE_MODULES += admin
CORE_MODULES += calendar
CORE_MODULES += email
CORE_MODULES += manual
CORE_MODULES += nntp
CORE_MODULES += notes
CORE_MODULES += phpgwapi
CORE_MODULES += preferences
CORE_MODULES += setup
CORE_MODULES += todo

CORE_BUILD_DIRECTORY = $(BUILD_DIRECTORY)/core
CORE_ARCHIVES = phpgroupware-core-$(VERSION).tar.%
CORE_PACKAGES := $(patsubst %,$(CORE_ARCHIVES),gz bz2)
CORE_SOURCES = phpgroupware $(CORE_MODULES)
CORE_SOURCES_COMPILED = $(patsubst %,%.source.files.compiled,$(CORE_SOURCES))

gz = $(GZIP)
bz2 = $(BZIP2)

core: core.packages.builded

core.packages.builded: $(CORE_PACKAGES)
        echo $(^) > $(@)

$(CORE_PACKAGES): tar.gz.requirements tar.bz2.requirements core.source.files
        $(TAR) -C $(CORE_BUILD_DIRECTORY) phpgroupware | \
                $($(@:core-$(VERSION).tar.=)) >> $(@)

core.source.files: # $(CORE_SOURCES_COMPILED)
        find phpgroupware $(SOURCE_FILES) \
                -exec $(INSTALL_FILE) {} $(CORE_BUILD_DIRECTORY)/{} \;
        find $(CORE_MODULES) $(SOURCE_FILES) \
                -exec $(INSTALL_FILE) {} 
$(CORE_BUILD_DIRECTORY)/phpgroupware/{} \;
        touch $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# The release target.
# -----------------------------------------------------------------------------
release: build core
        for format in $(PACKAGES) ; do \
                cat *.$${format}.builded | while read file ; do \
                        $(INSTALL_FILE) $${file} 
$(RELEASE_DIRECTORY)/$${format}/$${file} ;\
                done ;\
        done
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# The install target.
# -----------------------------------------------------------------------------
install: $(MODULES:%=%.files.compiled)
        find phpgroupware $(SOURCE_FILES) -exec \
                $(INSTALL_FILE) {} $(INSTALL_DIRECTORY)/{} \;
        find $(filter-out phpgroupware,$(MODULES)) $(SOURCE_FILES) -exec \
                $(INSTALL_FILE) {} $(INSTALL_DIRECTORY)/phpgroupware/{} \;
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# The lint target.
# -----------------------------------------------------------------------------

include $(wildcard $(INCLUDES)/lint/checks/*.check)

lint: $(MODULES:%=%.lint.report)

LINT_INFOS = 's/{MODULE}/$(@:.lint.report=)/ ; s/{VERSION}/$(VERSION)/g'
LINT_CHECKS = $(foreach check,$(CHECKS),%.lint.$(check))

$(MODULES:%=%.lint.report): %.lint.report : $(LINT_CHECKS)
        for check in $(CHECKS) ; do \
                if test -s $(@:report=)$${check} ; then \
                        $(SED) $(LINT_INFOS) < \
                                $(INCLUDES)/lint/infos/$${check}.info >> $(@) ;\
                fi ;\
        done
        touch $(@)
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# The clean target.
# -----------------------------------------------------------------------------
$(MODULES:%=%.source.clean):
        if test -f $(@:clean=files.compiled) ; then \
                cat $(@:clean=files.compiled) | xargs $(RM) ;\
        fi
        -cd $(@:.source.clean=) && $(DEBIAN_RULES) clean

clean: $(MODULES:%=%.source.clean)
        for list in $(wildcard *.builded) ; do \
                cat $${list} | xargs $(RM) ;\
        done
        -$(RM) *.requirements
        -$(RM) *.lint.*
        -$(RM) *.builded
        -$(RM) *.source.*
        -$(RM) --recursive $(BUILD_DIRECTORY)
# -----------------------------------------------------------------------------

.PHONY: build compile clean release install lint core $(MODULES) $(PACKAGES)

====================================================
Index: conf
#!make
#
# -----------------------------------------------------------------------------
# First coded by Luca - De Whiskey's - De Vitis <address@hidden> on 2002.6.20
# -----------------------------------------------------------------------------
# $Id: conf,v 1.1 2005/05/05 00:56:39 skwashd Exp $
#
#   The phpgroupware packages utilities.
#   Copyright (C) 2002  Luca - De Whiskey's - De Vitis <address@hidden>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   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 General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# -----------------------------------------------------------------------------
# Archive types and packages formats.
# -----------------------------------------------------------------------------
# - tar.gz:     Gzip compressed tar archive.
# - tar.bz2:    Bzip2 compressed tar archive.
# - deb:        Dpkg package format (i.e. Debian).
# - rpm:        [1] RPM package format (i.e. RedHat).
# - slp:        [1] SLP package format (i.e. Stampede).
# - tgz:        [1] TGZ package format (i.e. Slackware).
#
# -----------------------------------------------------------------------------
# Other packages formats.
# -----------------------------------------------------------------------------
# - core:           Not really a format: build core-$(VERSION).tar.gz and
#                   core-$(VERSION).tar.bz2
# - orig.tar.gz:    Gzip Compressed archive used to build official Debian
#                   packages.
# - pkg:            [1] Solaris package format. Cannot build this one, because
#                   we miss Solaris specific tools. I've included it anyway:
#                   just incase...
#
# [1] Package is of an alien type. This means that we have no one who really
#     build package in this format. To build them we will use the alien(1) 
command.

# -----------------------------------------------------------------------------
# Editable Variables: I'ts better to overwrite them from the command line.
# -----------------------------------------------------------------------------
PACKAGES = tar.gz tar.bz2 deb rpm tgz slp
BUILD_DIRECTORY = .build
RELEASE_DIRECTORY = /home/ftp/phpgroupware
INSTALL_DIRECTORY = /var/www
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Editable Options: edit _only_ if you know what are you doing.
# -----------------------------------------------------------------------------
rm                  := $(shell which rm)
mv                  := $(shell which mv)
chmod               := $(shell which chmod)
sed                 := $(shell which sed)
gzip                := $(shell which gzip)
tar                 := $(shell which tar)
install             := $(shell which install)
bzip2               := $(shell which bzip2)
alien               := $(shell which alien)
sgmltools           := $(shell which sgmltools)
fakeroot            := $(shell which fakeroot)
dpkg_parsechangelog := $(shell which dpkg-parsechangelog)
dch                 := $(shell which dch)
tidy                            := $(shell which tidy)

RM                  = $(rm) --force
MV                  = $(mv) --force --update
CHMOD               = $(chmod) --silent
SED                 = $(sed)
SEDN                = $(sed) --silent
GZIP                = $(gzip) --best --stdout
BZIP2               = $(bzip2) --best --stdout
TAR                 = $(tar) --create
INSTALL             = $(install) -D --mode=644
INSTALL_FILE            = $(install) -D --mode=644
INSTALL_DIRECTORY       = $(install) -d --mode=755
ALIEN               = $(fakeroot) $(alien) --keep-version
SGMLTOOLS           = $(sgmltools)
DEBIAN_RULES        = $(fakeroot) debian/rules
DPKG_PARSECHANGELOG = $(dpkg_parsechangelog)
DCH                 = $(dch) --newversion
TIDY                            = $(tidy) -i -clean
# -----------------------------------------------------------------------------

====================================================
Index: version
$Name:  $

====================================================
Index: phpgw-pkgs-do.pl
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------
# First coded by Luca - De Whiskey's - De Vitis <address@hidden> on 2002.06.25
# -----------------------------------------------------------------------------
# $Id: phpgw-pkgs-do.pl,v 1.1 2005/05/05 00:56:39 skwashd Exp $
#
#   The phpgroupware packages utilities.
#   Copyright (C) 2002  Luca - De Whiskey's - De Vitis <address@hidden>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   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 General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

use Getopt::Long;
use Pod::Usage;
use strict;
use vars qw(
    $wd
    %default %option
    @cvs
    @make %target %variable %package
);

%default = (
    'r' => 'HEAD',
    'C' => '/var/lib/phpgroupware/source',
    'f' => '/usr/share/phpgroupware-packages/Makefile',
);

%option = (
    'g' => \$default{'g'}, 'get'                    => \$default{'g'},
    'r' => \$default{'r'}, 'cvs-release'            => \$default{'r'},
    'd' => \$default{'d'}, 'cvs-date'               => \$default{'d'},
    'A' => \$default{'A'}, 'build-all'              => \$default{'A'},
    'G' => \$default{'G'}, 'build-tar-gz'           => \$default{'G'},
    'B' => \$default{'B'}, 'build-tar-bz2'          => \$default{'B'},
    'O' => \$default{'O'}, 'build-orig-tar-gz'      => \$default{'O'},
    'D' => \$default{'D'}, 'build-deb'              => \$default{'D'},
    'R' => \$default{'R'}, 'build-rpm'              => \$default{'R'},
    'T' => \$default{'T'}, 'build-tgz'              => \$default{'T'},
    'S' => \$default{'S'}, 'build-slp'              => \$default{'S'},
    'P' => \$default{'P'}, 'build-pkg'              => \$default{'P'},
    'k' => \$default{'k'}, 'build-core'             => \$default{'k'},
    'l' => \$default{'l'}, 'lint'                   => \$default{'l'},
    'M' => \$default{'M'}, 'modules-list'           => \$default{'M'},
    'F' => \$default{'F'}, 'packages-formats-list'  => \$default{'F'},
    'X' => \$default{'X'}, 'excluded-modules-list'  => \$default{'X'},
    'b' => \$default{'b'}, 'build-dir'              => \$default{'b'},
    'p' => \$default{'p'}, 'release-dir'            => \$default{'p'},
    'i' => \$default{'i'}, 'install-dir'            => \$default{'i'},
    'C' => \$default{'C'}, 'dir'                    => \$default{'C'},
    'I' => \$default{'I'}, 'include-dir'            => \$default{'I'},
    'f' => \$default{'f'}, 'file'                   => \$default{'f'},
    'h' => \$default{'h'}, 'help'                   => \$default{'h'},
    'm' => \$default{'m'}, 'man'                    => \$default{'m'},
    'q' => \$default{'q'}, 'quiet'                  => \$default{'q'}
);

Getopt::Long::Configure('gnu_getopt');
Getopt::Long::GetOptions(
    \%option,
        'g|get:s',
        'r|cvs-release=s',
        'd|cvs-date=s',
        'A|build-all=s',
        'G|build-tar-gz=s',
        'B|build-tar-bz2=s',
        'O|build-orig-tar-gz=s',
        'D|build-deb=s',
        'R|build-rpm=s',
        'T|build-tgz=s',
        'S|build-slp=s',
        'P|build-pkg=s',
        'l|lint=s',
        'k|build-core',
        'M|modules-list=s',
        'F|packages-formats-list=s',
        'X|excluded-modules-list=s',
        'b|build-dir=s',
        'p|release-dir=s',
        'i|install-dir=s',
        'C|change-dir=s',
        'I|include-dir=s',
        'f|file=s',
        'h|help',
        'q|quiet',
        'm|man'
) or pod2usage({ -verbose => 0, -exitval => 0});

if (defined($default{'h'})) {
    pod2usage({ -verbose => 0, -exitval => 0});
} elsif (defined($default{'m'})) {
    pod2usage({ -verbose => 1, -exitval => 0});
}

$wd = "${default{'C'}}/${default{'r'}}";
if (not -d $wd) {
    print("mkdir $wd\n");
}
print("chdir $wd\n");

@make = ('make',"-f ${default{'f'}}");
@cvs = ('cvs','get',"-r ${default{'r'}}");

if (defined($default{'q'})) {
    push(@cvs,'-Q');
    push(@make, '-s');
}
if (defined($default{'d'})) {
    push(@cvs,"-D ${default{'d'}}");
}
if (defined($default{'g'})) {
    if ($default{'g'}) {
        push(@cvs,split(',',$default{'g'}));
    } else {
        push(@cvs,'all');
    }
}
if (scalar(@cvs) > 3) {
    print("@cvs\n");
}

%package = (
    'A' => 'build',
    'G' => 'tar.gz',
    'B' => 'tar.bz2',
    'O' => 'orig.tar.gz',
    'D' => 'deb',
    'R' => 'rpm',
    'T' => 'tgz',
    'S' => 'slp',
    'P' => 'pkg'
);

foreach my $format (keys(%package)) {
    if (defined($default{$format})) {
        foreach my $module (split(',',$default{$format})) {
            push(@make,"$module.".$package{$format}.".builded");
        }
    }
}
if (defined($default{'l'})) {
    foreach my $module (split(',',$default{'l'})) {
        push(@make,"$module.lint.report");
    }
}
%variable = (
    'M' => 'MODULES',
    'F' => 'FORMATS',
    'I' => 'CONF',
    'X' => 'EXCLUDED_MODULES',
    'b' => 'BUILD_DIRECTORY',
    'p' => 'RELEASE_DIRECTORY',
    'i' => 'INSTALL_DIRECTORY',
);
foreach my $name (keys(%variable)) {
    if (defined($default{$name})) {
        my @values = split(',',$default{$name});
        push(@make,"'${variable{$name}} = @values'");
    }
}
if (@ARGV) {
    push(@make,@ARGV);
}
print("@make\n");

__END__

=head1 NAME

phpgw-pkgs-do - command interface to the phpGroupWare packages Makefile.

=head1 SYNOPSIS

phpgw-pkgs-do B<[option ...]> B<[argument ...]>

=over

=item * Available options

S<[ B<-g modules>, B<--get=modules> ]>
S<[ B<-r tag>, B<--cvs-release=tag> ]>
S<[ B<-d date>, B<--cvs-date=date> ]>
S<[ B<-A modules>, B<--build-all=modules> ]>
S<[ B<-G modules>, B<--build-tar-gz=modules> ]>
S<[ B<-B modules>, B<--build-tar-bz2=modules> ]>
S<[ B<-O modules>, B<--build-orig-tar-gz=modules> ]>
S<[ B<-D modules>, B<--build-deb=modules> ]>
S<[ B<-R modules>, B<--build-rpm=modules> ]>
S<[ B<-T modules>, B<--build-tgz=modules> ]>
S<[ B<-S modules>, B<--build-slp=modules> ]>
S<[ B<-P modules>, B<--build-pkg=modules> ]>
S<[ B<-l modules>, B<--lint=modules> ]>
S<[ B<-M modules>, B<--modules-list=modules> ]>
S<[ B<-F formats>, B<--formats-list=formats> ]>
S<[ B<-X modules>, B<--excluded-modules-list=modules> ]>
S<[ B<-b dir>, B<--build-dir[=dir]> ]>
S<[ B<-p dir>, B<--release-dir[=dir]> ]>
S<[ B<-i dir>, B<--install-dir[=dir]> ]>
S<[ B<-C dir>, B<--change-dir=dir> ]>
S<[ B<-I dir>, B<--include=dir> ]>
S<[ B<-f Makefile>, B<--file=Makefile> ]>
S<[ B<-q>, B<--quiet> ]>
S<[ B<-h>, B<--help> ]>
S<[ B<-m>, B<--man> ]>

=item * Available arguments

core build release install clean lint [ module ... ] [ format ... ]

=back

=head1 DESCRIPTION

phpgw-pkgs-do offers a command interface to the Makefile used to build the
phpgroupware packages. It's primarily splittted in two phases:

=over

=item * cvs

In this phase, phpgw-pkgs-do will get the source code from the cvs repository
of phpgoupware. You can specify B<-r tag> or B<--cvs-release=tag> to get a
particular revision or B<-d date>, B<--cvs-date=date> to get the latest
snapshot up to the date specified by I<date>

=item * make

In this phase, phpgw-pkg-do will start the L<make(1)> command on the
phpGroupWare source code, acording to the target expressed as arguments or the
targets expressed with the options.

=back

=head1 OPTIONS

=over

=item B<-g modules>, B<--get=modules>

Uses L<cvs(1)> command to chekout the source code of phpGroupWare from the CVS
repository.

=item B<-r tag>, B<--release=tag>

Uses B<tag> to chekout a particular phpGroupWare release (Implies B<-g> or
B<--get>)

=item B<-d date>, B<--date=date>

Passes B<date> to the L<cvs(1)> B<-D> option to get the latest snapshot of
phpGroupWare source code, up to the date specified (Implies B<-g> or B<--get>).

=item B<-A modules>, B<--build-all=modules>

Builds I<all> the packages format for the comma separated list of B<modules>.

=item B<-G modules>, B<--build-tar-gz=modules>

Builds the I<tar.gz> packages format for the comma separated list of B<modules>.

=item B<-B modules>, B<--build-tar-bz2=modules>

Builds the I<tar.bz2> packages format for the comma separated list of 
B<modules>.

=item B<-O modules>, B<--build-orig-tar-gz=modules>

Builds the I<orig.tar.gz> packages format for the comma separated list of 
B<modules>.

=item B<-D modules>, B<--build-deb=modules>

Builds the I<deb> packages format for the comma separated list of B<modules>.

=item B<-R modules>, B<--build-rpm=modules>

Builds the I<rpm> packages format for the comma separated list of B<modules>.

=item B<-T modules>, B<--build-tgz=modules>

Builds the I<tgz> packages format for the comma separated list of B<modules>.

=item B<-S modules>, B<--build-slp=modules>

Builds the I<slp> packages format for the comma separated list of B<modules>.

=item B<-P modules>, B<--build-pkg=modules>

Builds the I<pkg> packages format for the comma separated list of B<modules>.

=item B<-l modules>, B<--lint=modules>

Applys lint check for the comma separated list of B<modules>.

=item B<-M modules>, B<--modules-list=modules>

Uses the comma separated list of B<modules> provided as the only modules 
available
in the L<make(1)> phase.

=item B<-F formats>, B<--formats-list=formats>

Uses the comma separated list of B<formats> as the only available packages 
formats
in the L<make(1)> phase.

=item B<-X modules>, B<--excluded-modules-list=modules>

Excludes the comma separated list of B<modules> from the L<make(1)> phase.

=item B<-b dir>, B<--build=dir>

Uses the directory F<dir> to build the package (instead of the default one).

=item B<-p dir>, B<--release-packages=dir>

Uses the directory F<dir> to release the builded package (instead of the default
one).

=item B<-i dir>, B<--install=dir>

Uses the directory F<dir> to insrtall the source code (instead of the default
one).

=item B<-C dir>, B<--dir=dir>

Canges to directory F<dir> before the start of any phase (instead of the default
one).

=item B<-I dir>, B<--include=dir>

Takes the needed files from the directory F<dir> (instead of the default one).

=item B<-f Makefile>, B<--file=Makefile>

Uses F<Makefile> (instead of the default one).

=item B<-q>, B<--quiet>

Executes all the commands quitely.

=item B<-h>, B<--help>

Shows a short help message.

=item B<-m>, B<--man>

Shows a longe help message.

=back

=head1 ARGUMENTS

=over

=item * core

This is a special target that build the B<core> modules up in une packages. It
generates a B<tar.gz> I<and> B<tar.bz2> format.

=item * build

If the argument B<build> is passed, the L<make> phase will build any available 
package
format for any available module.

=item * release

If the argument B<release> is passed, the L<make> phase will install all the
builded package into the release direcotry.

=item * install

If the argument B<install> is passed, the L<make> phase will install the source
code into the installation directory.

=item * clean

If the argument B<clean> is passed, the L<make> phase will clean all the
generated files.

=item * lint

If the argument B<lint> is passed, the L<make> phase will execute lint reports
for any available module.

=item * module

If any B<module> name is passed, the L<make> phase will build any available
package formats for the specified module (if either the B<module> and the
package formats are available).

=item * format

If any package B<format> is passed, the L<make> phase will build the specified
format for any available module (if either the package B<format> and the
modules are available).

=back

=head1 SEE ALSO

L<cvs(1)>, L<make(1)>, L<dpkg(8)>, L<rpm(8)>, L<alien(1)>, L<tar(1)>,
L<gzip(1)>, L<bzip2(1)>

=head1 AUTHOR

Luca - De Whiskey's - De Vitis <address@hidden>

====================================================
Index: do
#!/usr/bin/make -f
#
# -----------------------------------------------------------------------------
# First coded by Luca - De Whiskey's - De Vitis <address@hidden> on 2002.6.20
# -----------------------------------------------------------------------------
# $Id: do,v 1.1 2005/05/05 00:56:39 skwashd Exp $
#
#   The phpgroupware packages utilities.
#   Copyright (C) 2002  Luca - De Whiskey's - De Vitis <address@hidden>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   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 General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# The real Makefile name.
Makefile = Makefile

# The directory under which the Makefile resides.
INCLUDES = packages

include $(INCLUDES)/$(Makefile)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]