2022-07-18 23:59:14 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
2020-09-11 20:35:55 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
from datetime import datetime
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from shiv.bootstrap import Environment
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2020-09-11 20:35:55 +00:00
|
|
|
# from distutils.ccompiler import new_compiler
|
|
|
|
from shiv.builder import create_archive
|
|
|
|
from shiv.cli import __version__ as VERSION
|
|
|
|
|
2023-04-07 17:12:56 +00:00
|
|
|
|
2023-09-14 21:07:15 +00:00
|
|
|
def build_nxc():
|
|
|
|
print("building nxc")
|
2021-03-08 20:03:04 +00:00
|
|
|
try:
|
|
|
|
shutil.rmtree("bin")
|
2023-01-04 16:48:52 +00:00
|
|
|
shutil.rmtree("build")
|
|
|
|
except Exception as e:
|
2021-03-08 20:03:04 +00:00
|
|
|
pass
|
|
|
|
|
2020-09-11 20:35:55 +00:00
|
|
|
try:
|
2021-03-08 20:14:35 +00:00
|
|
|
print("remove useless files")
|
2020-09-11 20:35:55 +00:00
|
|
|
os.mkdir("build")
|
2020-09-11 20:56:27 +00:00
|
|
|
os.mkdir("bin")
|
2023-09-14 21:07:15 +00:00
|
|
|
shutil.copytree("nxc", "build/nxc")
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2021-03-08 20:03:04 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
return
|
2020-09-11 20:35:55 +00:00
|
|
|
|
2020-09-20 14:51:23 +00:00
|
|
|
subprocess.run(
|
2023-05-02 15:17:59 +00:00
|
|
|
[
|
|
|
|
sys.executable,
|
|
|
|
"-m",
|
|
|
|
"pip",
|
|
|
|
"install",
|
2023-09-03 17:08:36 +00:00
|
|
|
"-e",
|
|
|
|
".",
|
2023-05-02 15:17:59 +00:00
|
|
|
"-t",
|
|
|
|
"build",
|
|
|
|
],
|
|
|
|
check=True,
|
2020-09-11 20:35:55 +00:00
|
|
|
)
|
|
|
|
|
2023-05-02 15:17:59 +00:00
|
|
|
# [shutil.rmtree(p) for p in Path("build").glob("**/__pycache__")]
|
2020-09-11 20:35:55 +00:00
|
|
|
[shutil.rmtree(p) for p in Path("build").glob("**/*.dist-info")]
|
|
|
|
|
|
|
|
env = Environment(
|
2023-05-08 18:39:36 +00:00
|
|
|
built_at=datetime.utcfromtimestamp(int(time.time())).strftime("%Y-%m-%d %H:%M:%S"),
|
2023-09-14 21:07:15 +00:00
|
|
|
entry_point="nxc.netexec:main",
|
2020-09-11 20:35:55 +00:00
|
|
|
script=None,
|
|
|
|
compile_pyc=False,
|
|
|
|
extend_pythonpath=True,
|
|
|
|
shiv_version=VERSION,
|
|
|
|
)
|
|
|
|
create_archive(
|
|
|
|
[Path("build").absolute()],
|
2023-09-14 21:07:15 +00:00
|
|
|
Path("bin/nxc"),
|
2023-01-04 16:48:52 +00:00
|
|
|
"/usr/bin/env -S python -sE",
|
2020-09-11 20:35:55 +00:00
|
|
|
"_bootstrap:bootstrap",
|
|
|
|
env,
|
|
|
|
True,
|
|
|
|
)
|
|
|
|
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2023-09-14 21:07:15 +00:00
|
|
|
def build_nxcdb():
|
2023-09-14 21:41:51 +00:00
|
|
|
print("building nxcdb")
|
2020-09-11 20:35:55 +00:00
|
|
|
env = Environment(
|
2023-05-08 18:39:36 +00:00
|
|
|
built_at=datetime.utcfromtimestamp(int(time.time())).strftime("%Y-%m-%d %H:%M:%S"),
|
2023-09-14 21:07:15 +00:00
|
|
|
entry_point="nxc.nxcdb:main",
|
2020-09-11 20:35:55 +00:00
|
|
|
script=None,
|
|
|
|
compile_pyc=False,
|
|
|
|
extend_pythonpath=True,
|
|
|
|
shiv_version=VERSION,
|
|
|
|
)
|
|
|
|
create_archive(
|
|
|
|
[Path("build").absolute()],
|
2023-09-14 21:07:15 +00:00
|
|
|
Path("bin/nxcdb"),
|
2023-01-04 16:48:52 +00:00
|
|
|
"/usr/bin/env -S python -sE",
|
2020-09-11 20:35:55 +00:00
|
|
|
"_bootstrap:bootstrap",
|
|
|
|
env,
|
|
|
|
True,
|
|
|
|
)
|
|
|
|
|
2023-05-02 15:17:59 +00:00
|
|
|
|
2020-09-11 20:35:55 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
2023-09-14 21:07:15 +00:00
|
|
|
build_nxc()
|
|
|
|
build_nxcdb()
|
2020-09-11 20:35:55 +00:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
finally:
|
2020-09-11 20:56:27 +00:00
|
|
|
shutil.rmtree("build")
|