Last active
February 19, 2022 10:06
-
-
Save ikskuh/8c71e794a654b41f07510af96992dba7 to your computer and use it in GitHub Desktop.
Mini zpm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ihex": { | |
"git": "https://github.com/MasterQ32/zig-ihex" | |
}, | |
"args": { | |
"git": "https://github.com/MasterQ32/zig-args" | |
}, | |
"parser-toolkit": { | |
"git": "https://github.com/MasterQ32/parser-toolkit" | |
}, | |
"serial": { | |
"git": "https://github.com/MasterQ32/zig-serial" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### CONFIG ### | |
PACKAGE_LIBRARY="/home/felix/software/zig-packages.json" | |
### CODE STARTS HERE ### | |
set -e | |
if ! which jq git > /dev/null ; then | |
echo "Not all required tools are installed!" >&2 | |
exit 1 | |
fi | |
PACKAGE="$1" | |
if [ -z "${PACKAGE}" ]; then | |
echo "missing package name!" >&2 | |
exit 1 | |
fi | |
if [ "$(jq "has(\"${PACKAGE}\")" "${PACKAGE_LIBRARY}")" != "true" ]; then | |
echo "package ${PACKAGE} does not exist!" >&2 | |
echo "add ${PACKAGE} to ${PACKAGE_LIBRARY} in order to install it." >&2 | |
exit 1 | |
fi | |
ROOT="$(git rev-parse --show-superproject-working-tree)" | |
if [ -z "${ROOT}" ]; then | |
ROOT="$(git rev-parse --show-toplevel)" | |
fi | |
if [ ! -d "${ROOT}/.git" ]; then | |
echo "not in a git repository!" >&2 | |
exit 1 | |
fi | |
# if [ ! -f "${ROOT}/.gitmodules" ]; then | |
# echo "submodules not initialized!" >&2 | |
# exit 1 | |
# fi | |
if [ ! -d "${ROOT}/vendor" ]; then | |
echo "no vendor subfolder!" >&2 | |
exit 1 | |
fi | |
if [ -d "${ROOT}/vendor/${PACKAGE}" ]; then | |
echo "package ${PACKAGE} is already installed!" >&2 | |
exit 1 | |
fi | |
PACKAGE_REPO="$(jq --raw-output ".\"${PACKAGE}\".git" "${PACKAGE_LIBRARY}")" | |
cd "${ROOT}/vendor" | |
git submodule add "${PACKAGE_REPO}" "${PACKAGE}" | |
git submodule update --init --recursive | |
cd "${ROOT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment