Commit 6087d9bf authored by Robert Gobeille's avatar Robert Gobeille

preliminary checkin. Install locations need to be checked.


git-svn-id: http://svn.code.sf.net/p/fossology/code/branches/fossology2.0/fossology@5046 a5643f74-2041-0410-a2b9-94ffef304a07
parent 30059420
# FOSSology Makefile - install/
# Copyright (C) 2008-2011 Hewlett-Packard Development Company, L.P.
# Create and install:
# fo-postinstall
# SYSCONFDIR/db.conf
TOP=..
VARS=$(TOP)/Makefile.conf
include $(VARS)
......@@ -61,20 +66,19 @@ uninstall:
fi; \
fi
@echo "WARNING: Cowardly refusing to remove the following"
@echo " $(DESTDIR)$(CONFPATH)/agents.d"
@echo "Configuration files will not be removed:"
@echo " $(DESTDIR)$(CONFPATH)/fossology.conf"
@echo " $(DESTDIR)$(CONFPATH)/Db.conf"
@echo " Remove by hand if you desire."
clean:
rm -f fo-postinstall defconf/Db.conf
rm -f fo-postinstall defconf/Db.conf defconf/fossology.conf
test: all
@echo "NOTICE: no tests available for common"
@echo "NOTICE: no tests available for install"
coverage:
@echo "NOTICE: no coverage available for common""
@echo "NOTICE: no coverage available for install"
.PHONY: all install uninstall clean test
.PHONY: all install uninstall clean test coverage
<?php
/*
Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* \file fossinit-licenseref.php
* \brief Initialize the license_ref table
**/
/**
* \brief initLicenseRefTable function, Initialize the license_ref table data.
*
* \param $Verbose verbose mode; $Debug display database debug information
* \return 0 on success,1 on failure
**/
function initLicenseRefTable($Verbose, $Debug)
{
global $LIBEXECDIR;
global $PGCONN;
print " Importing license_ref table data\n";
flush();
if (!is_dir($LIBEXECDIR)) {
print "FATAL: Directory '$LIBEXECDIR' does not exist.\n";
return (1);
}
$dir = opendir($LIBEXECDIR);
if (!$dir) {
print "FATAL: Unable to access '$LIBEXECDIR'.\n";
return (1);
}
$file = "$LIBEXECDIR/licenseref.sql";
if (is_file($file)) {
$handle = fopen($file, "r");
$pattern = '/^INSERT INTO/';
$sql = "";
$flag = 0;
while(!feof($handle))
{
$buffer = fgets($handle, 4096);
if ( preg_match($pattern, $buffer) == 0)
{
$sql .= $buffer;
continue;
} else {
if ($flag)
{
@$result = pg_query($PGCONN, $sql);
if ($result == FALSE)
{
$PGError = pg_last_error($PGCONN);
if ($Debug)
{
print "SQL failed: $PGError\n";
}
}
@pg_free_result($result);
}
$sql = $buffer;
$flag = 1;
}
}
@$result = pg_query($PGCONN, $sql);
if ($result == FALSE)
{
$PGError = pg_last_error($PGCONN);
if ($Debug)
{
print "SQL failed: $PGError\n";
}
}
@pg_free_result($result);
fclose($handle);
} else {
print "FATAL: Unable to access '$file'.\n";
return (1);
}
return (0);
} // initLicenseRefTable()
......@@ -99,8 +99,11 @@ else
print "Initialization had errors.\n";
exit(1);
}
initLicenseRefTable(false);
exit(0);
/** \brief Print Usage statement.
* \return No return, this calls exit.
**/
......@@ -200,4 +203,76 @@ function bootstrap()
require_once("$MODDIR/lib/php/common.php");
return $SysConf;
}
/**
* \brief Load the license_ref table with licenses.
*
* \param $Verbose display database load progress information. If $Verbose is false,
* this function only prints errors.
*
* \return 0 on success, 1 on failure
**/
function initLicenseRefTable($Verbose)
{
global $LIBEXECDIR;
global $PGCONN;
if (!is_dir($LIBEXECDIR)) {
print "FATAL: Directory '$LIBEXECDIR' does not exist.\n";
return (1);
}
$dir = opendir($LIBEXECDIR);
if (!$dir) {
print "FATAL: Unable to access '$LIBEXECDIR'.\n";
return (1);
}
$file = "$LIBEXECDIR/licenseref.sql";
if (is_file($file)) {
$handle = fopen($file, "r");
$pattern = '/^INSERT INTO/';
$sql = "";
$flag = 0;
while(!feof($handle))
{
$buffer = fgets($handle, 4096);
if ( preg_match($pattern, $buffer) == 0)
{
$sql .= $buffer;
continue;
} else {
if ($flag)
{
@$result = pg_query($PGCONN, $sql);
if ($result == FALSE)
{
$PGError = pg_last_error($PGCONN);
if ($Debug)
{
print "SQL failed: $PGError\n";
}
}
@pg_free_result($result);
}
$sql = $buffer;
$flag = 1;
}
}
@$result = pg_query($PGCONN, $sql);
if ($result == FALSE)
{
$PGError = pg_last_error($PGCONN);
if ($Debug)
{
print "SQL failed: $PGError\n";
}
}
@pg_free_result($result);
fclose($handle);
} else {
print "FATAL: Unable to access '$file'.\n";
return (1);
}
return (0);
} // initLicenseRefTable()
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment