UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Don't have permission to exec library in cache directory

    Scheduled Pinned Locked Moved Solved App Development
    18 Posts 4 Posters 1.2k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • pavelprostoP Offline
        pavelprosto @dobey
        last edited by

        @dobey There were no other messages

        Your donations help me to continue programming free and openSource application development https://liberapay.com/pavelprosto/

        1 Reply Last reply Reply Quote 0
        • KenedaK Offline
          Keneda @dobey
          last edited by

          @dobey
          I'm not a dev, but that made me wonder : why a "native" uTouch click app would trigger libertine?

          2015-2023 : Meizu MX4 ā˜ ļøāš°ļøāœļø
          2023-2024 : Nexus 5 ā˜ ļøāš°ļøāœļø
          2024-***** : FPOS Fairphone 5 waiting UT for freedom šŸ˜‰
          šŸ‡²šŸ‡«šŸ‡¬šŸ‡§

          pavelprostoP 1 Reply Last reply Reply Quote 0
          • dobeyD Offline
            dobey @pavelprosto
            last edited by

            @pavelprosto said in Don't have permission to exec library in cache directory:

            Because this is a QML + Python project.
            I included transmission in the project, everything exactly turns out this error.

            Sure, but you can build separate click packages for each architecture, which pulls the approriate transmission binaries in, and will reduce the size of your package versus shipping the same thing on all architectures.

            Also, please can you state the exact command line which your app is trying to run with subprocess.Popen here? I see in your code that you're raising an exception which includes that, but I have not seen that posted here. Also, it looks like you're defining CACHEPATH based on the path of __file__ which should I guess be pointing at the installed path of your package.

            pavelprostoP 1 Reply Last reply Reply Quote 0
            • pavelprostoP Offline
              pavelprosto @dobey
              last edited by pavelprosto

              @dobey command:

              transmission-cli --config-dir "/home/phablet/.cache/transmission.pavelprosto/" -p 51414 -w "/home/phablet/.cache/transmission.pavelprosto/Download/" -d 1024 -u 256 -ep "/home/phablet/.cache/transmission.pavelprosto/manjaro-kde-20.2.1-210103-linux59.iso.torrent"
              

              Environment:
              "HOME" : "/home/phablet/.cache/transmission.pavelprosto/"
              "PWD" : "/home/phablet/.cache/transmission.pavelprosto/"
              "TMPDIR" : "/home/phablet/.cache/transmission.pavelprosto/tmp"
              "PATH" : "/home/phablet/.cache/transmission.pavelprosto//transmission/bin"
              "LD_LIBRARY_PATH" : "/home/phablet/.cache/transmission.pavelprosto/transmission/lib/"
              "PKG_CONFIG_PATH" : "/home/phablet/.cache/transmission.pavelprosto/transmission/lib/pkgconfig"

              Your donations help me to continue programming free and openSource application development https://liberapay.com/pavelprosto/

              dobeyD 1 Reply Last reply Reply Quote 0
              • pavelprostoP Offline
                pavelprosto @Keneda
                last edited by

                @keneda I also find it strange. libertine is not used in my program, where it came from, I don't understand

                Your donations help me to continue programming free and openSource application development https://liberapay.com/pavelprosto/

                1 Reply Last reply Reply Quote 0
                • dobeyD Offline
                  dobey @pavelprosto
                  last edited by

                  @pavelprosto OK. So, yes, apps cannot execute things in the cache or config directories for the app, but can execute things from the app's data directory ~/.local/share/${APP_PKG_NAME}/ instead.

                  Also, cache is things expected to be OK for the user to remove and have the app still working. I suspect your app shouldn't be unpacking transmission into the cache directory on every start.

                  Rather, my best suggestion is still to include the transmission binaries in the click package itself, and have them installed alongside your app's python and QML. lib/${ARCH_TRIPLET}/bin inside your click package, is already in the ${PATH} for your app, and lib/${ARCH_TRIPLET} already part of ${LD_LIBRARY_PATH}, so you don't need to mess with the environment like that, either.

                  pavelprostoP 1 Reply Last reply Reply Quote 1
                  • pavelprostoP Offline
                    pavelprosto @dobey
                    last edited by

                    @dobey THANK YOU VERY MUCH!
                    It is fantastic! Everything works with safe permission šŸ˜‰
                    I finish the final touches and publish in OpenStore 😘

                    Your donations help me to continue programming free and openSource application development https://liberapay.com/pavelprosto/

                    pavelprostoP 1 Reply Last reply Reply Quote 3
                    • pavelprostoP Offline
                      pavelprosto @pavelprosto
                      last edited by pavelprosto

                      If someone needs to create a front-end wrapper for a binary console program, here's how it can be implemented

                      create global environment
                      glob.py

                      import os
                      
                      APP_PKG_NAME = os.path.abspath(__file__)
                      APP_PKG_NAME = APP_PKG_NAME[APP_PKG_NAME.find(".com/")+5:]
                      APP_PKG_NAME = APP_PKG_NAME[:APP_PKG_NAME.find("/")]
                      SCRIPTPATH = os.path.abspath(__file__)
                      SCRIPTPATH = SCRIPTPATH[:SCRIPTPATH.rfind('/')]
                      
                      CACHEPATH = "/home/phablet/.cache/"+APP_PKG_NAME
                      DATAPATH = "/home/phablet/.local/share/"+APP_PKG_NAME
                      CONFIGPATH = "/home/phablet/.config/"+APP_PKG_NAME
                      
                      DOWNLOADPATH = CACHEPATH+"/Download"
                      TMPPATH = CACHEPATH+"/tmp"
                      RESUMEPATH   = CACHEPATH+"/resume/"
                      TORRENTSPATH = CACHEPATH+"/torrents/"
                      
                      MY_ENV = {"HOME" : CACHEPATH }
                      MY_ENV["PWD"] = CACHEPATH
                      MY_ENV["TMPDIR"] = CACHEPATH+"/tmp"
                      MY_ENV["PATH"] = DATAPATH+"/transmission/bin"
                      MY_ENV["LD_LIBRARY_PATH"] = DATAPATH+"/transmission/lib/"
                      MY_ENV["PKG_CONFIG_PATH"] = DATAPATH+"/transmission/lib/pkgconfig"
                      
                      if not os.path.exists(DATAPATH):
                          try:
                              os.makedirs(DATAPATH)
                          except Exception as e:
                              print("Can't create DATAPATH dir:\n"+DATAPATH)
                              print(e)
                      
                      if not os.path.exists(CONFIGPATH):
                          try:
                              os.makedirs(CONFIGPATH)
                          except Exception as e:
                              print("Can't create CONFIGPATH dir:\n"+CONFIGPATH)
                              print(e)
                      
                      if not os.path.exists(CACHEPATH):
                          try:
                              os.makedirs(CACHEPATH)
                          except Exception as e:
                              print("Can't create CACHEPATH dir:\n"+CACHEPATH)
                              print(e)
                      
                      if not os.path.exists(DOWNLOADPATH):
                          try:
                              os.makedirs(DOWNLOADPATH)
                          except Exception as e:
                              print("Can't create DOWNLOAD dir:\n"+DOWNLOADPATH)
                              print(e)
                      
                      if not os.path.exists(TMPPATH):
                          try:
                              os.makedirs(TMPPATH)
                          except Exception as e:
                              print("Can't create TMP dir:\n"+TMPPATH)
                              print(e)
                      

                      Correct location of all files is very important!!!
                      DATAPATH: contains all executables and libraries
                      CONFIGPATH: contains the settings for your application. But not settings for a binary console program, its settings must be stored in CACHEPATH
                      CACHEPATH: contains all files resulting from program execution.
                      Now you will be able to launch and communicate with the console program through your environment:

                      ...
                      import subprocess
                      import re
                      import shlex
                      import glob
                      ...
                      CMD="transmission-show"
                      def strip_color(s):
                         return re.sub('\x1b\\[(K|.*?m)', '', s)
                      
                      def _process(command_string, path=""):
                             cmd_args = shlex.split(command_string)
                             try:
                                 PROCESS = subprocess.Popen(cmd_args,
                                                     stdout=subprocess.PIPE,
                                                     stderr=subprocess.STDOUT,
                                                     universal_newlines=True,
                                                     shell=False,
                                                     executable=None,
                                                     env=glob.MY_ENV,
                                                     cwd=path)
                             except Exception as e:
                                 yield strip_color(str(e))
                             else:
                                 for stdout_line in iter(PROCESS.stdout.readline, ''):
                                     yield strip_color(stdout_line)
                                 PROCESS.stdout.close()
                                 return_code = PROCESS.wait()
                                 if return_code:
                                     raise subprocess.CalledProcessError(return_code, command_string)
                      ...
                      for stdout_line in _process(CMD+" \""+FILENAME+"\"", glob.CACHEPATH):
                         print(stdout_line)
                      ...
                      

                      Your donations help me to continue programming free and openSource application development https://liberapay.com/pavelprosto/

                      CiberSheepC 1 Reply Last reply Reply Quote 2
                      • CiberSheepC Offline
                        CiberSheep @pavelprosto
                        last edited by

                        @pavelprosto said in Don't have permission to exec library in cache directory:

                        If someone needs to create a front-end wrapper for a binary console program, here's how it can be implemented

                        Have you thought about joining forces with @aarontheissueguy and creating a git*b project for the template?

                        Another planet, another time, another universe!

                        pavelprostoP 1 Reply Last reply Reply Quote 1
                        • pavelprostoP Offline
                          pavelprosto @CiberSheep
                          last edited by

                          @cibersheep Yes,I want to write a guide. But first I need to make sure it works for all console programs.
                          I tried, add the previous guides in github
                          https://docs.ubports.com/en/latest/appdev/guides/index.html

                          But something didn't work out for me. I try will do this in spare time šŸ™‚

                          Your donations help me to continue programming free and openSource application development https://liberapay.com/pavelprosto/

                          1 Reply Last reply Reply Quote 1
                          • First post
                            Last post