def installApplication(self, child): install_dir = child.path(DF.install | DF.root | DF.absolute) py_lib = child.path(DF.install | DF.langlib | DF.relative, lang="python", relative_to=install_dir) script_name = child["APP_OPTIONS"]["PY_MAIN"] if child["APP_OPTIONS"][ "PY_MAIN"] != "main.py" else child.name() + "-main.py" py_main = child.path(DF.build | DF.langlib, lang="python", subdirs=["apps"], file_name=script_name) py_main_use = child.path(DF.install | DF.langlib, lang="python", subdirs=["apps"], file_name=script_name) py_main_script = child.path(DF.install | DF.langlib | DF.relative, lang="python", subdirs=["apps"], relative_to=install_dir, file_name=script_name) PySH.copy(py_main, py_main_use, dst_type="file", force=True) child_code = "#! /bin/bash\n" child_code += "APP_ROOT=${APP_ROOT:-%s}\n" % install_dir child_code += "PYTHONPATH=${PYTHONPATH}:${APP_ROOT}/%s python ${APP_ROOT}/%s $@" % ( py_lib, py_main_script) file_name = child.path(DF.install | DF.bin, file_name=child.name()) file = PyFile.file(file_name, "w") file.write(child_code) file.close() PySH.cmd("chmod a+x %s" % file_name)
def installApp(self, child, app): app_root = app.path(DF.source | DF.root) dep_roots = PyFind.getDirDirs(os.path.join(app_root, "deps")) for dir in ["ebin", "priv"]: install_erl_dir = app.path(DF.install | DF.langlib | DF.app | DF.version, lang="erlang", subdirs=[dir]) PySH.copy(app.path(DF.source | DF.root, subdirs=[dir]), install_erl_dir, force=True) for (dep_name, dep_dir) in [(os.path.basename(d_root), d_root) for d_root in dep_roots]: for dir in ["ebin", "priv"]: install_erl_dir = app.path(DF.install | DF.langlib | DF.app | DF.version, lang="erlang", subdirs=[dir], dep_name=dep_name, dep_dir=dep_dir) PySH.copy(os.path.join(dep_dir, dir), install_erl_dir, force=True)
def installApp(self, app): for app in self.apps: app_install_dir = os.path.join(app.config["INSTALL_PREFIX"], "var/www/js/" + app.name) if not os.path.isdir(app_install_dir): os.makedirs(app_install_dir) PySH.copy(app.buildDir(), app_install_dir, force=True)
def documentApp(self, child, app): for app in self.apps: PySH.cmd("cd " + app.path(DF.source | DF.root) + " && rebar doc") doc_dir = app.path(DF.install | DF.doc | DF.app | DF.version, dirs=["erlang"]) PySH.copy(app.path(DF.source | DF.root, subdir="doc"), doc_dir, force=True)
def installApp(self, child, app): ## copy binaries install_erl_dir = app.path(DF.install | DF.langlib | DF.app | DF.version, lang="erlang", subdirs=["ebin"]) PySH.copy(app.path(DF.build | DF.langlib | DF.app, lang="erlang", subdirs=["ebin"]), install_erl_dir, force=True)
def buildLibrary(self, child): build_dir = child.path(DF.build | DF.langlib | DF.app, lang="python") source_dir = child.path(DF.source | DF.src) PyLog.debug("BUILD Copy " + source_dir + " -> " + build_dir, log_level=6) PySH.copy(source_dir, build_dir, pattern="*.py", force=True, root_only=False)
def installLibrary(self, child): build_dir = child.path(DF.build | DF.langlib | DF.app, lang="python") install_dir = child.path(DF.install | DF.langlib | DF.app, lang="python") PyLog.debug("INSTALL Copy " + build_dir + " -> " + install_dir, log_level=-6) PySH.copy(build_dir, install_dir, pattern="*.py", force=True, root_only=False)
def installApp(self, child, app): name = app.name() file_name = name + ".app" src_file = app.path(DF.build | DF.langlib | DF.app, lang="erlang", subdirs=["ebin"], file_name=file_name) dst_file = app.path(DF.install | DF.langlib | DF.app | DF.version, lang="erlang", subdirs=["ebin"], file_name=file_name) PySH.copy(src_file, dst_file, dst_type="file", force=True)
def genApp(self, app): name = app.name() file_src = name + ".app.fish" file_name = name + ".app" app_src = app.path(DF.source | DF.src, file_name=file_src) app_file = app.path(DF.build | DF.langlib | DF.app, lang="erlang", subdirs=["ebin"], file_name=file_name) if os.path.isfile(app_src): doc = ErlApp(app_src, app) doc.write(app_file) else: app_src = app.path(DF.source | DF.src, file_name=file_name) if os.path.isfile(app_src): PySH.copy(app_src, app_file, dst_type="file", force=True)
def package(self, app): ## Make certain topdir is set file = PyFile.file(os.path.expanduser("~/.rpmmacros"), permissions="w") file.write(""" %%_topdir %s %%_tmppath %%{_topdir}/tmp """ % app.path(DF.build|DF.root|DF.absolute) ) file.close() ## Make the RPM build dirs dirs = ["BUILD", "BUILD_ROOT", "RPMS", "SOURCES", "SRPMS", "SPECS", "tmp"] for d in dirs: PySH.mkdirs(app.path(DF.build|DF.root, subdirs=[d])) ## Create install directory structure version = PyRCS.getMajorVersion() build = PyRCS.getMinorVersion() package_name = "%s-%s" % (app.name(), version) package_dir = app.path(DF.build|DF.root, subdirs=["tmp", package_name]) package_root = app.path(DF.build|DF.root, subdirs=["tmp", package_name, "usr", "local", app.name()]) package_bin = app.path(DF.build|DF.root, subdirs=["tmp", package_name, "usr", "local", package_name]) ## Copy PySH.mkdirs(package_root) PySH.copy(app.path(DF.install|DF.root), package_root) ## Rebuild bins package_root_bin = os.path.join(package_root, "bin") PySH.mkdirs(package_bin) for f in PyFind.getDirFiles(package_root_bin): name = os.path.basename(f) file_name = os.path.join(package_bin, name) f = PyFile.file(file_name, "w") code = "#! /bin/bash\n" code += "APP_ROOT=${APP_ROOT:-%s} %s $@\n" % ("/usr/local/%s" % app.name(), "/usr/local/%s/bin/%s" % (app.name(), name)) f.write(code) f.close() PySH.cmd("chmod a+x %s" % file_name) ## Generate Source ball PySH.cmd("cd %s && tar -czvf %s.tar.gz %s" % (app.path(DF.build|DF.root, subdirs=["tmp"]), app.path(DF.build|DF.root|DF.absolute, subdirs=["SOURCES"], file_name=package_name), package_name), stdout=True, stderr=True) ## Generate spec file name = app.name() file_name = app.path(DF.build|DF.root, subdirs=["SPECS"], file_name="%s.spec" % name) f = PyFile.file(file_name, "w") spec = """ %%define __spec_install_post %%{nil} %%define debug_package %%{nil} %%define __os_install_post %%{_dbpath}/brp-compress Summary: Autogenerated spec for %s Name: %s Version: %s Release: %s License: GPL+ Group: Development/Tools SOURCE0 : %%{name}-%%{version}.tar.gz URL: TODO BuildRoot: %%{_tmppath}/%%{name}-%%{version}-%%{release}-root %%description %%{summary} %%prep %%setup -q %%build # Empty section. %%install rm -rf %%{buildroot} mkdir -p %%{buildroot} # in builddir cp -a * %%{buildroot} %%clean rm -rf %%{buildroot} %%files /usr/bin/* /usr/local/%s/* %%changelog """ % (name, name, version, build, name) f.write(spec) f.close() PySH.cmd("rpmbuild -ba %s" % file_name, stdout=True, stderr=True)
def installMisc(self, app): var_dir = app.path(DF.source | DF.root, subdirs=["var"]) install_var_dir = app.path(DF.install | DF.var | DF.absolute) if os.path.isdir(var_dir): PyLog.debug("Copying content...") PySH.copy(var_dir, install_var_dir, force=True)