From f22f74e3da09f91140c1428d4bef6c79592102ef Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Mon, 21 Sep 2020 21:59:05 +0200 Subject: [PATCH] Instead of upload requiring root to upload to /dev/sdb we chown in in the source script --- scripts/upload.py | 13 ++++--------- source.sh | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/upload.py b/scripts/upload.py index 14117bd..fb1f1f4 100755 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -84,16 +84,11 @@ def upload_bload(filename): print("Failed to open serial port") def upload_sd(filename): - if os.geteuid() == 0: - print("Running as root") - file_in = open(filename, "rb") - file_out = open("/dev/sdb", "wb") + # @todo This does require /dev/sdb to be accessible without root + file_in = open(filename, "rb") + file_out = open("/dev/sdb", "wb") - file_out.write(file_in.read()) - else: - print("Reqeusting root permission") - subprocess.call(["sudo", "python3", *sys.argv]) - sys.exit() + file_out.write(file_in.read()) # @todo For now we just wrap the existing mojo.py tool diff --git a/source.sh b/source.sh index 0af5962..1c21fd1 100644 --- a/source.sh +++ b/source.sh @@ -1,3 +1,4 @@ # This order makes it so we can use deactive to also deactive the other additions to the path +sudo chown tim:tim /dev/sdb source $(dirname $(readlink -f $0))/env/bin/activate PATH=$(dirname $(readlink -f $0))/arm-none-eabi/bin:$(dirname $(readlink -f $0))/microblazeel-xilinx-elf/bin:$(dirname $(readlink -f $0))/bin:/opt/Xilinx/14.7/ISE_DS/EDK/bin/lin64:$PATH