4 echo Usage: $0 PluginName
7 echo "Plugin template creator"
13 minus=`echo $1 | tr '[A-Z]' '[a-z]'`
14 plugdir=gforge-plugin-$minus
15 echo "Creating $1 plugin"
16 echo "Creating directory $plugdir"
23 mkdir $plugdir/include
27 echo Creating $plugdir/bin/db-delete.pl
28 cat > $plugdir/bin/db-delete.pl <<FIN
33 # Debian-specific script to delete plugin-specific tables
34 # Roland Mas <lolando@debian.org>
43 use vars qw/\$dbh @reqlist \$query/ ;
44 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
45 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
46 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
47 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
48 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
49 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
50 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
52 use vars qw/\$pluginname/ ;
54 sub is_lesser ( \$\$ ) ;
55 sub is_greater ( \$\$ ) ;
57 sub parse_sql_file ( \$ ) ;
59 require ("/usr/lib/gforge/lib/include.pl") ; # Include a few predefined functions
60 require ("/usr/lib/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
62 debug "You'll see some debugging info during this installation." ;
63 debug "Do not worry unless told otherwise." ;
67 # debug "Connected to the database OK." ;
69 \$pluginname = "$minus" ;
71 \$dbh->{AutoCommit} = 0;
72 \$dbh->{RaiseError} = 1;
74 my (\$sth, @array, \$version, \$action, \$path, \$target, \$rname) ;
76 my \$pattern = "plugin_" . \$pluginname . '_%' ;
78 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='v'" ;
79 \$sth = \$dbh->prepare (\$query) ;
81 while (@array = \$sth->fetchrow_array ()) {
82 \$rname = \$array [0] ;
83 &drop_view_if_exists (\$rname) ;
87 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='r'" ;
88 \$sth = \$dbh->prepare (\$query) ;
90 while (@array = \$sth->fetchrow_array ()) {
91 \$rname = \$array [0] ;
92 &drop_table_if_exists (\$rname) ;
96 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='i'" ;
97 \$sth = \$dbh->prepare (\$query) ;
99 while (@array = \$sth->fetchrow_array ()) {
100 \$rname = \$array [0] ;
101 &drop_index_if_exists (\$rname) ;
105 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='s'" ;
106 \$sth = \$dbh->prepare (\$query) ;
108 while (@array = \$sth->fetchrow_array ()) {
109 \$rname = \$array [0] ;
110 &drop_sequence_if_exists (\$rname) ;
117 debug "It seems your database deletion went well and smoothly. That's cool." ;
118 debug "Please enjoy using Debian GForge." ;
120 # There should be a commit at the end of every block above.
121 # If there is not, then it might be symptomatic of a problem.
122 # For safety, we roll back.
127 warn "Transaction aborted because \$@" ;
128 debug "Transaction aborted because \$@" ;
129 debug "Last SQL query was:\n\$query\n(end of query)" ;
131 debug "Please report this bug on the Debian bug-tracking system." ;
132 debug "Please include the previous messages as well to help debugging." ;
133 debug "You should not worry too much about this," ;
134 debug "your DB is still in a consistent state and should be usable." ;
144 print STDERR "\$v\n" ;
147 sub drop_table_if_exists ( \$ ) {
148 my \$tname = shift or die "Not enough arguments" ;
149 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
150 my \$sth = \$dbh->prepare (\$query) ;
152 my @array = \$sth->fetchrow_array () ;
155 if (\$array [0] != 0) {
156 # debug "Dropping table \$tname" ;
157 \$query = "DROP TABLE \$tname" ;
159 \$sth = \$dbh->prepare (\$query) ;
165 sub drop_sequence_if_exists ( \$ ) {
166 my \$sname = shift or die "Not enough arguments" ;
167 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
168 my \$sth = \$dbh->prepare (\$query) ;
170 my @array = \$sth->fetchrow_array () ;
173 if (\$array [0] != 0) {
174 # debug "Dropping sequence \$sname" ;
175 \$query = "DROP SEQUENCE \$sname" ;
177 \$sth = \$dbh->prepare (\$query) ;
183 sub drop_index_if_exists ( \$ ) {
184 my \$iname = shift or die "Not enough arguments" ;
185 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
186 my \$sth = \$dbh->prepare (\$query) ;
188 my @array = \$sth->fetchrow_array () ;
191 if (\$array [0] != 0) {
192 # debug "Dropping index \$iname" ;
193 \$query = "DROP INDEX \$iname" ;
195 \$sth = \$dbh->prepare (\$query) ;
201 sub drop_view_if_exists ( \$ ) {
202 my \$iname = shift or die "Not enough arguments" ;
203 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
204 my \$sth = \$dbh->prepare (\$query) ;
206 my @array = \$sth->fetchrow_array () ;
209 if (\$array [0] != 0) {
210 # debug "Dropping view \$iname" ;
211 \$query = "DROP VIEW \$iname" ;
213 \$sth = \$dbh->prepare (\$query) ;
220 echo Creating $plugdir/bin/db-upgrade.pl
221 cat > $plugdir/bin/db-upgrade.pl <<FIN
226 # Debian-specific script to upgrade the database between releases
227 # Roland Mas <lolando@debian.org>
236 use vars qw/\$dbh @reqlist \$query/ ;
237 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
238 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
239 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
240 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
241 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
242 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
243 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
245 use vars qw/\$pluginname/ ;
247 sub is_lesser ( \$\$ ) ;
248 sub is_greater ( \$\$ ) ;
250 sub parse_sql_file ( \$ ) ;
252 require ("/usr/lib/gforge/lib/include.pl") ; # Include a few predefined functions
253 require ("/usr/lib/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
255 debug "You'll see some debugging info during this installation." ;
256 debug "Do not worry unless told otherwise." ;
260 # debug "Connected to the database OK." ;
262 \$pluginname = "$minus" ;
264 \$dbh->{AutoCommit} = 0;
265 \$dbh->{RaiseError} = 1;
267 my (\$sth, @array, \$version, \$path, \$target) ;
269 &create_metadata_table ("0") ;
271 \$version = &get_db_version ;
273 if (is_lesser \$version, \$target) {
274 my @filelist = ( "/usr/lib/gforge/plugins/\$pluginname/lib/\$pluginname-init.sql" ) ;
276 foreach my \$file (@filelist) {
277 debug "Processing \$file" ;
278 @reqlist = @{ &parse_sql_file (\$file) } ;
280 foreach my \$s (@reqlist) {
283 \$sth = \$dbh->prepare (\$query) ;
290 &update_db_version (\$target) ;
291 debug "Committing." ;
295 \$version = &get_db_version ;
297 if (is_lesser \$version, \$target) {
298 debug "Adding local data." ;
300 do "/etc/gforge/local.pl" or die "Cannot read /etc/gforge/local.pl" ;
302 my \$ip_address = qx/host \$domain_name | awk '{print \\$3}'/ ;
305 "INSERT INTO plugin_".\$pluginname."_sample_data (domain, ip_address) VALUES ('\$domain_name', '\$ip_address')",
308 foreach my \$s (@reqlist) {
311 \$sth = \$dbh->prepare (\$query) ;
317 &update_db_version (\$target) ;
318 debug "Committing." ;
322 debug "It seems your database install/upgrade went well and smoothly. That's cool." ;
323 debug "Please enjoy using Debian GForge." ;
325 # There should be a commit at the end of every block above.
326 # If there is not, then it might be symptomatic of a problem.
327 # For safety, we roll back.
332 warn "Transaction aborted because \$@" ;
333 debug "Transaction aborted because \$@" ;
334 debug "Last SQL query was:\n\$query\n(end of query)" ;
336 debug "Please report this bug on the Debian bug-tracking system." ;
337 debug "Please include the previous messages as well to help debugging." ;
338 debug "You should not worry too much about this," ;
339 debug "your DB is still in a consistent state and should be usable." ;
346 sub is_lesser ( \$\$ ) {
347 my \$v1 = shift || 0 ;
348 my \$v2 = shift || 0 ;
350 my \$rc = system "dpkg --compare-versions \$v1 lt \$v2" ;
355 sub is_greater ( \$\$ ) {
356 my \$v1 = shift || 0 ;
357 my \$v2 = shift || 0 ;
359 my \$rc = system "dpkg --compare-versions \$v1 gt \$v2" ;
367 print STDERR "\$v\n" ;
370 sub create_metadata_table ( \$ ) {
371 my \$v = shift || "0" ;
372 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
373 # Do we have the metadata table?
375 \$query = "SELECT count(*) FROM pg_class WHERE relname = '\$tablename' and relkind = 'r'";
377 my \$sth = \$dbh->prepare (\$query) ;
379 my @array = \$sth->fetchrow_array () ;
382 # Let's create this table if we have it not
384 if (\$array [0] == 0) {
385 debug "Creating \$tablename table." ;
386 \$query = "CREATE TABLE \$tablename (key varchar primary key, value text not null)" ;
388 \$sth = \$dbh->prepare (\$query) ;
393 \$query = "SELECT count(*) FROM \$tablename WHERE key = 'db-version'";
395 \$sth = \$dbh->prepare (\$query) ;
397 @array = \$sth->fetchrow_array () ;
400 # Empty table? We'll have to fill it up a bit
402 if (\$array [0] == 0) {
403 debug "Inserting first data into \$tablename table." ;
404 \$query = "INSERT INTO \$tablename (key, value) VALUES ('db-version', '\$v')" ;
406 \$sth = \$dbh->prepare (\$query) ;
412 sub update_db_version ( \$ ) {
413 my \$v = shift or die "Not enough arguments" ;
414 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
416 debug "Updating \$tablename table." ;
417 \$query = "UPDATE \$tablename SET value = '\$v' WHERE key = 'db-version'" ;
419 my \$sth = \$dbh->prepare (\$query) ;
424 sub get_db_version () {
425 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
427 \$query = "SELECT value FROM \$tablename WHERE key = 'db-version'" ;
429 my \$sth = \$dbh->prepare (\$query) ;
431 my @array = \$sth->fetchrow_array () ;
434 my \$version = \$array [0] ;
439 sub drop_table_if_exists ( \$ ) {
440 my \$tname = shift or die "Not enough arguments" ;
441 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
442 my \$sth = \$dbh->prepare (\$query) ;
444 my @array = \$sth->fetchrow_array () ;
447 if (\$array [0] != 0) {
448 # debug "Dropping table \$tname" ;
449 \$query = "DROP TABLE \$tname" ;
451 \$sth = \$dbh->prepare (\$query) ;
457 sub drop_sequence_if_exists ( \$ ) {
458 my \$sname = shift or die "Not enough arguments" ;
459 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
460 my \$sth = \$dbh->prepare (\$query) ;
462 my @array = \$sth->fetchrow_array () ;
465 if (\$array [0] != 0) {
466 # debug "Dropping sequence \$sname" ;
467 \$query = "DROP SEQUENCE \$sname" ;
469 \$sth = \$dbh->prepare (\$query) ;
475 sub drop_index_if_exists ( \$ ) {
476 my \$iname = shift or die "Not enough arguments" ;
477 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
478 my \$sth = \$dbh->prepare (\$query) ;
480 my @array = \$sth->fetchrow_array () ;
483 if (\$array [0] != 0) {
484 # debug "Dropping index \$iname" ;
485 \$query = "DROP INDEX \$iname" ;
487 \$sth = \$dbh->prepare (\$query) ;
493 sub drop_view_if_exists ( \$ ) {
494 my \$iname = shift or die "Not enough arguments" ;
495 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
496 my \$sth = \$dbh->prepare (\$query) ;
498 my @array = \$sth->fetchrow_array () ;
501 if (\$array [0] != 0) {
502 # debug "Dropping view \$iname" ;
503 \$query = "DROP VIEW \$iname" ;
505 \$sth = \$dbh->prepare (\$query) ;
511 sub bump_sequence_to ( \$\$ ) {
512 my (\$sth, @array, \$seqname, \$targetvalue) ;
515 \$targetvalue = shift ;
518 \$query = "select nextval ('\$seqname')" ;
519 \$sth = \$dbh->prepare (\$query) ;
521 @array = \$sth->fetchrow_array () ;
523 } until \$array[0] >= \$targetvalue ;
527 echo Creating $plugdir/bin/$minus
528 cat > $plugdir/bin/$minus <<FIN
533 do "/etc/gforge/plugins/$minus/$minus.conf"
534 or die "Cannot read /etc/gforge/plugins/$minus/$minus.conf" ;
536 print STDOUT "\$world on STDOUT!\n" ;
537 print STDERR "\$world on STDERR!\n" ;
540 echo Creating $plugdir/etc/$minus.conf
541 cat > $plugdir/etc/$minus.conf <<FIN
545 echo Creating $plugdir/httpd.conf
546 cat > $plugdir/httpd.conf <<FIN
547 <Location /plugins/$minus/>
548 SetEnv PLUGINNAME $minus
549 SetEnv PLUGINVERSION 0.1-1
553 echo Creating $plugdir/debian/README.Debian
554 cat > $plugdir/debian/README.Debian <<FIN
555 gforge-plugin-$minus for Debian
556 ----------------------------------------
558 <possible notes regarding this package - if none, delete this file>
560 -- Roland Mas <lolando@debian.org>, Tue, 26 Nov 2002 21:31:00 +0100
563 echo Creating $plugdir/debian/changelog
564 cat > $plugdir/debian/changelog <<FIN
565 gforge-plugin-$minus (0.1-1) unstable; urgency=low
569 -- Roland Mas <lolando@debian.org> Tue, 26 Nov 2002 21:31:00 +0100
573 echo Creating $plugdir/debian/control
574 cat > $plugdir/debian/control <<FIN
575 Source: gforge-plugin-$minus
578 Maintainer: Roland Mas <lolando@debian.org>
579 Build-Depends-Indep: debhelper (>> 4.0.0)
580 Standards-Version: 3.5.8
582 Package: gforge-plugin-$minus
584 Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache | gforge-web
585 Description: The ${fullname} plugin for GForge
586 This is intended as an example for developers of GForge plugins,
587 as well as an experimental area for the GForge plugin subsystem.
590 echo Creating $plugdir/debian/copyright
591 cat > $plugdir/debian/copyright <<FIN
592 This package was debianized by Roland Mas <lolando@debian.org> on
593 Tue, 26 Nov 2002 21:31:00 +0100.
595 It was downloaded from <http://savannah.nongnu.org/projects/debian-sf>
597 Upstream Author: Roland Mas <lolando@debian.org>
601 This package is free software; you can redistribute it and/or modify
602 it under the terms of the GNU General Public License as published by
603 the Free Software Foundation; version 2 dated June, 1991.
605 This package is distributed in the hope that it will be useful,
606 but WITHOUT ANY WARRANTY; without even the implied warranty of
607 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
608 GNU General Public License for more details.
610 You should have received a copy of the GNU General Public License
611 along with this package; if not, write to the Free Software
612 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
615 On Debian GNU/Linux systems, the complete text of the GNU General
616 Public License can be found in '/usr/share/common-licenses/GPL'.
620 echo Creating $plugdir/debian/cron.d
621 cat > $plugdir/debian/cron.d <<FIN
622 0 0 * * * gforge [ -x /usr/lib/gforge/plugins/$minus/bin/$minus ] && /usr/lib/gforge/plugins/$minus/bin/$minus > /dev/null 2>&1
625 echo Creating $plugdir/debian/dirs
626 cat > $plugdir/debian/dirs <<FIN
629 etc/gforge/httpd.conf.d
630 etc/gforge/httpd.secrets.d
632 etc/gforge/plugins/$minus
636 usr/lib/gforge/plugins/
637 usr/lib/gforge/plugins/$minus
638 usr/lib/gforge/plugins/$minus/bin
639 usr/lib/gforge/plugins/$minus/include
640 usr/lib/gforge/plugins/$minus/lib
641 usr/lib/gforge/cgi-bin
645 usr/share/gforge/www/plugins
646 usr/share/gforge/www/plugins/$minus
649 echo Creating $plugdir/debian/postinst
650 cat > $plugdir/debian/postinst <<FIN
652 # postinst script for gforge-plugin-$minus
654 # see: dh_installdeb(1)
658 # summary of how this script can be called:
659 # * <postinst> 'configure' <most-recently-configured-version>
660 # * <old-postinst> 'abort-upgrade' <new version>
661 # * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
663 # * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
664 # <failed-install-package> <version> 'removing'
665 # <conflicting-package> <version>
666 # for details, see http://www.debian.org/doc/debian-policy/ or
667 # the debian-policy package
669 # quoting from the policy:
670 # Any necessary prompting should almost always be confined to the
671 # post-installation script, and should be protected with a conditional
672 # so that unnecessary prompting doesn't happen if a package's
673 # installation fails and the 'postinst' is called with 'abort-upgrade',
674 # 'abort-remove' or 'abort-deconfigure'.
678 /usr/lib/gforge/plugins/$minus/bin/db-upgrade.pl
679 /usr/lib/gforge/bin/register-plugin $minus "${fullname}"
680 invoke-rc.d apache reload
683 abort-upgrade|abort-remove|abort-deconfigure)
688 echo "postinst called with unknown argument \'\$1'" >&2
693 # dh_installdeb will replace this with shell code automatically
694 # generated by other debhelper scripts.
703 echo Creating $plugdir/debian/postrm.ex
704 cat > $plugdir/debian/postrm.ex <<FIN
706 # postrm script for gforge-plugin-$minus
708 # see: dh_installdeb(1)
712 # summary of how this script can be called:
713 # * <postrm> 'remove'
715 # * <old-postrm> 'upgrade' <new-version>
716 # * <new-postrm> 'failed-upgrade' <old-version>
717 # * <new-postrm> 'abort-install'
718 # * <new-postrm> 'abort-install' <old-version>
719 # * <new-postrm> 'abort-upgrade' <old-version>
720 # * <disappearer's-postrm> 'disappear' <r>overwrit>r> <new-version>
721 # for details, see http://www.debian.org/doc/debian-policy/ or
722 # the debian-policy package
726 purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
732 echo "postrm called with unknown argument \'\$1'" >&2
737 # dh_installdeb will replace this with shell code automatically
738 # generated by other debhelper scripts.
745 echo Creating $plugdir/debian/preinst.ex
746 cat > $plugdir/debian/preinst.ex <<FIN
748 # preinst script for gforge-plugin-$minus
750 # see: dh_installdeb(1)
754 # summary of how this script can be called:
755 # * <new-preinst> 'install'
756 # * <new-preinst> 'install' <old-version>
757 # * <new-preinst> 'upgrade' <old-version>
758 # * <old-preinst> 'abort-upgrade' <new-version>
760 # for details, see http://www.debian.org/doc/debian-policy/ or
761 # the debian-policy package
766 # if [ "\$1" = "upgrade" ]
768 # start-stop-daemon --stop --quiet --oknodo \
769 # --pidfile /var/run/gforge-plugin-$minus.pid \
770 # --exec /usr/sbin/gforge-plugin-$minus 2>/dev/null || true
778 echo "preinst called with unknown argument \'\$1'" >&2
783 # dh_installdeb will replace this with shell code automatically
784 # generated by other debhelper scripts.
793 echo Creating $plugdir/debian/prerm
794 cat > $plugdir/debian/prerm <<FIN
796 # prerm script for gforge-plugin-$minus
798 # see: dh_installdeb(1)
802 # summary of how this script can be called:
804 # * <old-prerm> 'upgrade' <new-version>
805 # * <new-prerm> 'failed-upgrade' <old-version>
806 # * <conflictor's-prerm> 'remove' 'in-favour' <package> <new-version>
807 # * <deconfigured's-prerm> 'deconfigure' 'in-favour'
808 # <package-being-installed> <version> 'removing'
809 # <conflicting-package> <version>
810 # for details, see http://www.debian.org/doc/debian-policy/ or
811 # the debian-policy package
816 /usr/lib/gforge/bin/unregister-plugin $minus
817 invoke-rc.d apache reload
818 /usr/lib/gforge/plugins/$minus/bin/db-delete.pl
820 upgrade|failed-upgrade)
823 echo "prerm called with unknown argument \'\$1'" >&2
828 # dh_installdeb will replace this with shell code automatically
829 # generated by other debhelper scripts.
838 echo Creating $plugdir/debian/rules
839 cat > $plugdir/debian/rules <<FIN
841 # Sample debian/rules that uses debhelper.
842 # GNU copyright 1997 to 1999 by Joey Hess.
844 # Uncomment this to turn on verbose mode.
847 # This is the debhelper compatibility version to use.
852 configure: configure-stamp
855 # Add here commands to configure the package.
856 touch configure-stamp
860 build-stamp: configure-stamp
867 rm -f build-stamp configure-stamp
870 DESTDIR=\$(CURDIR)/debian/gforge-plugin-\$(PLUGIN)
878 cp -r bin/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/bin/
879 cp -r include/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/include/
880 cp -r lib/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/lib/
881 # cp -r cgi-bin/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/cgi-bin/
882 cp -r etc/* \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/
883 cp -r www/* \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/
884 install -m 0644 httpd.conf \$(DESTDIR)/etc/gforge/httpd.conf.d/50\$(PLUGIN)
885 # install -m 0600 httpd.secrets \$(DESTDIR)/etc/gforge/httpd.secrets.d/50\$(PLUGIN)
886 find \$(DESTDIR)/ -name CVS -type d | xargs rm -rf
887 find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/bin/ -type f | xargs chmod 0755
888 find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/include/ -type f | xargs chmod 0644
889 find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/lib/ -type f | xargs chmod 0644
890 # find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/cgi-bin/ -type f | xargs chmod 0755
891 find \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
892 find \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
895 # Build architecture-independent files here.
896 binary-indep: build install
897 # We have nothing to do by default.
899 # Build architecture-dependent files here.
900 binary-arch: build install
907 # dh_installlogrotate
929 binary: binary-indep binary-arch
930 .PHONY: build clean binary-indep binary-arch binary install configure
933 echo Creating $plugdir/include/${fullname}Plugin.class
934 cat > $plugdir/include/${fullname}Plugin.class <<FIN
937 class ${fullname}Plugin extends Plugin {
938 function ${fullname}Plugin () {
940 \$this->name = "$minus" ;
941 \$this->hooks[] = "usermenu" ;
944 function CallHook (\$hookname, \$params) {
945 global \$Language, \$G_SESSION, \$HTML ;
946 if (\$hookname == "usermenu") {
947 \$text = "${fullname}" ;
948 if (\$G_SESSION->usesPlugin("$minus")) {
953 echo ' | ' . \$HTML->PrintSubMenu (array (\$text),
954 array ('/plugins/$minus/index.php?user_id=' . \$G_SESSION->getId()));
955 } elseif (\$hookname == "blahblahblah") {
963 // c-file-style: "bsd"
969 echo Creating $plugdir/include/$minus-init.php
970 cat > $plugdir/include/$minus-init.php <<FIN
973 require_once ('/usr/lib/gforge/plugins/$minus/include/${fullname}Plugin.class') ;
975 \$${fullname}PluginObject = new ${fullname}Plugin ;
977 register_plugin (\$${fullname}PluginObject) ;
981 // c-file-style: "bsd"
987 echo Creating $plugdir/lib/$minus-init.sql
988 cat > $plugdir/lib/$minus-init.sql <<FIN
989 CREATE TABLE plugin_${minus}_sample_data (
995 echo Creating $plugdir/www/index.php
996 cat > $plugdir/www/index.php <<FIN
1001 * Roland Mas <lolando@debian.org>
1004 require_once('pre.php');
1007 exit_error('Error','No User Id Provided');
1010 \$user = user_get_object(\$user_id);
1013 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1014 exit_error("Invalid User", "That user does not exist.");
1016 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1017 \$user_name = \$user->getRealName();
1019 if (\$user->usesPlugin("$minus")) {
1020 print \$HTML->boxTop("\$user_name says ${fullname}!");
1022 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1024 print '<A HREF="toggle.php?user_id='.\$user_id.'">Toggle!</A>' ;
1025 print "This is the $minus plugin. I hope you enjoy it." ;
1026 print '<A HREF="/my/">Back to My Peronal Page.</A>' ;
1027 print \$HTML->boxBottom();
1028 print \$HTML->footer(array());
1033 // c-file-style: "bsd"
1039 echo Creating $plugdir/www/toggle.php
1040 cat > $plugdir/www/toggle.php <<FIN
1043 * ${fullname} plugin
1045 * Roland Mas <lolando@debian.org>
1048 require_once('pre.php');
1051 exit_error('Error','No User Id Provided');
1054 \$user = user_get_object(\$user_id);
1057 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1058 exit_error("Invalid User", "That user does not exist.");
1060 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1061 \$user_name = \$user->getRealName();
1063 if (\$user->usesPlugin("$minus")) {
1064 print \$HTML->boxTop("\$user_name says ${fullname}!");
1066 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1068 print "And now, I'm toggling the use of the ${fullname} plugin...\n" ;
1069 \$user->setPluginUse("$minus", !\$user->usesPlugin("$minus")) ;
1070 print "done. Let's try it out.\n" ;
1072 if (\$user->usesPlugin("$minus")) {
1073 print \$HTML->boxMiddle("\$user_name now says ${fullname}!");
1075 print \$HTML->boxMiddle("\$user_name now does not say ${fullname}...");
1077 print '<A HREF="index.php?user_id='.\$user_id.'">Back to index.</A>' ;
1078 print \$HTML->boxBottom();
1079 print \$HTML->footer(array());
1084 // c-file-style: "bsd"
1101 echo $minus already exist, Aborting....