rewrote the pre-revprop-chagnge script in perl

This commit is contained in:
hyung-hwan 2014-05-16 13:26:49 +00:00
parent df0a6fba2c
commit 124632ba8a
6 changed files with 160 additions and 41 deletions

3
codepot/configure vendored
View File

@ -2544,7 +2544,7 @@ cachedir=$cachedir
ac_config_files="$ac_config_files Makefile codepot.spec etc/Makefile etc/codepot.ini etc/codepot.a2ldap etc/start-commit DEBIAN/Makefile DEBIAN/control DEBIAN/postinst DEBIAN/postrm src/config.php src/codepot/config/Makefile src/codepot/controllers/Makefile src/codepot/errors/Makefile src/codepot/helpers/Makefile src/codepot/hooks/Makefile src/codepot/language/english/Makefile src/codepot/language/indonesian/Makefile src/codepot/language/korean/Makefile src/codepot/language/Makefile src/codepot/libraries/Makefile src/codepot/models/Makefile src/codepot/views/Makefile src/codepot/Makefile src/css/images/Makefile src/css/Makefile src/js/prettify/Makefile src/js/Makefile src/system/cache/Makefile src/system/codeigniter/Makefile src/system/database/drivers/mssql/Makefile src/system/database/drivers/mysql/Makefile src/system/database/drivers/mysqli/Makefile src/system/database/drivers/oci8/Makefile src/system/database/drivers/odbc/Makefile src/system/database/drivers/postgre/Makefile src/system/database/drivers/sqlite/Makefile src/system/database/drivers/Makefile src/system/database/Makefile src/system/fonts/Makefile src/system/helpers/Makefile src/system/language/english/Makefile src/system/language/korean/Makefile src/system/language/Makefile src/system/libraries/Makefile src/system/logs/Makefile src/system/plugins/Makefile src/system/scaffolding/images/Makefile src/system/scaffolding/views/Makefile src/system/scaffolding/Makefile src/system/Makefile src/Makefile" ac_config_files="$ac_config_files Makefile codepot.spec etc/Makefile etc/codepot.ini etc/codepot.a2ldap etc/start-commit etc/pre-revprop-change DEBIAN/Makefile DEBIAN/control DEBIAN/postinst DEBIAN/postrm src/config.php src/codepot/config/Makefile src/codepot/controllers/Makefile src/codepot/errors/Makefile src/codepot/helpers/Makefile src/codepot/hooks/Makefile src/codepot/language/english/Makefile src/codepot/language/indonesian/Makefile src/codepot/language/korean/Makefile src/codepot/language/Makefile src/codepot/libraries/Makefile src/codepot/models/Makefile src/codepot/views/Makefile src/codepot/Makefile src/css/images/Makefile src/css/Makefile src/js/prettify/Makefile src/js/Makefile src/system/cache/Makefile src/system/codeigniter/Makefile src/system/database/drivers/mssql/Makefile src/system/database/drivers/mysql/Makefile src/system/database/drivers/mysqli/Makefile src/system/database/drivers/oci8/Makefile src/system/database/drivers/odbc/Makefile src/system/database/drivers/postgre/Makefile src/system/database/drivers/sqlite/Makefile src/system/database/drivers/Makefile src/system/database/Makefile src/system/fonts/Makefile src/system/helpers/Makefile src/system/language/english/Makefile src/system/language/korean/Makefile src/system/language/Makefile src/system/libraries/Makefile src/system/logs/Makefile src/system/plugins/Makefile src/system/scaffolding/images/Makefile src/system/scaffolding/views/Makefile src/system/scaffolding/Makefile src/system/Makefile src/Makefile"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
@ -3077,6 +3077,7 @@ do
"etc/codepot.ini" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.ini" ;; "etc/codepot.ini" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.ini" ;;
"etc/codepot.a2ldap" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.a2ldap" ;; "etc/codepot.a2ldap" ) CONFIG_FILES="$CONFIG_FILES etc/codepot.a2ldap" ;;
"etc/start-commit" ) CONFIG_FILES="$CONFIG_FILES etc/start-commit" ;; "etc/start-commit" ) CONFIG_FILES="$CONFIG_FILES etc/start-commit" ;;
"etc/pre-revprop-change" ) CONFIG_FILES="$CONFIG_FILES etc/pre-revprop-change" ;;
"DEBIAN/Makefile" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/Makefile" ;; "DEBIAN/Makefile" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/Makefile" ;;
"DEBIAN/control" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/control" ;; "DEBIAN/control" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/control" ;;
"DEBIAN/postinst" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/postinst" ;; "DEBIAN/postinst" ) CONFIG_FILES="$CONFIG_FILES DEBIAN/postinst" ;;

View File

