FOSSology  4.4.0
Open Source License Compliance by Open Source Software
schema-export.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008-2012 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
20 /* Note: php 5 getopt() ignores options not specified in the function call, so add
21  * dummy options in order to catch invalid options.
22  */
23 $AllPossibleOpts = "abc:d:ef:ghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
24 
25 /* defaults */
26 $Verbose = false;
27 $DatabaseName = "fossology";
28 $UpdateLiceneseRef = false;
29 $showUsage = false;
30 
31 /* default location of core-schema.dat. This file is checked into svn */
32 $SchemaFilePath = "$MODDIR/www/ui/core-schema.dat";
33 
34 /* command-line options */
35 $Options = getopt($AllPossibleOpts);
36 foreach ($Options as $Option => $OptVal) {
37  switch ($Option) {
38  case 'c': /* used by fo_wrapper */
39  break;
40  case 'd': /* optional database name */
41  $DatabaseName = $OptVal;
42  break;
43  case 'f': /* schema file */
44  $SchemaFilePath = $OptVal;
45  break;
46  case 'h': /* help */
47  $showUsage = true;
48  break;
49  default:
50  echo "Invalid Option \"$Option\".\n";
51  $showUsage = true;
52  }
53 }
54 
55 if ($showUsage) {
56  global $argv;
57 
58  $usage = "Usage: " . basename($argv[0]) . " [options]
59  Update FOSSology database. Options are:
60  -d {database name} default is 'fossology'
61  -f {output file}
62  -h this help usage";
63  print "$usage\n";
64 } else {
65  if (file_exists($SchemaFilePath) && !@unlink($SchemaFilePath)) {
66  $FailMsg = "Existing schema data file ($SchemaFilePath) could not be removed.";
67  } else {
68  $FailMsg = ExportSchema($SchemaFilePath);
69  }
70 
71  if ($FailMsg !== false) {
72  print "ERROR: $FailMsg \n";
73  exit(1);
74  }
75 }
ExportSchema($filename=NULL)
Export the schema of the connected ($PG_CONN) database to a file in the format readable by GetSchema(...
Definition: libschema.php:1122