{"id":29675117,"url":"https://github.com/joknarf/mkshz","last_synced_at":"2026-05-21T02:33:25.580Z","repository":{"id":305365276,"uuid":"1022701702","full_name":"joknarf/mkshz","owner":"joknarf","description":"self extracting shell gzip tarball packager","archived":false,"fork":false,"pushed_at":"2025-12-28T18:20:22.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-29T23:47:03.265Z","etag":null,"topics":["bash","command-line-tool","deployment","linux","macos","packager","posix","postinstall","self-extracting","shell-script","targz"],"latest_commit_sha":null,"homepage":"https://joknarf.github.io/joknarf-tools","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joknarf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-19T16:33:28.000Z","updated_at":"2025-12-28T17:43:18.000Z","dependencies_parsed_at":"2025-07-19T20:11:51.853Z","dependency_job_id":"11933a24-60bc-4206-8aa9-130d62adc01d","html_url":"https://github.com/joknarf/mkshz","commit_stats":null,"previous_names":["joknarf/mkshz"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/joknarf/mkshz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fmkshz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fmkshz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fmkshz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fmkshz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joknarf","download_url":"https://codeload.github.com/joknarf/mkshz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fmkshz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33286049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-20T15:12:43.734Z","status":"online","status_checked_at":"2026-05-21T02:00:07.181Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","command-line-tool","deployment","linux","macos","packager","posix","postinstall","self-extracting","shell-script","targz"],"created_at":"2025-07-22T23:05:56.987Z","updated_at":"2026-05-21T02:33:25.571Z","avatar_url":"https://github.com/joknarf.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Joknarf Tools](https://img.shields.io/badge/Joknarf%20Tools-Visit-darkgreen?logo=github)](https://joknarf.github.io/joknarf-tools)\n[![Build and Release Packages](https://github.com/joknarf/mkshz/actions/workflows/release.yml/badge.svg)](https://github.com/joknarf/mkshz/actions/workflows/release.yml)\n[![Shell](https://img.shields.io/badge/shell-bash%20-blue.svg)]()\n[![OS](https://img.shields.io/badge/OS-Linux%20|%20macOS%20|%20SunOS%20...-blue.svg)]()\n[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://shields.io/)\n[![Packages](https://img.shields.io/badge/Packages-%20rpm%20|%20deb%20|%20pkg%20|%20apk%20|%20brew%20-darkgreen.svg)](https://github.com/joknarf/mkshz/releases/latest)\n\n# mkshz\nself extracting shell gzip tarball packager.  \n\u003e * Simple shell script to generate self extracting shell script with embedded gzipped tarball.  \n\u003e * Minimalist universal packager with pre / post install command without any complex package factory to setup.  \n\u003e * Simple deployment of application using unique shell script package.\n\u003e * Alternative to rpm/deb/... factory for simple projects\n\n## prerequisites\n\n* bash\n* sed (gnu/bsd)\n* tar / gzip\n\nyou can use mkshz.compat if using old OS distribution (tar/sed missing features)\n\n## usage\n\nusage: `mkshz \u003cfile.shz\u003e \u003cdir\u003e [\u003ccommand\u003e [--tmp-exec] [--pre-extract \u003ccommand\u003e] \u003ctar options\u003e]`\n\nCreates a shell script `\u003cfile.shz\u003e` with embedded tgz archive created from `\u003cdir\u003e` content.\n* The script will extract the archive to the current directory on execution.\n* A `\u003ccommand\u003e` in `\u003cdir\u003e` can be specified to run after extraction with arguments passed to `\u003cfile.shz\u003e`.\n* A pre-extract `\u003ccommand\u003e` in `\u003cdir\u003e` can be specified to be extracted and run before the whole archive is extracted.\n* if `--tmp-exec` flag is set the resulting script will extract to /tmp/shz.XXXX executes the commands and clean the /tmp/shz.XXXXX\n* shz_version environment variable can be set to get the version of the archive using `v-shz` parameter.\n\nExample usage:\n\n```\n$ shz_version=v1.2 mkshz install.shz app/ bin/config.sh --pre-extract bin/pre-stop.bash --exclude=.git --exclude=*.o\n```\nNotes:\n* The `\u003ccommand\u003e` arguments are relative to `\u003cdir\u003e`.\n* The script generated will be created with a shebang line for bash.\n* The pre-extract `\u003ccommand\u003e` will be extracted and executed before extracting whole archive\n* The pre-extract `\u003ccommand\u003e` does not receive any arguments.\n* If the pre-extract `\u003ccommand\u003e` exit code is not zero, the script will abort whole extraction.\n\n## Example\n\n```\n$ shz_version=v1.2 mkshz installapp.shz app bin/setup.sh --pre-extract bin/stopapp.sh --exclude=.git\n```\n\n* Generated script `installapp.shz`:\n\n```\n#!/bin/bash                                                                                                                                                                         \n# Script created with mkshz\n# This script extracts embedded tgz archive \n# extract archive directory: 'app'\n# pre-extract command: 'app/bin/stopapp.sh'\n# post-extract command: 'app/bin/config.sh'\n# to extract the archive without command execution, use:\n#  ./installapp.shz x-shz\n# shz_verbose=1 env variable can be set to enable tar output\n# shz_target_dir can be set to specify the target directory for extraction\n#\nversion=\"v1.2\"\ndir=\"app\"\npre=\"app/bin/stopapp.sh\"\ncmd=\"app/bin/config.sh\"\ntmpexec=\"1\"\nshz=\"${0##*/}\"\n[ \"$shz_verbose\" ] \u0026\u0026 v=v || v=\"\"\n[ \"$1\" = \"v-shz\" ] \u0026\u0026 echo \"$version\" \u0026\u0026 exit 0\n[ \"$1\" = \"x-shz\" ] \u0026\u0026 cmd=\"\" pre=\"\"\n\n[ ! \"$shz_target_dir\" ] \u0026\u0026 [ \"$tmpexec\" ] \u0026\u0026 {\n  shz_target_dir=$(mktemp -d /tmp/shz.XXXXXX) || exit 1\n  [ \"$cmd\" ] \u0026\u0026 trap 'rm -rf \"$shz_target_dir\"' EXIT\n}\n: ${shz_target_dir:=$PWD}\n\nextract() {\n  sed '1,/^__tgz__/d' \"$0\"| (cd \"$shz_target_dir\" \u0026\u0026 tar xz${v}f - \"$@\" \u003e\u00262) || exit 1\n}\n\n# Pre-extract script:\n[ \"$pre\" ] \u0026\u0026 {\n  echo \"$shz: Extracting/Executing pre-extract script: $pre\" \u003e\u00262\n  extract \"$pre\"\n  \"$shz_target_dir/$pre\" || { echo \"$shz: Error: Failed to execute pre-extract script ($pre)\" \u003e\u00262; exit 1; }\n}\necho \"$shz: Extracting archive directory '$dir' in '$shz_target_dir'\" \u003e\u00262\nextract\n[ \"$cmd\" ] || exit 0\ncmd=\"$shz_target_dir/$cmd\"\necho \"$shz: Executing command: $cmd $*\" \u003e\u00262\n[ ! -x \"$cmd\" ] \u0026\u0026 echo \"$shz: Error: Command $cmd not found or not executable.\" \u003e\u00262 \u0026\u0026 exit 1\n\"$cmd\" \"$@\"\nexit $?\n\n__tgz__ ====== binary data starts here ==========================================\n```\n\n* script execution\n\n```\nuser@host:/myapp/distrib $ ./installapp.shz --register myhost\ninstallapp.shz: Extracting/Executing pre-extract script: app/bin/stopapp.sh\n  stopapp.sh: Stopping app\n  stopapp.sh: Done\ninstallapp.shz: Extracting archive directory 'app' in '/myapp/distrib'\ninstallapp.shz: Executing command: app/bin/setup.sh --register myhost\n  config.sh: Configuring app\n  config.sh: Starting app\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoknarf%2Fmkshz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoknarf%2Fmkshz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoknarf%2Fmkshz/lists"}