@ -87,6 +87,7 @@ AC_CONFIG_FILES([
etc/codepot.ini etc/codepot.ini
etc/codepot.a2ldap etc/codepot.a2ldap
etc/start-commit etc/start-commit
etc/pre-revprop-change
DEBIAN/Makefile DEBIAN/Makefile
DEBIAN/control DEBIAN/control
DEBIAN/postinst DEBIAN/postinst

View File

@ -3,5 +3,8 @@ cfgdir=$(CFGDIR)
cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap
cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS) perldir=$(CFGDIR)/perl/Codepot
perl_SCRIPTS=perl/Codepot/AccessHandler.pm perl/Codepot/AuthenHandler.pm
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS) $(perl_SCRIPTS)

View File

@ -38,7 +38,7 @@ POST_UNINSTALL = :
subdir = etc subdir = etc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/codepot.a2ldap.in $(srcdir)/codepot.ini.in \ $(srcdir)/codepot.a2ldap.in $(srcdir)/codepot.ini.in \
$(srcdir)/start-commit.in $(srcdir)/pre-revprop-change.in $(srcdir)/start-commit.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/as-ac-expand.m4 \ am__aclocal_m4_deps = $(top_srcdir)/ac/m4/as-ac-expand.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
@ -46,10 +46,13 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/./config.h CONFIG_HEADER = $(top_builddir)/./config.h
CONFIG_CLEAN_FILES = codepot.ini codepot.a2ldap start-commit CONFIG_CLEAN_FILES = codepot.ini codepot.a2ldap start-commit \
am__installdirs = "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(cfgdir)" pre-revprop-change
am__installdirs = "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(perldir)" \
"$(DESTDIR)$(cfgdir)"
cfgSCRIPT_INSTALL = $(INSTALL_SCRIPT) cfgSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(cfg_SCRIPTS) perlSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(cfg_SCRIPTS) $(perl_SCRIPTS)
SOURCES = SOURCES =
DIST_SOURCES = DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@ -146,7 +149,9 @@ target_alias = @target_alias@
wwwdir = @wwwdir@ wwwdir = @wwwdir@
cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap cfg_DATA = codepot.ini codepot.mysql codepot.a2ldap
cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change cfg_SCRIPTS = start-commit pre-commit post-commit pre-revprop-change post-revprop-change
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS) perldir = $(CFGDIR)/perl/Codepot
perl_SCRIPTS = perl/Codepot/AccessHandler.pm perl/Codepot/AuthenHandler.pm
EXTRA_DIST = $(cfg_DATA) $(cfg_SCRIPTS) $(perl_SCRIPTS)
all: all-am all: all-am
.SUFFIXES: .SUFFIXES:
@ -185,6 +190,8 @@ codepot.a2ldap: $(top_builddir)/config.status $(srcdir)/codepot.a2ldap.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
start-commit: $(top_builddir)/config.status $(srcdir)/start-commit.in start-commit: $(top_builddir)/config.status $(srcdir)/start-commit.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
pre-revprop-change: $(top_builddir)/config.status $(srcdir)/pre-revprop-change.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-cfgSCRIPTS: $(cfg_SCRIPTS) install-cfgSCRIPTS: $(cfg_SCRIPTS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
test -z "$(cfgdir)" || $(mkdir_p) "$(DESTDIR)$(cfgdir)" test -z "$(cfgdir)" || $(mkdir_p) "$(DESTDIR)$(cfgdir)"
@ -204,6 +211,25 @@ uninstall-cfgSCRIPTS:
echo " rm -f '$(DESTDIR)$(cfgdir)/$$f'"; \ echo " rm -f '$(DESTDIR)$(cfgdir)/$$f'"; \
rm -f "$(DESTDIR)$(cfgdir)/$$f"; \ rm -f "$(DESTDIR)$(cfgdir)/$$f"; \
done done
install-perlSCRIPTS: $(perl_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(perldir)" || $(mkdir_p) "$(DESTDIR)$(perldir)"
@list='$(perl_SCRIPTS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f $$d$$p; then \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " $(perlSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(perldir)/$$f'"; \
$(perlSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(perldir)/$$f"; \
else :; fi; \
done
uninstall-perlSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(perl_SCRIPTS)'; for p in $$list; do \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " rm -f '$(DESTDIR)$(perldir)/$$f'"; \
rm -f "$(DESTDIR)$(perldir)/$$f"; \
done
uninstall-info-am: uninstall-info-am:
install-cfgDATA: $(cfg_DATA) install-cfgDATA: $(cfg_DATA)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@ -230,6 +256,7 @@ CTAGS:
distdir: $(DISTFILES) distdir: $(DISTFILES)
$(mkdir_p) $(distdir)/perl/Codepot
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \ list='$(DISTFILES)'; for file in $$list; do \
@ -260,7 +287,7 @@ check-am: all-am
check: check-am check: check-am
all-am: Makefile $(SCRIPTS) $(DATA) all-am: Makefile $(SCRIPTS) $(DATA)
installdirs: installdirs:
for dir in "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(cfgdir)"; do \ for dir in "$(DESTDIR)$(cfgdir)" "$(DESTDIR)$(perldir)" "$(DESTDIR)$(cfgdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \ test -z "$$dir" || $(mkdir_p) "$$dir"; \
done done
install: install-am install: install-am
@ -305,7 +332,8 @@ info: info-am
info-am: info-am:
install-data-am: install-cfgDATA install-cfgSCRIPTS install-data-am: install-cfgDATA install-cfgSCRIPTS \
install-perlSCRIPTS
install-exec-am: install-exec-am:
@ -331,17 +359,19 @@ ps: ps-am
ps-am: ps-am:
uninstall-am: uninstall-cfgDATA uninstall-cfgSCRIPTS uninstall-info-am uninstall-am: uninstall-cfgDATA uninstall-cfgSCRIPTS uninstall-info-am \
uninstall-perlSCRIPTS
.PHONY: all all-am check check-am clean clean-generic distclean \ .PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \ distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-cfgDATA install-cfgSCRIPTS \ install install-am install-cfgDATA install-cfgSCRIPTS \
install-data install-data-am install-exec install-exec-am \ install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-man install-strip \ install-info install-info-am install-man install-perlSCRIPTS \
installcheck installcheck-am installdirs maintainer-clean \ install-strip installcheck installcheck-am installdirs \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ maintainer-clean maintainer-clean-generic mostlyclean \
pdf-am ps ps-am uninstall uninstall-am uninstall-cfgDATA \ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-cfgSCRIPTS uninstall-info-am uninstall-cfgDATA uninstall-cfgSCRIPTS uninstall-info-am \
uninstall-perlSCRIPTS
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.

View File

@ -1,24 +0,0 @@
#!/bin/sh
REPOBASE="`basename "${1}"`"
REVISION="${2}"
USER="${3}"
PROPNAME="${4}"
ACTION="${5}"
# [STDIN] PROPVAL ** the new property value is passed via STDIN.
ans="`wget -q -O- "%API%/projectHasMember/${REPOBASE}/${USER}" 2>/dev/null`"
[ "${ans}" = "YES" ] && exit 0
[ "${ans}" = "NO" ] && {
echo "-------------------------------------------------------------" >&2
echo " ${USER} is not a member of ${REPOBASE}" >&2
echo "-------------------------------------------------------------" >&2
exit 1
}
echo "---------------------------------------------------------------------" >&2
echo " Failed to check membership of ${REPOBASE} for ${USER}" >&2
echo "---------------------------------------------------------------------" >&2
exit 1

View File

@ -0,0 +1,108 @@
#!/usr/bin/perl
use strict;
use Config::Simple;
use DBI;
use File::Basename;
my $CFG_FILE = '@CFGDIR@/codepot.ini';
my $REPOBASE = basename($ARGV[0]);
my $REVISION= $ARGV[1];
my $USER = $ARGV[2];
my $PROPNAME = $ARGV[3];
my $ACTION = $ARGV[4];
sub get_config
{
my $cfg = new Config::Simple();
if (!$cfg->read ($CFG_FILE))
{
return undef;
}
my $config = {
database_hostname => $cfg->param ("database_hostname"),
database_username => $cfg->param ("database_username"),
database_password => $cfg->param ("database_password"),
database_name => $cfg->param ("database_name"),
database_driver => $cfg->param ("database_driver"),
database_prefix => $cfg->param ("database_prefix")
};
return $config;
}
sub open_database
{
my ($cfg) = @_;
my $dbtype = $cfg->{database_driver};
my $dbname = $cfg->{database_name};
my $dbhost = $cfg->{database_hostname};
my $dbh = DBI->connect(
"DBI:$dbtype:$dbname:$dbhost",
$cfg->{database_username},
$cfg->{database_password},
{ RaiseError => 0, PrintError => 0, AutoCommit => 0 }
);
return $dbh;
}
sub close_database
{
my ($dbh) = @_;
$dbh->disconnect ();
}
sub is_project_member
{
my ($dbh, $prefix, $projectid, $userid) = @_;
my $query = $dbh->prepare ("SELECT projectid FROM ${prefix}project_membership WHERE userid=? AND projectid=?");
if (!$query || !$query->execute ($userid, $projectid))
{
return (-1, $dbh->errstr());
}
my @row = $query->fetchrow_array;
return (((scalar(@row) > 0)? 1: 0), undef);
}
#------------------------------------------------------------
# MAIN
#------------------------------------------------------------
my $cfg = get_config ();
if (!defined($cfg))
{
print (STDERR "Cannot load codepot configuration file\n");
exit (1);
}
my $dbh = open_database ($cfg);
if (!defined($dbh))
{
print (STDERR "Cannot open database\n");
exit (1);
}
my ($member, $errstr) = is_project_member ($dbh, $cfg->{database_prefix}, $REPOBASE, $USER);
close_database ($dbh);
if ($member <= -1)
{
print (STDERR "Cannot check membership - $errstr\n");
exit (1);
}
elsif ($member == 0)
{
print (STDERR "$USER doesn't belong to the $REPOBASE project\n");
exit (1);
}
exit (0);