[mod] tools:build:auf python umgestellt
This commit is contained in:
parent
40361269e5
commit
7ae9bc62e1
104
tools/build
104
tools/build
|
|
@ -1,28 +1,90 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env python3
|
||||
|
||||
## consts
|
||||
|
||||
dir_lib=lib
|
||||
dir_source=source
|
||||
dir_build=build
|
||||
name=index.php
|
||||
import os as _os
|
||||
import shutil as _shutil
|
||||
import argparse as _argparse
|
||||
|
||||
|
||||
## args
|
||||
def main():
|
||||
## consts
|
||||
conf = {
|
||||
"dir_lib": "lib",
|
||||
"dir_source": "source",
|
||||
"dir_logic": "logic",
|
||||
}
|
||||
|
||||
if [ $# -ge 1 ] ; then profile=$1 && shift ; else profile="" ; fi
|
||||
## args
|
||||
argument_parser = _argparse.ArgumentParser(
|
||||
)
|
||||
argument_parser.add_argument(
|
||||
"-o",
|
||||
"--output-directory",
|
||||
default = "/tmp/davina",
|
||||
type = str,
|
||||
metavar = "<output-directory>",
|
||||
)
|
||||
argument_parser.add_argument(
|
||||
"-c",
|
||||
"--conf-path",
|
||||
default = None,
|
||||
type = str,
|
||||
metavar = "<conf-path>",
|
||||
)
|
||||
args = argument_parser.parse_args()
|
||||
|
||||
## exec
|
||||
### exec:directories
|
||||
if True:
|
||||
_os.makedirs(
|
||||
args.output_directory,
|
||||
exist_ok = True
|
||||
)
|
||||
_os.makedirs(
|
||||
_os.path.join(args.output_directory, "data"),
|
||||
exist_ok = True
|
||||
)
|
||||
_os.makedirs(
|
||||
_os.path.join(args.output_directory, "public"),
|
||||
exist_ok = True
|
||||
)
|
||||
### exec:libs
|
||||
if True:
|
||||
_shutil.copytree(
|
||||
_os.path.join(conf["dir_lib"], "composer"),
|
||||
_os.path.join(args.output_directory, "composer"),
|
||||
dirs_exist_ok = True
|
||||
)
|
||||
### exec:sources
|
||||
if True:
|
||||
_shutil.copytree(
|
||||
conf["dir_source"],
|
||||
_os.path.join(args.output_directory, conf["dir_logic"]),
|
||||
dirs_exist_ok = True
|
||||
)
|
||||
### exec:index
|
||||
if True:
|
||||
path = _os.path.join(args.output_directory, "index.php")
|
||||
if (not _os.path.exists(path)):
|
||||
pass
|
||||
else:
|
||||
_os.remove(
|
||||
path
|
||||
)
|
||||
_os.symlink(
|
||||
_os.path.join(conf["dir_logic"], "main.php"),
|
||||
path
|
||||
)
|
||||
### exec:conf
|
||||
if True:
|
||||
if (args.conf_path is None):
|
||||
pass
|
||||
else:
|
||||
_shutil.copy(
|
||||
args.conf_path,
|
||||
_os.path.join(args.output_directory, "conf.json")
|
||||
)
|
||||
print(args.output_directory)
|
||||
|
||||
|
||||
## exec
|
||||
main()
|
||||
|
||||
mkdir -p ${dir_build}
|
||||
cp -r ${dir_lib}/composer/* ${dir_build}/
|
||||
|
||||
mkdir -p ${dir_build}/data
|
||||
mkdir -p ${dir_build}/public
|
||||
|
||||
rm -f ${dir_build}/${name}
|
||||
cp -r -u -v ${dir_source}/* ${dir_build}/
|
||||
ln -s main.php ${dir_build}/index.php
|
||||
|
||||
test -z ${profile} || cp conf/${profile}.json ${dir_build}/conf.json
|
||||
|
|
|
|||
Loading…
Reference in a new issue