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') metadata, content = loadBook('rc-5')
txtRelease(metadata, content) # txtRelease(metadata, content)
jsonRelease(metadata, content) # jsonRelease(metadata, content)
htmlRelease(metadata, content) # htmlRelease(metadata, content)
# staticRelease(metadata, content) staticRelease(metadata, content)
gitbookRelease(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 def createFolder(folderName: str) -> None: # create folder
if not os.path.exists(folderName): if not os.path.exists(folderName):
os.mkdir(folderName) os.mkdir(folderName)

9
src/release/utils/release.py

@ -7,6 +7,7 @@ import shutil
import tempfile import tempfile
import subprocess import subprocess
from .common import isRoot
from .common import rootPath from .common import rootPath
from .common import saveFile from .common import saveFile
from .common import projectUrl from .common import projectUrl
@ -107,13 +108,11 @@ def staticBuild(workDir: str) -> None:
def staticRelease(metadata: dict, content: dict) -> None: def staticRelease(metadata: dict, content: dict) -> None:
if not isRoot():
# TODO: confirm running under root 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 tempDir = tempfile.TemporaryDirectory() # access temporary directory
content = {x: content[x] for x in list(content)[:20]} # TODO: just for test content = {x: content[x] for x in list(content)[:20]} # TODO: just for test
staticDepends(tempDir.name, metadata, content) staticDepends(tempDir.name, metadata, content)
staticBuild(tempDir.name) staticBuild(tempDir.name)
tempDir.cleanup() tempDir.cleanup()

Loading…
Cancel
Save