search for INSTALL and COPYING files in more directories, don't fail if
authorJuerg Billeter <j@bitron.ch>
Tue, 27 Nov 2007 21:12:19 +0000 (21:12 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 27 Nov 2007 21:12:19 +0000 (21:12 +0000)
2007-11-27  Juerg Billeter  <j@bitron.ch>

* gen-project/valaprojectgenerator.vala: search for INSTALL and COPYING
  files in more directories, don't fail if auxiliary files can't be
  found, based on patch by Marcelo Lira, fixes bug 499806

svn path=/trunk/; revision=731

ChangeLog
gen-project/valaprojectgenerator.vala

index 9c0234b..ab528dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2007-11-27  Jürg Billeter  <j@bitron.ch>
 
+       * gen-project/valaprojectgenerator.vala: search for INSTALL and COPYING
+         files in more directories, don't fail if auxiliary files can't be
+         found, based on patch by Marcelo Lira, fixes bug 499806
+
+2007-11-27  Jürg Billeter  <j@bitron.ch>
+
        * gen-project/valaprojectgenerator.vala: add AM_MAINTAINER_MODE and
          replace deprecated INCLUDES by AM_CPPFLAGS
 
index 5dc8ba6..0636515 100644 (file)
@@ -193,16 +193,24 @@ class Vala.ProjectGenerator : Dialog {
                        FileUtils.set_contents (project_path + "/po/ChangeLog", "", -1);
 
                        string s;
-                       FileUtils.get_contents ("/usr/share/automake/INSTALL", out s);
-                       FileUtils.set_contents (project_path + "/INSTALL", s, -1);
+                       string automake_path = get_automake_path ();
+                       if (automake_path != null) {
+                               string install_filename = automake_path + "/INSTALL";
+                               if (FileUtils.test (install_filename, FileTest.EXISTS)) {
+                                       FileUtils.get_contents (install_filename, out s);
+                                       FileUtils.set_contents (project_path + "/INSTALL", s, -1);
+                               }
+                       }
 
                        string license_filename = null;
                        if (project_license == ProjectLicense.GPL2) {
-                               license_filename = "/usr/share/automake/COPYING";
+                               if (automake_path != null) {
+                                       license_filename = automake_path + "/COPYING";
+                               }
                        } else if (project_license == ProjectLicense.LGPL2) {
                                license_filename = "/usr/share/libtool/libltdl/COPYING.LIB";
                        }
-                       if (license_filename != null) {
+                       if (license_filename != null && FileUtils.test (license_filename, FileTest.EXISTS)) {
                                FileUtils.get_contents (license_filename, out s);
                                FileUtils.set_contents (project_path + "/COPYING", s, -1);
                        }
@@ -559,6 +567,20 @@ class Vala.ProjectGenerator : Dialog {
                FileUtils.set_contents (project_path + "/MAINTAINERS", s, -1);
        }
 
+       private string get_automake_path () {
+               var automake_paths = new string[] { "/usr/share/automake",
+                                                   "/usr/share/automake-1.10",
+                                                   "/usr/share/automake-1.9" };
+
+               foreach (string automake_path in automake_paths) {
+                       if (FileUtils.test (automake_path, FileTest.IS_DIR)) {
+                               return automake_path;
+                       }
+               }
+
+               return null;
+       }
+
        static void main (string[] args) {
                Gtk.init (ref args);