Linux Folder/Package Management - linux

I'm looking for a way to store all my applications files within a single folder. However, when someone clicks on the folder I want the application inside the folder to open up as opposed to open the folder itself. I want to keep all dependancies and files inside this folder at all times.
I'm doing this because I'm going to be deploying a couple applications on a common framework and want to ensure that they are together and independent of the distribution have all requirements.

Folders are directories, and directories are distinct from files. There's no way to redirect a directory to an executable file. However, you can make a hidden directory (begin name with ".") and use an executable file to provide access to that directory. The directory will then not appear in window manager folders, just the application. However, window managers will not misrepresent the executable file as a directory.

Related

Use Electron to select specific folder with program in it, and install files into directory

So I'm currently looking for a method to open a specific folder, containing let's say FiveM.exe
When the folder is selected it should download and install some files to it.
Is this even possible with Electron?
And how would you go around and do so, I know how to do a select folder and file dialog, but the rest I'm not too sure about.

Copying files/folders to Electron Dist folder

Long story short:
I need to copy some files/directories over from my src folder to my dist/resources folder. Is there any way I can 'automatically' copy these files/folders over during packaging? I am using Electron-packager.
Long story:
I have a couple of folders containing JSON files that need to be read and copied over to a certain user directory. These are all done when I mount a certain component.
I use readFileSync() and using path.resolve with __dirname - but this generates an error since my relative path is different when I am running the packaged app (inside dist folder). Error is it cannot find my JSON file in dist/resources/config/settings.json. Also tried to check content of my app.asar but can't seem to find it there.
So my working workaround is to copy the directory/files over from my src folder to my dist/resources folder.
But this is kind of hacky and prone to forgetting. Is there any way I can 'automatically' copy these files/folders over during packaging?
I've seen a lot of questions like this and I've never really understood them. Maybe your project structure is very different than mine (below)?
Everything that is within my "app" directory is included by electron-packager (or electron-builder – I use both) and so it's all available when the app i packaged. In my case I have some Excel templates which the user can opt to save to disk but I could just as well create a directory and copy them there at first launch (haven't tried this but assuming permissions are ok I don't doubt that it will work). Maybe that is less "clean" than having a separate resources folder?
That said, I have seen this: Electron - How to add external files?

Renaming executable's image name is giving it write permission

Dear community members,
We have three of same hardware Windows 7 Professional computers. No one of them is connected to a domain or directory service etc.
We run same executable image on all three computers. In one of them, I had to rename it. Because, with my application's original filename, it has no write access to it's working directory.
I setup full access permisions to USER group in working directory manually but this did not solve.
I suspect some kind of deny mechanism in Windows based on executable's name.
I searched the registry for executable's name but I did not find something relevant or meaningfull.
This situation occured after lot of crashes and updates of my program on that computer (I am a developer). One day, it suddenly started not to open files. I did not touch registry or did not change something other on OS.
My executable's name is karbon_tart.exe
When it start, it calls CreateFile (open mode if exist or create mode if not exist) to open karbon_tart.log file and karbon_tart.ini file.
With the files are exist and without the file exists, I tried two times and none of them, the program can open the files.
But if I just rename the name to karbon_tart_a.exe, program can open files no matter if they are exist or not.
Thank you for your interest
Regards
Ömür Ölmez.
I figured out at the end.
It is because of an old copy of my application in Virtual Store.

How to copy files into AppData\Local\Temp in inno script

I have created an .exe file for my application using inno script. Here I want to copy files from my setup folder to the AppData\Local\Temp directory. This is done using the below code.
Source: "WebcamApplet_1-0-0\*"; DestDir: "{localappdata}\Temp\WebcamApplet_1-0-0"
The problem I'm facing is that this code is only copying the files into the sysadmin ie C:\Users\Sysadmin\AppData\Local\Temp (Admin), I have to put it in C:\Users\Manesh\AppData\Local\Temp(User) for my application to work. How do I solve this problem.
Your application is badly designed if it expects files to be installed to the Temp folder. This folder is so named because the user or the system are free to delete all files contained therein at any time -- it is therefore suitable only for temporary use.
Additionally, there is no reasonable and reliable way for a per-machine installer (one running with PrivilegesRequired=admin, which is the default) to install files or settings to per-user folders, including the per-user temporary folder.
If you really really want to do this, you should set PrivilegesRequired=lowest to create a per-user installer -- but bear in mind that this will introduce other restrictions, such as limiting where your application can be installed to. Provided that you are running with lowest privileges, you can then use {%TEMP} to refer to the temporary path.

Storing Qt application data files on Linux - not enough permissions

I have Qt application which should work on multiple platforms. One of those platforms is Linux. I am completely new in Linux world.
My application need to create and manage set of data files. After reading some links about linux directory structure I decided to store data files in /var/myapp directory and in its subdirectories.
Here is the problem: if my application runs without superuser privileges then it has no rights to create /var/myapp directory. Even if i will create directory manually (with sudo) my application will not have rights to write files there.
Is it possible to temporary elevate application's permissions from Qt code to create /var/myapp directory and write files there?
Or possibly there is another place in Linux directory structure which is by default available for storing application's data files?
Only root can create directories in /var. If your application needs a subdirectory under /var, you need to create it during installation (which typically runs with root permissions), and chmod it appropriately: either create a group for users that may run your application, put /var/myapp in that group, and chmod it to 770; or just chmod the directory to 777 to allow everyone to access it. If you want to prevent writing by regular users, use 755 or 750 instead. (For data files, don't set the execute bit though: the appropriate permissions here are 666/660/644/640). Instead of octal triplets, you may prefer the more elaborate mnemoic syntax to chmod, e.g. chmod ug+x filename adds (+) the execute bit (x) to filename for the owning user (u) and group (g).
However, /var is not necessarily the best choice: /var is typically used for volatile data (temporary files etc.), as well as things that are expected to change frequently (mail, log files, etc.). Other data should go into either:
/usr/share/{appname} for system-wide data files and resources
/etc/{appname} for system-wide configuration files
~/.{appname} (old convention) or ~/.config/{appname} for per-user configuration files
/var/tmp/{appname} for temporary files
Also, you want to make the /usr prefix configurable; most distributions reserve /usr for package-managed files, except /usr/local, which mirrors /usr for out-of-distro installs (so in that case, your system-wide resources go into /usr/local/share instead of /usr/share).
You could distribute it without installation scripts, but you'd have to tell them to run it once as root... or have the app run itself as root using gksudo/kdesudo if its system wide data files do not exist.
The custom though is to make a package (.deb, .rpm, or even a .tar.gz that the user will extract himself) including all necessary files.
But linux (and OS X for that matter) are multi user systems. Are you sure your files belong in /var or /usr? If they're created at runtime as you say, don't they depend on user input? In which case you need to put them in some directory inside the user's home directory (getenv("HOME")).

Resources