diff --git a/.fpm b/.fpm new file mode 100644 index 0000000..332e704 --- /dev/null +++ b/.fpm @@ -0,0 +1,18 @@ +-s dir +-f +--name rebash +--license WTFPL +--version 0.0.8 +--architecture all +--depends bash +--depends sed +--depends grep +--provides rebash +--description 'bash/shell library/framework' +--url 'https://github.com/jandob/rebash' +--maintainer 'Janosch Dobler ' +--after-install 'after-install.sh' +--after-remove 'after-remove.sh' + +rebash.sh=/usr/bin/rebash +src/=/usr/lib/rebash/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist diff --git a/.travis.yml b/.travis.yml index 609427b..811be75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ sudo: required dist: trusty language: bash script: - - bash doc_test.sh + - bash rebash.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec72d36 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +from alpine:latest + +COPY dist/rebash-0.0.8-any.apk /tmp/ + +RUN apk add --allow-untrusted /tmp/rebash-0.0.8-any.apk + +ENTRYPOINT [ "/bin/bash", "-c" ] + +CMD [ "exec bash --init-file <(echo '. /usr/lib/rebash.sh') -i" ] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6aec195 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +ifndef PREFIX + override PREFIX=/usr/local +endif + +VERSION=0.0.8 + +.PHONY: test install package + +test: + bash rebash.sh --side-by-side --no-check-undocumented -v + +install: + install -b rebash.sh $(PREFIX)/bin/rebash + mkdir -p $(PREFIX)/lib/rebash + sudo cp -f src/* $(PREFIX)/lib/rebash/ + bash after-install.sh + +package: + mkdir -p ./dist + # fpm -t pacman -p dist/rebash-$(VERSION)-any.pkg bsdtar required? + fpm -t deb -p dist/rebash-$(VERSION)-any.deb + fpm -t rpm -p dist/rebash-$(VERSION)-any.rpm + fpm -t apk --depends coreutils -p dist/rebash-$(VERSION)-any.apk + +docker: + make package + docker build -t jandob/rebash:0.0.8 . + docker push jandob/rebash:0.0.8 && \ + docker tag jandob/rebash:0.0.8 jandob/rebash:latest && \ + docker push jandob/rebash:latest diff --git a/PKGBUILD b/PKGBUILD index 0f2e286..000335e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -16,6 +16,6 @@ package() { mkdir -p "${pkgdir}/usr/bin" rm -r "${srcdir}/rebash/images" cp -r "${srcdir}/rebash/" "${pkgdir}/usr/lib/" - ln -sT /usr/lib/rebash/doc_test.sh "${pkgdir}/usr/bin/rebash-doc-test" - ln -sT /usr/lib/rebash/documentation.sh "${pkgdir}/usr/bin/rebash-documentation" + ln -sT /usr/lib/rebash/src/doc_test.sh "${pkgdir}/usr/bin/rebash-doc-test" + ln -sT /usr/lib/rebash/src/documentation.sh "${pkgdir}/usr/bin/rebash-documentation" } diff --git a/after-install.sh b/after-install.sh new file mode 100644 index 0000000..4fa69c6 --- /dev/null +++ b/after-install.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo "export REBASH_HOME=/usr/lib/rebash" | tee /etc/.rebash +chmod 0755 /etc/.rebash +ln -s /usr/bin/rebash /usr/lib/rebash.sh diff --git a/after-remove.sh b/after-remove.sh new file mode 100644 index 0000000..122cdf7 --- /dev/null +++ b/after-remove.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf /etc/.rebash +rm -f /usr/lib/rebash.sh diff --git a/package.json b/package.json new file mode 100644 index 0000000..31f0455 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "rebash", + "version": "0.0.8", + "description": "bash/shell library/framework", + "install": "make install", + "scripts": [ "rebash.sh" ], + "files": [ + "src/arguments.sh", + "src/array.sh", + "src/btrfs.sh", + "src/change_root.sh", + "src/core.sh", + "src/dictionary.sh", + "src/doc_test.sh", + "src/documentation.sh", + "src/exceptions.sh", + "src/logging.sh", + "src/time.sh", + "src/ui.sh", + "src/utils.sh" + ] +} diff --git a/rebash.sh b/rebash.sh new file mode 100755 index 0000000..bd3caf5 --- /dev/null +++ b/rebash.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +VERSION=0.0.8 + +if [ -f $HOME/.rebash ]; then + source $HOME/.rebash +else + if [ -f /etc/.rebash ]; then + source /etc/.rebash + fi +fi + +if [ -z "$REBASH_HOME" ]; then + export REBASH_HOME=`dirname ${BASH_SOURCE[0]}`/src +fi + +if [[ ${BASH_SOURCE[0]} != $0 ]]; then + source $REBASH_HOME/core.sh +else + $REBASH_HOME/doc_test.sh "${@}" + exit $? +fi diff --git a/arguments.sh b/src/arguments.sh similarity index 100% rename from arguments.sh rename to src/arguments.sh diff --git a/array.sh b/src/array.sh similarity index 100% rename from array.sh rename to src/array.sh diff --git a/btrfs.sh b/src/btrfs.sh similarity index 100% rename from btrfs.sh rename to src/btrfs.sh diff --git a/change_root.sh b/src/change_root.sh similarity index 100% rename from change_root.sh rename to src/change_root.sh diff --git a/core.sh b/src/core.sh similarity index 97% rename from core.sh rename to src/core.sh index 7747928..baaf96b 100644 --- a/core.sh +++ b/src/core.sh @@ -292,7 +292,7 @@ core_import() { >>> ( >>> core.import logging >>> logging_set_level warn - >>> core.import test/mockup_module-b.sh false + >>> core.import ../test/mockup_module-b.sh false >>> ) +doc_test_contains imported module c @@ -300,12 +300,12 @@ core_import() { imported module b Modules should be imported only once. - >>> (core.import test/mockup_module_a.sh && \ - >>> core.import test/mockup_module_a.sh) + >>> (core.import ../test/mockup_module_a.sh && \ + >>> core.import ../test/mockup_module_a.sh) imported module a >>> ( - >>> core.import test/mockup_module_a.sh false + >>> core.import ../test/mockup_module_a.sh false >>> echo $core_declared_functions_after_import >>> ) imported module a @@ -314,7 +314,7 @@ core_import() { >>> ( >>> core.import logging >>> logging_set_level warn - >>> core.import test/mockup_module_c.sh false + >>> core.import ../test/mockup_module_c.sh false >>> echo $core_declared_functions_after_import >>> ) +doc_test_contains diff --git a/dictionary.sh b/src/dictionary.sh similarity index 100% rename from dictionary.sh rename to src/dictionary.sh index 22302c3..b0c66e9 100644 --- a/dictionary.sh +++ b/src/dictionary.sh @@ -56,8 +56,8 @@ dictionary_get_keys() { >>> dictionary_set map foo "a b c" bar 5 >>> dictionary_get_keys map - bar foo + bar Iterate keys: >>> dictionary_set map foo "a b c" bar 5 @@ -65,8 +65,8 @@ dictionary_get_keys() { >>> for key in $(dictionary_get_keys map); do >>> echo "$key": "$(dictionary_get map "$key")" >>> done - bar: 5 foo: a b c + bar: 5 >>> dictionary__bash_version_test=true >>> dictionary_set map foo "a b c" bar 5 diff --git a/doc_test.sh b/src/doc_test.sh similarity index 100% rename from doc_test.sh rename to src/doc_test.sh diff --git a/documentation.sh b/src/documentation.sh similarity index 100% rename from documentation.sh rename to src/documentation.sh diff --git a/exceptions.sh b/src/exceptions.sh similarity index 100% rename from exceptions.sh rename to src/exceptions.sh diff --git a/logging.sh b/src/logging.sh similarity index 100% rename from logging.sh rename to src/logging.sh diff --git a/time.sh b/src/time.sh similarity index 100% rename from time.sh rename to src/time.sh diff --git a/ui.sh b/src/ui.sh similarity index 100% rename from ui.sh rename to src/ui.sh diff --git a/utils.sh b/src/utils.sh similarity index 100% rename from utils.sh rename to src/utils.sh diff --git a/test/mockup_module-b.sh b/test/mockup_module-b.sh index 6295d6f..10e44a0 100644 --- a/test/mockup_module-b.sh +++ b/test/mockup_module-b.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # shellcheck source=./core.sh -source "$(dirname "${BASH_SOURCE[0]}")/../core.sh" +source "$(dirname "${BASH_SOURCE[0]}")/../src/core.sh" core.import logging core.import mockup_module_c.sh echo imported module b diff --git a/test/mockup_module_a.sh b/test/mockup_module_a.sh index 2dee914..f24c6a1 100644 --- a/test/mockup_module_a.sh +++ b/test/mockup_module_a.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # shellcheck source=../core.sh -source "$(dirname "${BASH_SOURCE[0]}")/../core.sh" +source "$(dirname "${BASH_SOURCE[0]}")/../src/core.sh" mockup_module_a_foo() { echo "a" } diff --git a/test/mockup_module_c.sh b/test/mockup_module_c.sh index c2b4df7..f92aac3 100644 --- a/test/mockup_module_c.sh +++ b/test/mockup_module_c.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # shellcheck source=./core.sh -source "$(dirname "${BASH_SOURCE[0]}")/../core.sh" +source "$(dirname "${BASH_SOURCE[0]}")/../src/core.sh" core.import logging core.import mockup_module-b.sh foo123() {