fix install

pull/2/head
Joseph Werle 10 years ago
parent 3becfc7c31
commit 388a23dfab

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
BPKG_GIT_REMOTE="${BPKG_GIT_REMOTE:-"https://github.com"}"
BPKG_REMOTE="${BPKG_REMOTE:-"https://raw.githubusercontent.com"}" BPKG_REMOTE="${BPKG_REMOTE:-"https://raw.githubusercontent.com"}"
BPKG_USER="${BPKG_USER:-"bpkg"}" BPKG_USER="${BPKG_USER:-"bpkg"}"
@ -40,6 +41,7 @@ bpkg_install () {
## ensure there is a package to install ## ensure there is a package to install
if [ -z "${pkg}" ]; then if [ -z "${pkg}" ]; then
usage
return 1 return 1
fi fi
@ -47,6 +49,7 @@ bpkg_install () {
{ {
curl -s "${BPKG_REMOTE}" curl -s "${BPKG_REMOTE}"
if [ "0" != "$?" ]; then if [ "0" != "$?" ]; then
echo >&2 "error: Remote unreachable"
return 1 return 1
fi fi
} }
@ -61,6 +64,7 @@ bpkg_install () {
if [ "1" = "${#parts[@]}" ]; then if [ "1" = "${#parts[@]}" ]; then
version="master" version="master"
echo >&2 "Using latest (master)"
elif [ "2" = "${#parts[@]}" ]; then elif [ "2" = "${#parts[@]}" ]; then
name="${parts[0]}" name="${parts[0]}"
version="${parts[1]}" version="${parts[1]}"
@ -88,8 +92,10 @@ bpkg_install () {
return 1 return 1
fi fi
## clean up name of weird trailing versions ## clean up name of weird trailing
## versions and slashes
name=${name/@*//} name=${name/@*//}
name=${name////}
## build uri portion ## build uri portion
uri="/${user}/${name}/${version}" uri="/${user}/${name}/${version}"
@ -126,20 +132,20 @@ bpkg_install () {
## install bin if needed ## install bin if needed
build="$(echo -n ${json} | bpkg-json -b | grep 'install' | awk '{ print $2 }' | tr -d '\"')" build="$(echo -n ${json} | bpkg-json -b | grep 'install' | awk '{ print $2 }' | tr -d '\"')"
if [ ! -z "${build}" ]; then if [ ! -z "${build}" ]; then
( {(
## go to tmp dir ## go to tmp dir
cd $( [ ! -z $TMPDIR ] && echo $TMPDIR || echo /tmp) && cd $( [ ! -z $TMPDIR ] && echo $TMPDIR || echo /tmp) &&
## prune existing ## prune existing
rm -rf ${name}-${version} && rm -rf ${name}-${version} &&
## shallow clone ## shallow clone
git clone --depth=1 https://github.com/${user}/${name}.git ${name}-${version} && git clone --depth=1 ${BPKG_GIT_REMOTE}/${user}/${name}.git ${name}-${version} &&
## move into directory ## move into directory
cd ${name}-${version} && cd ${name}-${version} &&
## build ## build
( "${build}" ) && ( "${build}" ) &&
## clean up ## clean up
rm -rf ${name}-${version} rm -rf ${name}-${version}
) )}
fi fi
elif [ "${#scripts[@]}" -gt "0" ]; then elif [ "${#scripts[@]}" -gt "0" ]; then

@ -4,8 +4,5 @@
"description": "Lightweight bash package manager", "description": "Lightweight bash package manager",
"global": true, "global": true,
"scripts": [ "bpkg.sh" ], "scripts": [ "bpkg.sh" ],
"bin": { "bpkg": "bpkg.sh" }, "install": "make install"
"dependencies": {
"jwerle/term.sh": "*"
}
} }

Loading…
Cancel
Save