SynologyOpenSource / pkgscripts-ng

Synology DSM6.0 package toolkit framework
162 stars 56 forks source link

Cannot build a package because command "pkgscripts-ng/PkgCreate.py -p avoton -c -v 7.0 ExamplePackage" throws an exception, root permission required #47

Closed usarskyy closed 6 months ago

usarskyy commented 6 months ago

I am trying to build a test package but the command from the example throws an error:

[2024-02-26 18:16:41,044] INFO:                 Start to run "Build Package"                
[2024-02-26 18:16:41,044] INFO: ------------------------------------------------------------
[2024-02-26 18:16:41,055] INFO: [avoton] env PackageName=ExamplePackage /pkgscripts-ng/SynoBuild --avoton -c --min-sdk 6.2 ExamplePackage
[2024-02-26 18:16:41,103] INFO: /pkgscripts-ng/include/check: line 93: /dev/null: Permission denied
[2024-02-26 18:16:41,104] INFO: ERROR: This script must be run as root
[2024-02-26 18:16:41,105] INFO: Traceback (most recent call last):
[2024-02-26 18:16:41,105] INFO:   File "/media/synology_toolkit/toolkit/pkgscripts-ng/include/python/exec_env.py", line 76, in execute
[2024-02-26 18:16:41,105] INFO:     output = commandrunner.run(cmd, display=display, **kwargs)
[2024-02-26 18:16:41,105] INFO:   File "/media/synology_toolkit/toolkit/pkgscripts-ng/include/python/commandrunner.py", line 39, in run
[2024-02-26 18:16:41,106] INFO:     raise RunShellFailed(p.returncode, cmd, output)
[2024-02-26 18:16:41,106] INFO: commandrunner.RunShellFailed

I am running terminal window as root (used sudo -i), command whoami returns "root". My development virtual machine runs on Ubuntu 22.04.3.

Unfortunately I am not a very experienced Linux user and never had an experience with Python scripts, also googling didn't bring much. Please advise how to properly setup my dev environment and build an example package.

pkgcreate.log

usarskyy commented 6 months ago

Okay, with the great help from SO I was able to finally find a solution.

Basically, the problem is that EnvDeploy script doesn't mount /dev/null and /dev/urandom when chroot jail for dev environment is created. This causes the above mention error to be thrown.

The solution is to manually mount those devices by yourself. Afterwards I was able to build a package as expected.

I will create a new bug to fix the EnvDeploy script.