I have a script which was origionally made for Linux, but adapted to run with Cygwin in windows, and if you already have the executables (sh, cp, mv, etc.) then you can run it without Cygwin. The only problem is that the script also uses a few hundred (yes hundreds) of other executables. Is there any way I can compile this script into a regular executable and pack these other supporting files in as resources?
The script is ~1600 lines long which is probably too long to confortably re-implement by hand in C++. I am looking to compile the script into something which windows can execute without having to make edits to the path to include a bunch of third party executables. A way to contain all this.
I doubt that the solution you have in mind is feasible.
Instead, I'd modify the script so that the first thing it does is figure out where all those hundreds of executables are. Then either set $PATH appropriately, or invoke each one by its full pathname.
Or you can have an installer that installs the executables in a specified or user-chosen location, then re-generates the script (from an input file) so it knows where the executables are. Ship with the-script.in, then have the installer perform textual substitutions to generate the-script from the-script.in.
I point out:
RPM and SHC
as a possible solution for your problem. Maybe this tools helps you to do the job.
Using SHC to Cygwin is possible to compile bash to exe
Ok. Realy old, but I was looking for it and decide to do my self and make it public.
http://goo.gl/M1NSY
Use ports of the required utils and use some application virtualization tool to package it all up. Cameyo is a free one. Forget Cygwin, that thing is huuuge :)
Related
I have at the core a very simple program. A shell script that can run on either mac or ubuntu. I have the requirement to distribute it on both platforms (in the mac case, must be a .app), however, I must build it exclusively on Ubuntu.
I was looking in to what is a mac '.app', and it seems like it's just a unique directory structure with executable, metadata, etc. For example, here are Apple's docs on the matter which explains it.
https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1
It seems like the metadata, etc. can all be put together, however in the Contents/MacOS folder, this is where the executable (the app's entrypoint) goes. This is the part I am confused on. For example, is there a way to make my shell script as an 'executable'? Or does this need to be a proper binary file (like you would get by compiling a C program?). If it is the latter, is there a way to do this on a Linux machine? (Noting that, this shell script, or C script I could make it in to, is so simple - essentially a single if/else statement which calls another utility.)
You need to have two things:
Put your executable into the Contents/MacOS directory, and make sure it is world-executable (just call chmod 755 on it). I think a shell script should work here, as long as it's got the correct "shebang" in front. For an actual binary, you'd need to find a way to compile a Mach-O binary on Linux.
Next, you need to make an Info.plist file in the Contents directory. Just dig out any Apple plist file as a template, and put these keys in it:
a. CFBundleExecutable—this should be the filename of your executable in Contents/MacOS
b. CFBundleIdentifier—this should be a unique bundle ID for your application, in reverse-DNS notation, i.e. com.yourwebsitename.yourappname
If you have these components in your .app bundle, it should launch when you double-click on it.
Hi this question seems to be answered but answers don't resolve my problem.
I try to include lua script into executable by copying it into exe
copy -b a.exe+test.lua output.exe
but when i launch output.exe luaL_dofile() cannot find lua script.
I dont want to use any third party apps to achieve this.
Copying files seems to work because Love2D projects works and I copy files in the same way but i treats them as zip archive (for sake of file hierarchy).
You can append a Lua script to your .exe but you'll need some way to load it into your program. The main problem is how to find the Lua script at the end of the .exe. srlua appends a small signature that contains the size of the Lua script so that the program can read the script at the right offset in the .exe file. Fortunately, the Lua API provides a function to load scripts from arbitrary sources. The convenience function luaL_dofile uses that function. You can use the same technique in your own program.
I needed to know if there is a program which would perform a set of simple tasks which a user can do.
For example. I want to copy file1 of folder1 to folder2. And then stop some services. And then copy file2 to folder3. If folder3 does not exist then folder4. And then download something and then maybe uninstall/install something.
May I please know if there is a program which can do that.
Thanking you.
Best regards,
Satya Ashok Kumar.
There is make for windows, too. nmake as part of Visual studio, gnu make from cygwin or mingw. Or something newer, like cmake.
But what you describe looks more like a simple batch file (like a shellscript on Unix) would be sufficient. The interpreter for that, cmd.exe, is already part of windows. More advanced: Powershell.
My organization has a group policy in effect that will only allow executable programs to reside under the Program Files (or Program Files X86) directory. Obviously, these directories are not writable by normal users. I have access to local admin rights, so I can install things there if I want. But of course it doesn't make sense to put the whole cygwin tree there, since users need to be able to write to /home, /tmp, etc. I am thinking I might be able to do something with links, maybe install to c:\cygwin, then move just the /bin directory under Program Files and create a hard link to it?
Has anyone run into a similar situation and come up with an elegant solution? This is Win 7 Enterprise.
Prior to Cygwin 1.7.34, solving such problems required a fair bit of hoop-jumping,¹ but now it's easy:
If you haven't installed Cygwin yet, do so.²
If you have Cygwin installed already and you started with a version of Cygwin prior to 1.7.34, move /etc/passwd and /etc/group out of the way,³ then upgrade to the current version.
Start the Cygwin Terminal.
Open Cygwin's /etc/nsswitch.conf in your favorite text editor.⁴ Add a line like this:
db_home: /%H
That's it! When you next re-start Cygwin, it will treat your Windows profile directory as your Cygwin home directory.⁵ This means you will have useful sub-folders like Desktop and Downloads as sub-folders, which matches the way OS X and a lot of desktop Linuxes work.
Some people might not want these two directories to be treated as equivalents. You can choose any path scheme you like. For example, you could change it to /cygdrive/c/Users/%U/cygwin to put your Cygwin home folder into a cygwin subdirectory of your Windows profile directory.
This new feature of Cygwin is very powerful and can do a lot more than I show here. For example, you can change a Cygwin user home directory via AD instead, if you like. See that documentation for details.
You might also want to rearrange a few other elements of the Cygwin path scheme. You can do so by editing Cygwin's /etc/fstab file. You probably want to move /tmp, /usr/tmp, and /var/tmp to a directory that non-admin users can write to, for one thing:
c:/tmp /tmp ntfs auto 0 0
c:/tmp /usr/tmp ntfs auto 0 0
c:/tmp /var/tmp ntfs auto 0 0
This will let you install (and later update) Cygwin as an Administrator while still letting unprivileged users run Cygwin. This makes Cygwin behave more like Linux or Unix. Since most software in the Cygwin package repository comes from that world, you can count on it to behave correctly under such a scheme.
Footnotes:
The first version of this answer tells you how to do an equivalent thing with older versions of Cygwin.
Cygwin doesn't care where you install it, so if the default doesn't work for you, feel free to change it. Some ideas:
C:\Program Files\Cygwin
C:\Users\jeremy\Cygwin
D:\cygwin
Cygwin will remember your choice on subsequent updates.
If you don't move these files out of the way, they interfere with the solution we build above. This part of Cygwin is complex enough to deserve a whole section in the Cygwin user manual. Hint. :)
Cygwin installs a stripped-down version of the Vim text editor by default.
If you don't like vi, there are many other text editors in the Cygwin package repository.
If you do like vi, I suggest installing the full version of Vim, then adding alias vi=vim to your ~/.bashrc.
You can also use a native Windows GUI text editor. Cygwin's /etc/nsswitch.conf parser appears to cope with DOS line endings.
The Cygwin DLL is building this path from the %HOMEDRIVE% and %HOMEPATH% environment variables, then converting it to POSIX form.
Heading says it all really. Using Windows 7 and latest stable gvim, whenever I save (:w) a file it's marked executable. I'm doing cross-platform development and it'd be nice if this didn't happen.
#sceptics: The flag of the files are indeed set as executable. Do a ls -al before and after re-saving the file to observe the issue. (install cygwin, or may be other *nix emulations)
#OP: the question have been raised several times in the past. I don't remember the conclusion on the subject. You should search vim mailing-lists archives (vim_use and vim_dev).
May be you can try to add an hook to your RCS (if it supports that) to proceed to a chmod -x on file extensions that does not correspond to an executable (*.h, *.cpp, *.vim, ...), or on files that do not contain a shebang (unlike perl, I don't know if python source files may contain a shebang)