FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
create_test_database.php
1 #!/usr/bin/php
2 <?php
3 /*
4  Copyright (C) 2013-2014 Hewlett-Packard Development Company, L.P.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 // If set to TRUE, print additional DEBUG information. Note that
21 // printing this information will prevent the script from working
22 // from within the FOSSology makefiles
23 $debug = FALSE;
24 
25 $start_time = get_time();
26 
27 /*
28  create_test_database.php
29 
30  Create a minimal FOSSology test database and associated configuration,
31  if one does not already exist.
32 
33  This script is intended to provide a minimal PRE-INSTALLATION test
34  environment in which FOSSology Unit, Functional, and other tests can
35  be executed. It allows tests to be run without having the FOSSology
36  system installed on a target test system.
37 
38 
39  Here is what this script does:
40 
41  0) Check whether an environment variable FOSSOLOGY_TESTCONFIG is set
42  If so, this environment variable should point to the fossology
43  testing system configuration directory, which will be something like:
44 
45  /tmp/fossologytest_20120611_172315/
46 
47  If FOSSOLOGY_TESTCONFIG is set, then simply exit.
48  We do not validate the testing environment further, but any
49  subsequent tests should be able to use this test database and
50  system configuration.
51 
52  1) Make sure we can connect to postgres as the 'fossologytest' user.
53 
54  For this to work, the password must be specified in one of:
55 
56  * the PGPASSWORD environment variable
57  * the pgpass file specified by the PGPASSFILE environment variable
58  * the current user's ~/.pgpass file
59 
60  If we cannot connect as user 'fossologytest' then a few things
61  should be checked:
62 
63  a) Is PostgreSQL installed and running?
64  b) Does a 'fossologytest' Postgres user exist?
65  c) is a known password configured for user 'fossologytest'?
66 
67  2) Connect as the fossologytest user and create a new empty database
68 
69  The database should have a unique, easily-identifiable name that we
70  can use in subsequent FOSSology unit, function, or other tests.
71 
72  It will be called: 'fossologytest_YYYYMMDD_hhmmss
73 
74  where YYYYMMDD_hhmmss is a timestamp indicating when the database
75  was created.
76 
77  3) Load the core-schema.dat database schema into the new database
78 
79  This will be the core schema from the current working copy of the
80  FOSSology code from which this script is being executed.
81 
82  4) Create a temporary fossology system configuration directory for testing
83 
84  This is created in the system's temporary directory (e.g. /tmp).
85  It is named after the current testing database timestamp. Example:
86 
87  /tmp/fossologytest_20120611_172315/
88 
89  5) Create a Db.conf file in the testing system config directory
90 
91  This contains the database connection parameters that were just set up
92  and which should be used in subsequent tests. Example:
93 
94  /tmp/fossologytest_20120611_172315/Db.conf
95 
96  6) Create a mods-enabled directory in the temporary fossology system
97  configuration directory, and populate it with symlinks to the
98  working copy of fossology. Example:
99 
100  /tmp/fossologytest_20120611_172315/mods-enabled/adj2nest
101  /tmp/fossologytest_20120611_172315/mods-enabled/buckets
102  ...
103  /tmp/fossologytest_20120611_172315/mods-enabled/www
104 
105  7) Create an empty repository directory in the temporary fossology system
106  configuration directory for use in testing. Example:
107 
108  /tmp/fossologytest_20120611_172315/repository/
109 
110  8) Generate a simple fossology.conf file in the system config directory
111  with appropriate defaults for testing with the temporary fossology
112  test environment. Example:
113 
114  /tmp/fossologytest_20120611_172315/fossology.conf
115 
116 */
117 
118 
119 $test_username = 'fossologytest';
120 $test_environment_variable = 'FOSSOLOGY_TESTCONFIG';
121 
122 /* very first step - check for the FOSSOLOGY_TESTCONFIG environment variable.
123  If this exists, then our job here is done.
124  We simply echo the value to stdout and exit */
125 $fossology_testconfig = getenv($test_environment_variable);
126 
127 if ($fossology_testconfig && strlen($fossology_testconfig) > 1) {
128 
129  // just echo the value of the environment variable, and exit
130  echo "$fossology_testconfig\n";
131  exit(0);
132 
133 }
134 else {
135  debug("Did not find a valid $test_environment_variable environment variable");
136 }
137 
138 
139 
140 // check for a PGPASSWORD or PGPASSFILE environment variable
141 // PGPASSWORD specifies the actual password to use
142 // PGPASSFILE specifies the location of the 'pgpass' file
143 // Otherwise the .pgpass file in the current user's $HOME directory is
144 // where passwords are normally stored.
145 $pgpass_file = getenv('HOME') . '/.pgpass';
146 
147 $pg_password_environment = getenv('PGPASSWORD');
148 $pg_passfile_environment = getenv('PGPASSFILE');
149 
150 if ( $pg_password_environment ) {
151  // A PGPASSWORD environment variable overrides any other
152  // password authentication mechanism
153  debug("Found a PGPASSWORD environment variable of '$pg_password_environment' overriding any PGPASSFILE or ~/.pgpass authentication");
154 }
155 else {
156  if ( $pg_passfile_environment ) {
157  // A PGPASSFILE environment variable specifies the location
158  // of a pgpass file
159  debug("Found a PGPASSFILE environment variable of '$pg_passfile_environment' overriding any ~/.pgpass file");
160  $pgpass_file = $pg_passfile_environment;
161  }
162  if (is_file($pgpass_file)) {
163  $pgpass_perms = substr( sprintf("%o", fileperms($pgpass_file)), -4);
164  if ($pgpass_perms == '0600') {
165  debug("Permissions for $pgpass_file are correct (0600)");
166  $pgpass_contents = file($pgpass_file);
167 
168  // Scan thru the pgpass file for an entry for the test user
169  $testuser_found = FALSE;
170  foreach ($pgpass_contents as $line) {
171  if ( preg_match("/$test_username:[^:]*$/", $line) ) {
172  $testuser_found = TRUE;
173  }
174  }
175 
176  if ( $testuser_found == TRUE ) {
177  debug("Found a '$test_username' user in $pgpass_file");
178  }
179  else {
180  echo "FAIL: Did not find a '$test_username' user in $pgpass_file\n";
181  echo "Before you can run FOSSology tests, you must first create a Postgres user called '$test_username'\n";
182  echo "which has the CREATEDB permission. This can be done using the following SQL command (as the 'psql' Postgres super user):\n";
183  echo "\n CREATE USER $test_username WITH CREATEDB LOGIN PASSWORD '$test_username';\n";
184  echo "\nOnce done, this user needs to be added to a ~/.pgpass file with the following contents:\n";
185  // pgpass file needs an entry like 'localhost:*:*:fossologytest:fossologytest'
186  echo "\nlocalhost:*:*:$test_username:$test_username\n";
187  echo "\nAnd this file must have permissions set to 0600\n";
188  exit(1);
189  }
190  }
191  else {
192  echo "FAIL - Permissions for $pgpass_file are NOT correct, must be 0600\n";
193  exit (1);
194  }
195  }
196  else {
197  echo "FAIL - Pgpass file $pgpass_file does not exist, or is not a regular file\n";
198  exit (1);
199  }
200 }
201 
202 
203 
204 /* Check to see if we can connect to the Postgres server on the
205  local host as the 'fossologytest' user, using the built-in
206  PHP postgres connector
207 */
208 
209 // database 'template1' should exist by default on all Postgres servers
210 $template_db = 'template1';
211 $initial_postgres_params = "dbname=$template_db ";
212 $initial_postgres_params .= "host=localhost ";
213 /* the default Postgres port is 5432 */
214 //$postgres_params .= "port=5432 ";
215 $initial_postgres_params .= "user=$test_username ";
216 
217 // make sure that the new database can actually connect
218 $test_pg_conn = @pg_connect($initial_postgres_params);
219 
220 /* pg_connect returns a database connection handle, or FALSE if it
221  was not able to connect.
222 
223  If we were not able to connect, try to figure out why and
224  provide a helpful message to the tester */
225 if ( $test_pg_conn == FALSE ) {
226 
227  $error_array = error_get_last();
228  $pg_error_message = $error_array['message'];
229  echo "FAIL: Cannot connect to the local Postgres server. ";
230 
231  if ( preg_match('/no password supplied/', $pg_error_message) ) {
232  echo "The '$test_username' user must already exist and be included in a ~/.pgpass file, or the PGPASSWORD environment variable must be set!\n";
233  echo "Before you can run FOSSology tests, you must first create a Postgres user called '$test_username'\n";
234  echo "which has the CREATEDB permission. This can be done using the following SQL command (as the 'psql' Postgres super user):\n";
235  echo "\n CREATE USER $test_username WITH CREATEDB LOGIN PASSWORD '$test_username';\n";
236  echo "\nOnce done, this user needs to be added to a ~/.pgpass file with the following contents:\n";
237  // pgpass file needs an entry like 'localhost:*:*:fossologytest:fossologytest'
238  echo "\nlocalhost:*:*:$test_username:$test_username\n";
239  echo "\nAnd this file must have permissions set to 0600\n";
240  }
241  elseif ( preg_match('/authentication failed/', $pg_error_message) ) {
242  echo "The password for user '$test_username' is not correct!\n";
243  }
244  elseif ( preg_match("/database \"$template_db\" does not exist/", $pg_error_message) ) {
245  echo "The database '$template_db' does not exist!\n";
246  }
247  else {
248  echo "Unknown problem: $pg_error_message\n";
249  }
250 
251  exit(1);
252 }
253 else {
254  debug("Successfully connected to local Postgres server as user '$test_username'");
255 }
256 
257 pg_close($test_pg_conn) or die ("FAIL: We could not close the posgres connection!");
258 
259 
260 /* get the system's temporary directory location. We'll use this as the
261  base for the testing instance of the system config directory */
262 $system_temp_dir = sys_get_temp_dir();
263 
264 /* generate a timestamp directory name for this testing database instance
265  This will be, for example:
266  /tmp/fossologytest_20120611_172315/ */
267 $testing_timestamp = date("Ymd_His");
268 $testing_temp_dir = $system_temp_dir . '/fossologytest_' . $testing_timestamp;
269 
270 mkdir($testing_temp_dir, 0755, TRUE)
271  or die("FAIL! Cannot create test configuration directory at: $testing_temp_dir\n");
272 
273 $elapsed = get_time() - $start_time;
274 debug("Elapsed Time = $elapsed");
275 /* Now create a new, unique dataabase */
276 debug("Creating test database... ");
277 $test_db_name = "fossologytest_$testing_timestamp";
278 
279 // re-connect using the same template1 database as above
280 $test_pg_conn = @pg_connect($initial_postgres_params)
281  or die("FAIL: Could not connect to Postgres server!");
282 
283 // note: normal 'mortal' users cannot choose 'SQL_ASCII' encoding
284 // unless the LC_CTYPE environment variable is set correctly
285 //$sql_statement="CREATE DATABASE $test_db_name ENCODING='SQL_ASCII'";
286 // In the long run, FOSSology should be using a UTF8 encoding for text
287 $sql_statement="CREATE DATABASE $test_db_name ENCODING='UTF8' TEMPLATE template0";
288 $result = pg_query($test_pg_conn, $sql_statement)
289  or die("FAIL: Could not create test database!\n");
290 
291 // close the connection to the template1 database. Now we can
292 // reconnect to the newly-created test database
293 pg_close($test_pg_conn);
294 
295 debug("Done creating test database");
296 $elapsed = get_time() - $start_time;
297 debug("Elapsed Time = $elapsed");
298 
299 /* Now connect to the newly-created test database */
300 $test_db_params = "dbname=$test_db_name ";
301 $test_db_params .= "host=localhost ";
302 /* the default Postgres port is 5432 */
303 //$postgres_params .= "port=5432 ";
304 $test_db_params .= "user=$test_username ";
305 
306 $test_db_conn = pg_connect($test_db_params)
307  or die ("Could not connect to the new test database '$test_db_name'\n");
308 
309 
310 /* Do some minimal setup of the new database */
311 // Note: from Postgres 9.1 on, can use 'CREATE OR REPLACE LANGUAGE'
312 // instead of dropping and then re-creating
313 
314 // first check to make sure we don't already have the plpgsql language installed
315 $sql_statement = "select lanname from pg_language where lanname = 'plpgsql'";
316 
317 $result = pg_query($test_db_conn, $sql_statement)
318  or die("Could not check the database for plpgsql language\n");
319 
320 $plpgsql_already_installed = FALSE;
321 if ( $row = pg_fetch_row($result) ) {
322  $plpgsql_already_installed = TRUE;
323 }
324 
325 // then create language plpgsql if not already created
326 if ( $plpgsql_already_installed == FALSE ) {
327  $sql_statement = "CREATE LANGUAGE plpgsql";
328  $result = pg_query($test_db_conn, $sql_statement)
329  or die("Could not create plpgsql language in the database\n");
330 }
331 
332 
333 /* now create a valid Db.conf file in the testing temp directory
334  for accessing our fancy pants new test database */
335 $db_conf_fh = fopen("$testing_temp_dir/Db.conf", 'w')
336  or die("FAIL! Cannot write $testing_temp_dir/Db.conf\n");
337 fwrite($db_conf_fh, "dbname = $test_db_name;\n");
338 fwrite($db_conf_fh, "host = localhost;\n");
339 fwrite($db_conf_fh, "user = $test_username;\n");
340 // Note: because the Db.conf file is itself just the parameters
341 // used in the pg_connect() command, we should be able to
342 // safely omit the password, since whatever mechanism was
343 // already in place to authenticate can still be used.
344 //fwrite($db_conf_fh, "password = fossologytest;\n");
345 fclose($db_conf_fh);
346 
347 
348 /* now create a mods-enabled directory to contain symlinks to the
349  agents in the current working copy of fossology */
350 $mods_enabled_dir = "$testing_temp_dir/mods-enabled";
351 
352 mkdir($mods_enabled_dir, 0755, TRUE)
353  or die("FAIL! Cannot create test mods-enabled directory at: $mods_enabled_dir\n");
354 
355 /* here we have to do the work that each of the agents' 'make install'
356  targets would normally do, but since we want the tests to be able
357  to execute before FOSSology is installed, we need to do a minimal
358  amount of work to enable them */
359 
360 /* for each src/ directory above us, create a symlink for it in the
361  temporary testing mods-enabled directory we just created;
362  but always skip the cli and lib directories */
363 
364 $fo_base_dir = realpath(__DIR__ . '/../..');
365 $src_dirs = scandir($fo_base_dir);
366 
367 foreach ($src_dirs as $src_dir) {
368  $full_src_dir = $fo_base_dir . "/" . $src_dir;
369  // skip dotted directories, lib/, cli/, and other irrelevant directories
370  if ( preg_match("/^\./", $src_dir)
371  || $src_dir == 'lib'
372  || $src_dir == 'cli'
373  || $src_dir == 'example_wc_agent'
374  || $src_dir == 'tutorials'
375  || $src_dir == 'srcdocs'
376  || $src_dir == 'testing'
377  || $src_dir == 'demomod'
378  ) {
379  continue;
380  }
381  $splitModuls = array('monk'=>array('monk','monkbulk'),'copyright'=>array('copyright','ecc'));
382  if ( array_key_exists($src_dir,$splitModuls) ) {
383  foreach($splitModuls[$src_dir] as $agent){
384  mkdir("$mods_enabled_dir/$agent");
385  symlink("$full_src_dir/agent", "$mods_enabled_dir/$agent/agent");
386  symlink("$full_src_dir/ui", "$mods_enabled_dir/$agent/ui");
387  symlink("$full_src_dir/$agent.conf", "$mods_enabled_dir/$agent/$agent.conf");
388  symlink("$full_src_dir/VERSION-$agent", "$mods_enabled_dir/$agent/VERSION");
389  }
390  continue;
391  }
392  if (is_dir($full_src_dir)) {
393  symlink($full_src_dir, "$mods_enabled_dir/$src_dir")
394  or die("FAIL - could not create symlink for $src_dir in $mods_enabled_dir\n");
395  }
396 }
397 
398 /*
399 $des_dir = "/srv/fossologyTestRepo/testConf/mods-enabled/";
400 if (is_dir($des_dir)) {
401  symlink($des_dir, "$mods_enabled_dir")
402  or die("FAIL - could not create symlink for $des_dir\n");
403 }
404 else {
405  print "please run make install from source before do the test.\n";
406 }
407 */
408 
409 /* Now let's set up a test repository location, which is just an empty
410  subdirectory within our temporary testing system config directory */
411 $test_repo_dir = "$testing_temp_dir/repository";
412 mkdir($test_repo_dir, 0755, TRUE)
413  or die ("FAIL! Cannot create test repository directory at: $test_repo_dir\n");
414 
415 
416 /* now create a valid fossology.conf file in the testing
417  temp directory */
418 
419 // be lazy and just use a system call to gather user and group name
420 $user_name = rtrim(`id -un`);
421 $group_name = rtrim(`id -gn`);
422 // generate a random port number above 10,000 to use for testing
423 $fo_port_number = mt_rand(10001, 32768);
424 
425 $fo_conf_fh = fopen("$testing_temp_dir/fossology.conf", 'w')
426  or die("FAIL: Could not open $testing_temp_dir/fossology.conf for writing\n");
427 fwrite($fo_conf_fh, "; fossology.conf for testing\n");
428 fwrite($fo_conf_fh, "[FOSSOLOGY]\n");
429 fwrite($fo_conf_fh, "port = $fo_port_number\n");
430 fwrite($fo_conf_fh, "address = localhost\n");
431 fwrite($fo_conf_fh, "depth = 3\n");
432 fwrite($fo_conf_fh, "path = $test_repo_dir\n");
433 fwrite($fo_conf_fh, "[HOSTS]\n");
434 fwrite($fo_conf_fh, "localhost = localhost AGENT_DIR 10\n");
435 fwrite($fo_conf_fh, "[REPOSITORY]\n");
436 fwrite($fo_conf_fh, "localhost = * 00 ff\n");
437 fwrite($fo_conf_fh, "[DIRECTORIES]\n");
438 fwrite($fo_conf_fh, "PROJECTUSER=$user_name\n");
439 fwrite($fo_conf_fh, "PROJECTGROUP=$group_name\n");
440 fwrite($fo_conf_fh, "MODDIR=$fo_base_dir\n");
441 fwrite($fo_conf_fh, "BINDIR=$fo_base_dir/cli\n");
442 fwrite($fo_conf_fh, "SBINDIR=$fo_base_dir/cli\n");
443 fwrite($fo_conf_fh, "LIBEXECDIR=$fo_base_dir/lib\n");
444 fwrite($fo_conf_fh, "LOGDIR=$testing_temp_dir\n");
445 fclose($fo_conf_fh);
446 
447 
448 /* Write a VERSION file */
449 
450 $fo_version_fh = fopen("$testing_temp_dir/VERSION", 'w')
451  or die("FAIL: Could not open $testing_temp_dir/VERSION for writing\n");
452 fwrite($fo_version_fh, "[BUILD]\n");
453 fwrite($fo_version_fh, "VERSION=test\n");
454 fwrite($fo_version_fh, "COMMIT_HASH=0000\n");
455 $build_date = date("Y/m/d H:i");
456 fwrite($fo_version_fh, "BUILD_DATE=$build_date\n");
457 fclose($fo_version_fh);
458 
459 /* now load the fossology core schema into the database */
460 $core_schema_dat_file = $fo_base_dir . "/www/ui/core-schema.dat";
461 
462 // use our existing test database connection to populate the
463 // database with the FOSSology ApplySchema() function
464 
465 // To make absolutely sure we do not interfere with any existing
466 // database connections, save off any pre-existing database connections
467 if (isset($PG_CONN)) {
468  $previous_PG_CONN = $PG_CONN;
469 }
470 
471 // assign the global PG_CONN variable used by ApplySchema
472 $PG_CONN = $test_db_conn;
473 
474 /* We are going to break some testing rules here, by including and
475  using application code within the testing framework:
476 
477  PHP Library: Function we use:
478  ------------ ----------------
479  ../../lib/php/libschema.php ApplySchema() (used to load core-schema.dat)
480  ../../lib/php/common-db.php DBCheckResult()
481  ../../lib/php/common-cache.php ReportCachePurgeAll() (required by ApplySchema)
482 
483 */
484 if(!is_file(__DIR__ . '/../../vendor/autoload.php'))
485 {
486  throw new Exception('you need to run "composer install" before creating adatabase via ApplySchema');
487 }
488 
489 require_once(__DIR__ . '/../../lib/php/libschema.php');
490 require_once(__DIR__ . '/../../lib/php/common-db.php');
491 require_once(__DIR__ . '/../../lib/php/common-cache.php');
492 
493 // apply the core schema
494 // We need to buffer the output in order to silence the normal
495 // output generated by ApplySchema, or it will interfere with
496 // our makefile interface
497 debug("Applying the FOSSOlogy schema to test database via ApplySchema()");
498 ob_start();
499 $apply_result = ApplySchema($core_schema_dat_file, false, $test_db_name);
500 
501 // then re-assign the previous PG_CONN, if there was one
502 if (isset($previous_PG_CONN)) {
503  $PG_CONN = $previous_PG_CONN;
504 }
505 
506 if (!empty($apply_result)) {
507  die("FAIL: ApplySchema did not succeed. Output was:\n$apply_result\n");
508 }
509 debug("Done Applying the FOSSOlogy schema to test database via ApplySchema()");
510 $elapsed = get_time() - $start_time;
511 debug("Elapsed Time = $elapsed");
512 
513 // insert the 'fossy' user into the test database
514 // this is the FOSSology user 'fossy' (not a Postgres user, or a system user)
515 $random_seed = rand().rand();
516 $hash = sha1($random_seed . "fossy");
517 $user_sql = "INSERT INTO users (user_pk, user_name, user_desc, user_seed, user_pass, user_perm, user_email, email_notify, root_folder_fk) VALUES (1, 'fossy', 'Default Administrator', '$random_seed', '$hash', 10, 'fossy', 'n', 1);";
518 pg_query($test_db_conn, $user_sql)
519  or die("FAIL: could not insert default user into user table\n");
520 
521 // insert top level folder 'Software Repository'
522 $folder_sql = "INSERT INTO folder(folder_pk, folder_name, folder_desc) values(1, 'Software Repository', 'Top Folder');";
523 pg_query($test_db_conn, $folder_sql)
524  or die("FAIL: could not insert top folder\n");
525 $folder_sql = "INSERT INTO foldercontents (parent_fk, foldercontents_mode, child_id) VALUES (1, 0, 0);";
526 pg_query($test_db_conn, $folder_sql)
527  or die("FAIL: could not insert top folder contents\n");
528 $folder_sql = "SELECT setval('folder_folder_pk_seq', (SELECT max(folder_pk) + 1 FROM folder LIMIT 1));";
529 pg_query($test_db_conn, $folder_sql)
530  or die("FAIL: could not change folder sequence\n");
531 
532 $LIBEXECDIR = "$fo_base_dir/lib/";
533 $MODDIR = "$fo_base_dir/";
534 /* for the 2.0 -> 2.1 migration, create the uploadtree_0 table */
535 require_once(__DIR__ . '/../../lib/php/libschema.php');
536 require_once(__DIR__ . "/../../../install/db/dbmigrate_2.0-2.1.php"); // hardcode for now
537 require_once(__DIR__ . "/../../../install/db/dbmigrate_2.1-2.2.php"); // hardcode for now
538 $Verbose = 0;
539 Migrate_20_21($Verbose);
540 Migrate_21_22($Verbose);
541 ob_end_clean();
542 
543 /* now we are done setting up the test database */
544 pg_close($test_db_conn);
545 
546 
547 /* When we finish successfully, print out the testing SYSCONFDIR
548  to stdout as the ONLY output from the script. In this way it
549  can be "imported" into the GNU Make environment */
550 debug("Successful test database creation");
551 $elapsed = get_time() - $start_time;
552 debug("Elapsed Time = $elapsed");
553 echo "$testing_temp_dir\n";
554 
555 // indicate a successful run
556 exit(0);
557 
558 
559 
560 
561 
562 
563 /*********************************************************************
564  *********************************************************************
565  *** ***
566  *** Function definitions ***
567  *** ***
568  *********************************************************************
569  *********************************************************************/
570 
571 // print a debug message, but only when "$debug" is set
572 function debug($message) {
573  global $debug;
574  if ($debug == TRUE) {
575  echo "DEBUG: $message\n";
576  }
577 }
578 
579 // get the time in seconds including decimal microseconds since UNIX epoch
580 function get_time() {
581 
582  list($usec,$sec) = explode(' ', microtime());
583  return ((float)$usec + (float)$sec);
584 
585 }
int debug
Definition: buckets.c:68
ApplySchema($Filename=NULL, $Debug=false, $Catalog= 'fossology')
Make schema match $Filename. This is a single transaction.
Definition: libschema.php:1051
if(!preg_match("/\s$projectGroup\s/", $groups)&&(posix_getgid()!=$gInfo['gid']))
get monk license list of one specified uploadtree_id
Definition: migratetest.php:44
Definition: db.php:41
Migrate_20_21($DryRun)
Migrate to the uploadtree_a table.
fo_conf * conf
The loaded configuration data.
Definition: fo_cli.c:50
FUNCTION int max(int permGroup, int permPublic)
Get the maximum group privilege.
Definition: libfossagent.c:309
Migrate_21_22($Verbose)
Create new groups, group_user_member, perm_upload and perm_folder records to support 2...
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
list_t type structure used to keep various lists. (e.g. there are multiple lists).
Definition: nomos.h:321
const char * folder_name
Definition: sqlstatements.h:65