diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6fbbce73d76af814ecd714e5944ae366cd6f3b56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +hello +hello.uu +bundle +output diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..9f19558bad3f77339be2dc6d402e3943d4ce1b7c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +--- +language: c +dist: trusty +sudo: false +group: beta + +addons: + apt: + packages: + - sharutils + +script: + - bats . + +notifications: + email: false + on_failure: never diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..21f83f94ebe311f9f78caffc53a72d754f703e2a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Adar Nimrod + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..94dfeba14f190ba8e537b5b46ed7c1027276fd89 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +bundle: hello.uu shellscript + cat shellscript hello.uu > bundle + chmod 755 bundle + +hello.uu: hello + uuencode hello output > hello.uu + +hello: hello.c + gcc -o hello hello.c diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ea9362602573b776874f65ab1772bdfb08aae744 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Bundle + +[](https://travis-ci.org/adarnimrod/bundle) + +> Bundle a binary file into a shell script. + +This a proof of concept on how to create a shell script that contains a binary +file for easy installtion. + +## License + +This software is licensed under the MIT license (see `LICENSE.txt`). + +## Author Information + +Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my [website]( +https://www.shore.co.il/). Patches are welcome via [`git send-email`]( +http://git-scm.com/book/en/v2/Git-Commands-Email). The repository is located +at: <https://www.shore.co.il/git/>. diff --git a/hello.c b/hello.c new file mode 100644 index 0000000000000000000000000000000000000000..dcbf42de8372b4ab8fef42ffd9438f0b57083552 --- /dev/null +++ b/hello.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(void) { + printf("Hello world.\n"); + return 0; +} diff --git a/shellscript b/shellscript new file mode 100644 index 0000000000000000000000000000000000000000..3ce647f9f927640d1a98f494f2829d449804e3c1 --- /dev/null +++ b/shellscript @@ -0,0 +1,5 @@ +#!/bin/sh +set -eu +uudecode "$0" +./output +exit diff --git a/test.bats b/test.bats new file mode 100644 index 0000000000000000000000000000000000000000..21736319ec9ded584a8a7aa0bb997b923f37bda7 --- /dev/null +++ b/test.bats @@ -0,0 +1,25 @@ +#!/usr/bin/env bats + +setup () { + git clean -fdX + make bundle +} + +@test './bundle' { + run ./bundle + [ "$output" = "Hello world." ] + [ "$status" -eq 0 ] +} + +@test 'sh bundle' { + run sh bundle + [ "$output" = "Hello world." ] + [ "$status" -eq 0 ] +} + +@test 'cat bundle | sh' { + skip "This will fail" + run sh -c 'cat bundle | sh' + [ "$output" = "Hello world." ] + [ "$status" -eq 0 ] +}