Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An executable that contains data

I've been thinking about a way to deploy configurations on a linux system, Specifically dotfiles.

I would really like to somehow compile all the dotfiles into one executable that, when executed, deploys them in the right place. Here comes the tricky part: the files are not available on the system where the executable is to be executed and I only want to 'ship' the executable. Nothing else.

Is there a way to put the files into the executable, so that they can be safely extracted later?

(I'm trying to build this in Haskell, but any language will do for the POC.))

like image 248
Syd Kerckhove Avatar asked Jun 02 '15 08:06

Syd Kerckhove


People also ask

What does an executable contain?

Executable files contain binary machine code that has been compiled from source code. This low-level code instructs a computer's central processing unit on how to run a program. The processor interprets the machine code and tells the computer's hardware what to do.

Can an exe store data?

Yes, there's plenty of space in an executable image you can put data. You can add a pre-initialised data segment for this, say, and write the data into there; or a resource, or you can abuse some of the segment padding space to store values in.

What is an example of an executable file?

A program file that can be run by a computer or device. An executable file contains a set of instructions, which your device interprets and runs when you open that file. For example, when you open the Microsoft Word executable file, it launches the Microsoft Word application.

Which is an executable program?

An executable is a file that contains a program - that is, a particular kind of file that is capable of being executed or run as a program in the computer. In a Disk Operating System or Windows operating system, an executable file usually has a file name extension of . bat, .com, or .exe.


1 Answers

You can do this using Template Haskell. Check out the file-embed package.

like image 104
Michael Snoyman Avatar answered Sep 21 '22 14:09

Michael Snoyman