Browse Source

feat: disable static builds for non-root user

master
Dnomd343 2 years ago
parent
commit
08afb75e1f
  1. 10
      src/release/release.py
  2. 4
      src/release/utils/common.py
  3. 9
      src/release/utils/release.py

10
src/release/release.py

@ -11,8 +11,8 @@ from utils import gitbookRelease
metadata, content = loadBook('rc-5')
txtRelease(metadata, content)
jsonRelease(metadata, content)
htmlRelease(metadata, content)
# staticRelease(metadata, content)
gitbookRelease(metadata, content)
# txtRelease(metadata, content)
# jsonRelease(metadata, content)
# htmlRelease(metadata, content)
staticRelease(metadata, content)
# gitbookRelease(metadata, content)

4
src/release/utils/common.py

@ -39,6 +39,10 @@ resourceInfo = { # resource download links
}
def isRoot() -> bool: # whether the current user is root
return os.geteuid() == 0
def createFolder(folderName: str) -> None: # create folder
if not os.path.exists(folderName):
os.mkdir(folderName)

9
src/release/utils/release.py

@ -7,6 +7,7 @@ import shutil
import tempfile
import subprocess
from .common import isRoot
from .common import rootPath
from .common import saveFile
from .common import projectUrl
@ -107,13 +108,11 @@ def staticBuild(workDir: str) -> None:
def staticRelease(metadata: dict, content: dict) -> None:
# TODO: confirm running under root
if not isRoot():
print('\033[0;33mDue to the permission problems, it is recommended to run under root user.\033[0m')
return
tempDir = tempfile.TemporaryDirectory() # access temporary directory
content = {x: content[x] for x in list(content)[:20]} # TODO: just for test
staticDepends(tempDir.name, metadata, content)
staticBuild(tempDir.name)
tempDir.cleanup()

Loading…
Cancel
Save