def init_ftp(): if not os.path.exists(ftp_dir): os.makedirs(ftp_dir) postgresql_jdbc_file = os.path.join(ftp_dir, bootstrap.postgresql_jdbc_name) if not file_utils.check_file(postgresql_jdbc_file, bootstrap.postgresql_jdbc_md5): sp.check_call([wget, "-O", postgresql_jdbc_file, bootstrap.postgresql_jdbc_url_default]) postgresql_deb_file = os.path.join(ftp_dir, bootstrap.postgresql_deb_name) if not file_utils.check_file(postgresql_deb_file, bootstrap.postgresql_deb_md5): sp.check_call([wget, "-O", postgresql_deb_file, bootstrap.postgresql_deb_url_default]) geotools_src_archive_file = os.path.join(ftp_dir, bootstrap.geotools_src_archive_name) if not file_utils.check_file(geotools_src_archive_file, bootstrap.geotools_src_archive_md5): sp.check_call([wget, "-O", geotools_src_archive_file, bootstrap.geotools_url_default]) postgis_src_archive_file = os.path.join(ftp_dir, bootstrap.postgis_src_archive_name) if not file_utils.check_file(postgis_src_archive_file, bootstrap.postgis_src_archive_md5): sp.check_call([wget, "-O", postgis_src_archive_file, bootstrap.postgis_url_default]) commons_src_archive_file = os.path.join(ftp_dir, bootstrap.commons_src_archive_name) if not file_utils.check_file(commons_src_archive_file, bootstrap.commons_src_archive_md5): sp.check_call([wget, "-O", commons_src_archive_file, bootstrap.commons_src_archive_url_default]) jgrapht_file = os.path.join(ftp_dir, bootstrap.jgrapht_name) if not file_utils.check_file(jgrapht_file, bootstrap.jgrapht_md5): sp.check_call([wget, "-O", jgrapht_file, bootstrap.jgrapht_url_default]) jfuzzy_file = os.path.join(ftp_dir, bootstrap.jfuzzy_name) if not file_utils.check_file(jfuzzy_file, bootstrap.jfuzzy_md5): sp.check_call([wget, "-O", jfuzzy_file, bootstrap.jfuzzy_url_default]) maven_bin_archive_file = os.path.join(ftp_dir, bootstrap.maven_bin_archive_name) if not file_utils.check_file(maven_bin_archive_file, bootstrap.maven_bin_archive_md5): sp.check_call([wget, "-O", maven_bin_archive_file, bootstrap.maven_bin_archive_url_default]) packages = ["python-pyftpdlib"] sp.check_call([apt_get, "install", ]+packages) # as long as pyftpdlib doesn't support shutdown (see https://code.google.com/p/pyftpdlib/issues/detail?id=267) use a subprocess and kill it if SIGINT is received (listening to SIGINT is also necessary if FTP server runs in a separate thread) def __ftp_process__(): from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import FTPHandler from pyftpdlib.servers import FTPServer authorizer = DummyAuthorizer() authorizer.add_user(ftp_user, ftp_pw, ftp_dir, perm="elradfmw") authorizer.add_anonymous(ftp_dir) handler = FTPHandler handler.authorizer = authorizer handler.banner = "pyftpdlib based ftpd ready." server = FTPServer((ftp_address, ftp_port), handler) server.serve_forever() global ftp_process ftp_process = multiprocessing.Process(target=__ftp_process__) ftp_process.start() logger.info("sleeping %s s to ensure ftp server is started" % str(ftp_server_start_timeout)) time.sleep(ftp_server_start_timeout)
def bootstrap( ignore_root_warning, force_overwrite_postgres_datadir, skip_tests, bootstrap_dir=bootstrap_dir_default, skip_build=False, psql=psql, initdb=initdb, createdb=createdb, postgres=postgres, postgres_datadir_path=postgres_datadir_path_default, postgresql_jdbc_url=postgresql_jdbc_url_default, postgresql_deb_url=postgresql_deb_url_default, geotools_url=geotools_url_default, jgrapht_url=jgrapht_url_default, jfuzzy_url=jfuzzy_url_default, maven_bin_archive_url=maven_bin_archive_url_default, commons_src_archive_url=commons_src_archive_url_default, postgis_install="pm", postgis_url=postgis_url_default, ): "Bootstrap the PGALISE simulation, including installation of dependencies (those which can't be fetched by maven), binaries (postgresql, postgis, etc.), setup of database in " # force specification of flag if script is invoked as root if os.getuid() == 0 and not ignore_root_warning: raise RuntimeError( "Script is invoked as root which is strongly discouraged. Specify the -I/--ignore-root-warning in order to overwrite. You have been warned!" ) # setup directories script_dir = os.path.join(base_dir, "scripts") external_dir = os.path.join(bootstrap_dir, "external") internal_dir = os.path.join(bootstrap_dir, "internal") # used for postgresql socket tmp_dir = os.path.join( script_dir, "tmp") # "/tmp less save than dir only readable by user" external_bin_dir = os.path.join(external_dir, "bin") external_src_dir = os.path.join(external_dir, "src") if not os.path.exists(bin_dir): os.makedirs(bin_dir) if not os.path.exists(bootstrap_dir): os.makedirs(bootstrap_dir) if not os.path.exists(external_dir): os.makedirs(external_dir) if not os.path.exists(external_bin_dir): os.makedirs(external_bin_dir) if not os.path.exists(external_src_dir): os.makedirs(external_src_dir) if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) user = sp.check_output([whoami]) postgres_socket_dir = tmp_dir # is this ok? # check some prequisites (after installation as they might be installed properly) java_home = os.getenv("JAVA_HOME") # necessary for mvn if java_home is None or java_home == "": raise RuntimeError("JAVA_HOME is not set") java_binary = os.path.join(java_home, "bin/java") if not os.path.exists(java_binary): raise RuntimeError( "JAVA_HOME %s doesn't seem to point to a valid JDK (java binary '%s' doesn't exist)" % (java_home, java_binary)) # install postgresql jdbc driver postgresql_jdbc_file = os.path.join(external_bin_dir, postgresql_jdbc_name) if not file_utils.check_file(postgresql_jdbc_file, postgresql_jdbc_md5): do_wget(postgresql_jdbc_url, postgresql_jdbc_file) if pg_version == (9, 2): postgresql_jdbc_mvn_version = "9.2-1004.jdbc4" elif pg_version == (9, 3): postgresql_jdbc_mvn_version = "9.2-1004.jdbc4" #@TODO: not optimal to have different client and server versions else: raise RuntimeError("postgresql version %s not supported" % string.join([str(x) for x in pg_version], ".")) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % postgresql_jdbc_file, "-DartifactId=postgresql", \ "-DgroupId=postgresql", "-Dversion=%s" % postgresql_jdbc_mvn_version, "-Dpackaging=jar"], cwd=external_bin_dir) # install jgrapht (install net.sf.jgrapht:jgrapht:0.8.3 as org.jgrapht:jgrapht:0.8.3 (could not be found in any repository)) jgrapht_file = os.path.join(external_bin_dir, jgrapht_name) if not file_utils.check_file(jgrapht_file, jgrapht_md5): do_wget(jgrapht_url, jgrapht_file) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % jgrapht_file, "-DartifactId=jgrapht", "-DgroupId=org.jgrapht", "-Dversion=0.8.3", "-Dpackaging=jar"], cwd=external_bin_dir) # install jfuzzylogic jfuzzy_file = os.path.join(external_bin_dir, jfuzzy_name) if not file_utils.check_file(jfuzzy_file, jfuzzy_md5): do_wget(jfuzzy_url, jfuzzy_file) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % jfuzzy_file, "-DartifactId=jfuzzy", "-DgroupId=pcingola", "-Dversion=3.0", "-Dpackaging=jar"], cwd=external_bin_dir) # geronimo not available as binary (but depends on eclipse source stuff...) #geronimo_file_name = "geronimo-3.0.1" #geronimo_src_archive_name = "geronimo-3.0.1-source-release.zip" #geronimo_url = "http://mirrors.ibiblio.org/maven2/org/apache/geronimo/geronimo/3.0.1/geronimo-3.0.1-source-release.zip" #geronimo_file_path = os.path.join(external_src_dir, geronimo_file_name) # install geotools #geotools_src_dir = os.path.join(external_src_dir, geotools_src_dir_name) #if not file_utils.check_dir(geotools_src_dir): # if not ch...le(os.path.join(external_src_dir, geotools_src_archive_name)) or file_utils.retrieve_md5sum(os.path.join(external_src_dir, geotools_src_archive_name)) != geotools_src_archive_md5: # do_wget() ... sp.check_call([wget, geotools_url], cwd=tmp_dir) # sp.check_call([unzip, os.path.join(tmp_dir, geotools_src_archive_name)], cwd=external_src_dir) #if not skip_build: # mvn_settings_file_path = os.path.join(script_dir, "settings.xml") # sp.check_call([mvn, "-e", "--global-settings", mvn_settings_file_path, "--settings", mvn_settings_file_path, "install", "-Dall", "-DskipTests=true"], cwd=geotools_src_dir) # install commons-collections 4 #commons_src_dir = os.path.join(external_src_dir, commons_src_dir_name) #if not file_utils.check_dir(commons_src_dir): # commons_src_archive_file = os.path.join(external_src_dir, commons_src_archive_name) # if not file_utils.check_file(commons_src_archive_file, commons_src_archive_md5): # do_wget(commons_src_archive_url, commons_src_archive_file) # sp.check_call([tar, "xf", commons_src_archive_file], cwd=external_src_dir) #if not skip_build: # mvn_install(commons_src_dir, skip_tests) # install postgis from source (installation with package manager occurs in # bootstrap_privileged.py if postgis_install == "source": # installation of postgis-jdbc from bin directory should not occur in sources installation as this refers to the version shipped with the tarball -> will install mvn project in subdirectory of tarball root postgis_src_dir = os.path.join(external_src_dir, postgis_src_dir_name) if check_os.check_ubuntu() or check_os.check_debian(): if not file_utils.check_dir(postgis_src_dir): postgis_src_archive_file = os.path.join( external_src_dir, postgis_src_archive_name) if not file_utils.check_file(postgis_src_archive_file, postgis_src_archive_md5): do_wget(postgis_url, postgis_src_archive_file) sp.check_call([tar, "xf", postgis_src_archive_file], cwd=external_src_dir) if not skip_build: pm_utils.install_apt_get_build_dep( ["postgis"], package_manager=apt_get, skip_apt_update=skip_apt_update ) # might not be sufficient because Ubuntu 13.10's version of postgis is 1.5.x (we're using 2.x) pm_utils.install_packages( ["libgdal-dev"], package_manager=apt_get, skip_apt_update=skip_apt_update ) # not covered by 1.5.x requirements (see above) sp.check_call([bash, "autogen.sh"], cwd=postgis_src_dir) sp.check_call([bash, "configure"], cwd=postgis_src_dir) sp.check_call([make, "-j8"], cwd=postgis_src_dir) sp.check_call([make, "install"], cwd=postgis_src_dir) # install postgis-jdbc (project is shipped inside postgis project (as long as a fixed version of postgis is used here, the version of postgis-jdbc will be fixed, too (postgis 2.1.1 -> postgis-jdbc 2.1.0SVN) postgis_mvn_project_path = os.path.join(postgis_src_dir, "java/jdbc") sp.check_call( [ant], cwd=postgis_mvn_project_path) # generates maven project mvn_install(postgis_mvn_project_path, skip_tests) elif check_os.check_opensuse(): raise RuntimeError("PostGIS source installation not supported") else: # better to let the script fail here than to get some less comprehensive error message later raise RuntimeError("Operating system not supported!") elif postgis_install == "pm": # install postgis from scripts/bin (as it is not available from somewhere online) postgis_jdbc_file = os.path.join(bin_dir, postgis_jdbc_name) if not os.path.exists(postgis_jdbc_file): raise RuntimeError( "postgis JDBC jar %s doesn't exist, can't continue, consider fetching it manually" % (postgis_jdbc_file, )) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % postgis_jdbc_file, "-DartifactId=postgis-jdbc", "-DgroupId=org.postgis", "-Dversion=2.1.0SVN", "-Dpackaging=jar"], cwd=bin_dir) else: raise RuntimeError("postgis_install %s isn't supported" % (postgis_install, )) # always install openejb from bin directory (might be made flexible with source installation like postgis (see above) later) openejb_jar_file_path = os.path.join(bin_dir, openejb_jar_file_name) if not os.path.exists(openejb_jar_file_path): raise RuntimeError( "OpenEJB jar %s doesn't exist, can't continue, consider fetching it manually" % (openejb_jar_file_path, )) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % (openejb_jar_file_path,), "-DartifactId=openejb-core", "-DgroupId=org.apache.openejb", "-Dversion=4.7.0-SNAPSHOT", "-Dpackaging=jar"], cwd=bin_dir) openejb_api_jar_file_path = os.path.join(bin_dir, openejb_api_jar_file_name) if not os.path.exists(openejb_api_jar_file_path): raise RuntimeError( "OpenEJB API jar %s doesn't exist, can't continue, consider fetching it manually" % (openejb_api_jar_file_path, )) sp.check_call([ mvn, "install:install-file", "-Dfile=%s" % (openejb_api_jar_file_path, ), "-DartifactId=openejb-api", "-DgroupId=org.apache.openejb", "-Dversion=4.7.0-SNAPSHOT", "-Dpackaging=jar" ], cwd=bin_dir) #openejb_snapshot_ahtutils_workaround(external_src_dir) # setup postgis datadir and configuration if not file_utils.check_dir( postgres_datadir_path) or force_overwrite_postgres_datadir: # os.makedirs(postgres_datadir_path) # causes error if directory exists and is not necessary postgis_utils.bootstrap_datadir(postgres_datadir_path, postgres_user, password=postgres_pw, initdb=initdb) postgis_utils.bootstrap_database(postgres_datadir_path, postgres_port, postgres_host, postgres_user, pgalise_db_name, password=postgres_pw, initdb=initdb, postgres=postgres, createdb=createdb, psql=psql) postgis_utils.bootstrap_database(postgres_datadir_path, postgres_port, postgres_host, postgres_user, pgalise_db_test_name, password=postgres_pw, initdb=initdb, postgres=postgres, createdb=createdb, psql=psql) else: logger.info( "Postgres datadir %s has not been overwritten. Check output of script invoked with -h/--help on how to do that." % (postgres_datadir_path, ))
def check_file(self,fileName): """ file_utils.ファイルチェックのらっぱ """ try : file_utils.check_file(fileName) except IOError as e : self.error(str(e))
def init_ftp(): if not os.path.exists(ftp_dir): os.makedirs(ftp_dir) postgresql_jdbc_file = os.path.join(ftp_dir, bootstrap.postgresql_jdbc_name) if not file_utils.check_file(postgresql_jdbc_file, bootstrap.postgresql_jdbc_md5): sp.check_call([ wget, "-O", postgresql_jdbc_file, bootstrap.postgresql_jdbc_url_default ]) postgresql_deb_file = os.path.join(ftp_dir, bootstrap.postgresql_deb_name) if not file_utils.check_file(postgresql_deb_file, bootstrap.postgresql_deb_md5): sp.check_call([ wget, "-O", postgresql_deb_file, bootstrap.postgresql_deb_url_default ]) geotools_src_archive_file = os.path.join( ftp_dir, bootstrap.geotools_src_archive_name) if not file_utils.check_file(geotools_src_archive_file, bootstrap.geotools_src_archive_md5): sp.check_call([ wget, "-O", geotools_src_archive_file, bootstrap.geotools_url_default ]) postgis_src_archive_file = os.path.join(ftp_dir, bootstrap.postgis_src_archive_name) if not file_utils.check_file(postgis_src_archive_file, bootstrap.postgis_src_archive_md5): sp.check_call([ wget, "-O", postgis_src_archive_file, bootstrap.postgis_url_default ]) commons_src_archive_file = os.path.join(ftp_dir, bootstrap.commons_src_archive_name) if not file_utils.check_file(commons_src_archive_file, bootstrap.commons_src_archive_md5): sp.check_call([ wget, "-O", commons_src_archive_file, bootstrap.commons_src_archive_url_default ]) jgrapht_file = os.path.join(ftp_dir, bootstrap.jgrapht_name) if not file_utils.check_file(jgrapht_file, bootstrap.jgrapht_md5): sp.check_call( [wget, "-O", jgrapht_file, bootstrap.jgrapht_url_default]) jfuzzy_file = os.path.join(ftp_dir, bootstrap.jfuzzy_name) if not file_utils.check_file(jfuzzy_file, bootstrap.jfuzzy_md5): sp.check_call([wget, "-O", jfuzzy_file, bootstrap.jfuzzy_url_default]) maven_bin_archive_file = os.path.join(ftp_dir, bootstrap.maven_bin_archive_name) if not file_utils.check_file(maven_bin_archive_file, bootstrap.maven_bin_archive_md5): sp.check_call([ wget, "-O", maven_bin_archive_file, bootstrap.maven_bin_archive_url_default ]) packages = ["python-pyftpdlib"] sp.check_call([ apt_get, "install", ] + packages) # as long as pyftpdlib doesn't support shutdown (see https://code.google.com/p/pyftpdlib/issues/detail?id=267) use a subprocess and kill it if SIGINT is received (listening to SIGINT is also necessary if FTP server runs in a separate thread) def __ftp_process__(): from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import FTPHandler from pyftpdlib.servers import FTPServer authorizer = DummyAuthorizer() authorizer.add_user(ftp_user, ftp_pw, ftp_dir, perm="elradfmw") authorizer.add_anonymous(ftp_dir) handler = FTPHandler handler.authorizer = authorizer handler.banner = "pyftpdlib based ftpd ready." server = FTPServer((ftp_address, ftp_port), handler) server.serve_forever() global ftp_process ftp_process = multiprocessing.Process(target=__ftp_process__) ftp_process.start() logger.info("sleeping %s s to ensure ftp server is started" % str(ftp_server_start_timeout)) time.sleep(ftp_server_start_timeout)
def bootstrap(ignore_root_warning, force_overwrite_postgres_datadir, skip_tests, bootstrap_dir=bootstrap_dir_default, skip_build=False, psql=psql, initdb=initdb, createdb=createdb, postgres=postgres, postgres_datadir_path=postgres_datadir_path_default, postgresql_jdbc_url=postgresql_jdbc_url_default, postgresql_deb_url=postgresql_deb_url_default, geotools_url=geotools_url_default, jgrapht_url=jgrapht_url_default, jfuzzy_url=jfuzzy_url_default, maven_bin_archive_url=maven_bin_archive_url_default, commons_src_archive_url=commons_src_archive_url_default, postgis_install="pm", postgis_url=postgis_url_default, ): "Bootstrap the PGALISE simulation, including installation of dependencies (those which can't be fetched by maven), binaries (postgresql, postgis, etc.), setup of database in " # force specification of flag if script is invoked as root if os.getuid() == 0 and not ignore_root_warning: raise RuntimeError("Script is invoked as root which is strongly discouraged. Specify the -I/--ignore-root-warning in order to overwrite. You have been warned!") # setup directories script_dir = os.path.join(base_dir, "scripts") external_dir = os.path.join(bootstrap_dir, "external") internal_dir = os.path.join(bootstrap_dir, "internal") # used for postgresql socket tmp_dir = os.path.join(script_dir, "tmp") # "/tmp less save than dir only readable by user" external_bin_dir = os.path.join(external_dir, "bin") external_src_dir = os.path.join(external_dir, "src") if not os.path.exists(bin_dir): os.makedirs(bin_dir) if not os.path.exists(bootstrap_dir): os.makedirs(bootstrap_dir) if not os.path.exists(external_dir): os.makedirs(external_dir) if not os.path.exists(external_bin_dir): os.makedirs(external_bin_dir) if not os.path.exists(external_src_dir): os.makedirs(external_src_dir) if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) user = sp.check_output([whoami]) postgres_socket_dir = tmp_dir # is this ok? # check some prequisites (after installation as they might be installed properly) java_home = os.getenv("JAVA_HOME") # necessary for mvn if java_home is None or java_home == "": raise RuntimeError("JAVA_HOME is not set") java_binary = os.path.join(java_home, "bin/java") if not os.path.exists(java_binary): raise RuntimeError("JAVA_HOME %s doesn't seem to point to a valid JDK (java binary '%s' doesn't exist)" % (java_home, java_binary)) # install postgresql jdbc driver postgresql_jdbc_file = os.path.join(external_bin_dir, postgresql_jdbc_name) if not file_utils.check_file(postgresql_jdbc_file, postgresql_jdbc_md5): do_wget(postgresql_jdbc_url, postgresql_jdbc_file) if pg_version == (9,2): postgresql_jdbc_mvn_version = "9.2-1004.jdbc4" elif pg_version == (9,3): postgresql_jdbc_mvn_version = "9.2-1004.jdbc4" #@TODO: not optimal to have different client and server versions else: raise RuntimeError("postgresql version %s not supported" % string.join([str(x) for x in pg_version],".")) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % postgresql_jdbc_file, "-DartifactId=postgresql", \ "-DgroupId=postgresql", "-Dversion=%s" % postgresql_jdbc_mvn_version, "-Dpackaging=jar"], cwd=external_bin_dir) # install jgrapht (install net.sf.jgrapht:jgrapht:0.8.3 as org.jgrapht:jgrapht:0.8.3 (could not be found in any repository)) jgrapht_file = os.path.join(external_bin_dir, jgrapht_name) if not file_utils.check_file(jgrapht_file, jgrapht_md5): do_wget(jgrapht_url, jgrapht_file) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % jgrapht_file, "-DartifactId=jgrapht", "-DgroupId=org.jgrapht", "-Dversion=0.8.3", "-Dpackaging=jar"], cwd=external_bin_dir) # install jfuzzylogic jfuzzy_file = os.path.join(external_bin_dir, jfuzzy_name) if not file_utils.check_file(jfuzzy_file, jfuzzy_md5): do_wget(jfuzzy_url, jfuzzy_file) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % jfuzzy_file, "-DartifactId=jfuzzy", "-DgroupId=pcingola", "-Dversion=3.0", "-Dpackaging=jar"], cwd=external_bin_dir) # geronimo not available as binary (but depends on eclipse source stuff...) #geronimo_file_name = "geronimo-3.0.1" #geronimo_src_archive_name = "geronimo-3.0.1-source-release.zip" #geronimo_url = "http://mirrors.ibiblio.org/maven2/org/apache/geronimo/geronimo/3.0.1/geronimo-3.0.1-source-release.zip" #geronimo_file_path = os.path.join(external_src_dir, geronimo_file_name) # install geotools #geotools_src_dir = os.path.join(external_src_dir, geotools_src_dir_name) #if not file_utils.check_dir(geotools_src_dir): # if not ch...le(os.path.join(external_src_dir, geotools_src_archive_name)) or file_utils.retrieve_md5sum(os.path.join(external_src_dir, geotools_src_archive_name)) != geotools_src_archive_md5: # do_wget() ... sp.check_call([wget, geotools_url], cwd=tmp_dir) # sp.check_call([unzip, os.path.join(tmp_dir, geotools_src_archive_name)], cwd=external_src_dir) #if not skip_build: # mvn_settings_file_path = os.path.join(script_dir, "settings.xml") # sp.check_call([mvn, "-e", "--global-settings", mvn_settings_file_path, "--settings", mvn_settings_file_path, "install", "-Dall", "-DskipTests=true"], cwd=geotools_src_dir) # install commons-collections 4 #commons_src_dir = os.path.join(external_src_dir, commons_src_dir_name) #if not file_utils.check_dir(commons_src_dir): # commons_src_archive_file = os.path.join(external_src_dir, commons_src_archive_name) # if not file_utils.check_file(commons_src_archive_file, commons_src_archive_md5): # do_wget(commons_src_archive_url, commons_src_archive_file) # sp.check_call([tar, "xf", commons_src_archive_file], cwd=external_src_dir) #if not skip_build: # mvn_install(commons_src_dir, skip_tests) # install postgis from source (installation with package manager occurs in # bootstrap_privileged.py if postgis_install == "source": # installation of postgis-jdbc from bin directory should not occur in sources installation as this refers to the version shipped with the tarball -> will install mvn project in subdirectory of tarball root postgis_src_dir = os.path.join(external_src_dir, postgis_src_dir_name) if check_os.check_ubuntu() or check_os.check_debian(): if not file_utils.check_dir(postgis_src_dir): postgis_src_archive_file = os.path.join(external_src_dir, postgis_src_archive_name) if not file_utils.check_file(postgis_src_archive_file, postgis_src_archive_md5): do_wget(postgis_url, postgis_src_archive_file) sp.check_call([tar, "xf", postgis_src_archive_file], cwd=external_src_dir) if not skip_build: pm_utils.install_apt_get_build_dep(["postgis"], package_manager=apt_get, skip_apt_update=skip_apt_update) # might not be sufficient because Ubuntu 13.10's version of postgis is 1.5.x (we're using 2.x) pm_utils.install_packages(["libgdal-dev"], package_manager=apt_get, skip_apt_update=skip_apt_update) # not covered by 1.5.x requirements (see above) sp.check_call([bash, "autogen.sh"], cwd=postgis_src_dir) sp.check_call([bash, "configure"], cwd=postgis_src_dir) sp.check_call([make, "-j8"], cwd=postgis_src_dir) sp.check_call([make, "install"], cwd=postgis_src_dir) # install postgis-jdbc (project is shipped inside postgis project (as long as a fixed version of postgis is used here, the version of postgis-jdbc will be fixed, too (postgis 2.1.1 -> postgis-jdbc 2.1.0SVN) postgis_mvn_project_path = os.path.join(postgis_src_dir, "java/jdbc") sp.check_call([ant], cwd=postgis_mvn_project_path) # generates maven project mvn_install(postgis_mvn_project_path, skip_tests) elif check_os.check_opensuse(): raise RuntimeError("PostGIS source installation not supported") else: # better to let the script fail here than to get some less comprehensive error message later raise RuntimeError("Operating system not supported!") elif postgis_install == "pm": # install postgis from scripts/bin (as it is not available from somewhere online) postgis_jdbc_file = os.path.join(bin_dir, postgis_jdbc_name) if not os.path.exists(postgis_jdbc_file): raise RuntimeError("postgis JDBC jar %s doesn't exist, can't continue, consider fetching it manually" % (postgis_jdbc_file,)) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % postgis_jdbc_file, "-DartifactId=postgis-jdbc", "-DgroupId=org.postgis", "-Dversion=2.1.0SVN", "-Dpackaging=jar"], cwd=bin_dir) else: raise RuntimeError("postgis_install %s isn't supported" % (postgis_install,)) # always install openejb from bin directory (might be made flexible with source installation like postgis (see above) later) openejb_jar_file_path = os.path.join(bin_dir, openejb_jar_file_name) if not os.path.exists(openejb_jar_file_path): raise RuntimeError("OpenEJB jar %s doesn't exist, can't continue, consider fetching it manually" % (openejb_jar_file_path,)) sp.check_call([mvn, "install:install-file", \ "-Dfile=%s" % (openejb_jar_file_path,), "-DartifactId=openejb-core", "-DgroupId=org.apache.openejb", "-Dversion=4.7.0-SNAPSHOT", "-Dpackaging=jar"], cwd=bin_dir) openejb_api_jar_file_path = os.path.join(bin_dir, openejb_api_jar_file_name) if not os.path.exists(openejb_api_jar_file_path): raise RuntimeError("OpenEJB API jar %s doesn't exist, can't continue, consider fetching it manually" % (openejb_api_jar_file_path,)) sp.check_call([mvn, "install:install-file", "-Dfile=%s" % (openejb_api_jar_file_path,), "-DartifactId=openejb-api", "-DgroupId=org.apache.openejb", "-Dversion=4.7.0-SNAPSHOT", "-Dpackaging=jar"], cwd=bin_dir) #openejb_snapshot_ahtutils_workaround(external_src_dir) # setup postgis datadir and configuration if not file_utils.check_dir(postgres_datadir_path) or force_overwrite_postgres_datadir: # os.makedirs(postgres_datadir_path) # causes error if directory exists and is not necessary postgis_utils.bootstrap_datadir(postgres_datadir_path, postgres_user, password=postgres_pw, initdb=initdb) postgis_utils.bootstrap_database(postgres_datadir_path, postgres_port, postgres_host, postgres_user, pgalise_db_name, password=postgres_pw, initdb=initdb, postgres=postgres, createdb=createdb, psql=psql) postgis_utils.bootstrap_database(postgres_datadir_path, postgres_port, postgres_host, postgres_user, pgalise_db_test_name, password=postgres_pw, initdb=initdb, postgres=postgres, createdb=createdb, psql=psql) else: logger.info("Postgres datadir %s has not been overwritten. Check output of script invoked with -h/--help on how to do that." % (postgres_datadir_path, ))