Skip to content

Commit

Permalink
style: consistent formatting of bin scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
  • Loading branch information
vladdoster committed Jun 21, 2022
1 parent e60b969 commit d0f455e
Show file tree
Hide file tree
Showing 11 changed files with 346 additions and 335 deletions.
2 changes: 1 addition & 1 deletion bin/.local/bin/apple-silicon-m1-rosetta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
arch=$(/usr/bin/arch)

if [ "$arch" == "arm64" ]; then
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
fi
52 changes: 26 additions & 26 deletions bin/.local/bin/cherry-to-multiple-branchs.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
#!/usr/bin/env bash

function log() { echo "--- $1"; }
log() { echo "--- $1"; }

function merge {
log "pulling any changes on branch"
git pull --rebase
log "cherry-picking commit: $1"
git cherry-pick -x "$1"
git status
merge() {
log "pulling any changes on branch"
git pull --rebase
log "cherry-picking commit: $1"
git cherry-pick -x "$1"
git status

echo "Proceed with commit? (y/N):"
read XN
echo "Proceed with commit? (y/N):"
read XN

if [ "$XN" = "y" ]; then
log "committing"
git push origin
else
log "user aborted cherry-picking commit"
exit
fi
if [ "$XN" = "y" ]; then
log "committing"
git push origin
else
log "user aborted cherry-picking commit"
exit
fi
}

if [ ! -n "$1" ]; then
echo "Usage: cherrypick.sh <hash> [<branch1> <branch2> <branch3> ...]"
echo
echo "e.g. cherrypick.sh fb5cfe1cf2165abee 1.0.0 1.1.0 1.2.0"
exit
echo "Usage: cherrypick.sh <hash> [<branch1> <branch2> <branch3> ...]"
echo
echo "e.g. cherrypick.sh fb5cfe1cf2165abee 1.0.0 1.1.0 1.2.0"
exit
fi

if [ ! -n "$2" ]; then
log "cherry-picking to current branch"
merge "$1"
log "cherry-picking to current branch"
merge "$1"
else
for arg in "${@:2}"; do
git checkout "$arg"
merge "$1"
done
for arg in "${@:2}"; do
git checkout "$arg"
merge "$1"
done
fi
18 changes: 9 additions & 9 deletions bin/.local/bin/clang-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORK_DIR=$(mktemp -d)

if [[ ! $WORK_DIR || ! -d $WORK_DIR ]]; then
echo "--- failed creating temp build dir"
exit 1
echo "--- failed creating temp build dir"
exit 1
fi

function cleanup() {
sudo rm -rf "$WORK_DIR"
echo "--- cleaned up tmp build dir"
cleanup() {
sudo rm -rf "$WORK_DIR"
echo "--- cleaned up tmp build dir"
}

# cleanup build artifacts on EXIT signals
Expand All @@ -24,21 +24,21 @@ trap cleanup EXIT
echo "--- entering build dir $PWD"
pushd "$WORK_DIR"
if git clone --depth=1 "$SRC_URL" "$PROGRAM"; then
echo "--- cloned $PROGRAM, continuing"
echo "--- cloned $PROGRAM, continuing"
fi
pushd "$PROGRAM"
mkdir build
pushd build
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
echo "--- "
if autoreconf -iv; then
echo "--- autoreconf successfully, continuing"
echo "--- autoreconf successfully, continuing"
fi
if ./autogen.sh; then
echo "--- autogen.sh successful, continuing"
echo "--- autogen.sh successful, continuing"
fi
if ./configure; then
echo "--- configure successful, continuing"
echo "--- configure successful, continuing"
fi
echo "--- compiling $PROGRAM"
make -j
Expand Down
42 changes: 21 additions & 21 deletions bin/.local/bin/get-gh-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ curl -s $url | jq -r --arg filename "$filename" '.assets[] | select(.name == $fi

# extract
extract() {
for arg in $@; do
if [ -f $arg ]; then
case $arg in
*.tar.bz2) tar xjf $arg ;;
*.tar.gz) tar xzf $arg ;;
*.tar.xz) tar xzf $arg ;;
*.bz2) bunzip2 $arg ;;
*.gz) gunzip $arg ;;
*.tar) tar xf $arg ;;
*.tbz2) tar xjf $arg ;;
*.tgz) tar xzf $arg ;;
*.zip) unzip $arg ;;
*.Z) uncompress $arg ;;
*.rar) rar x $arg ;; # 'rar' must to be installed
*.jar) jar -xvf $arg ;; # 'jdk' must to be installed
*) echo "'$arg' cannot be extracted via extract()" ;;
esac
else
echo "'$arg' is not a valid file"
fi
done
for arg in $@; do
if [ -f $arg ]; then
case $arg in
*.tar.bz2) tar xjf $arg ;;
*.tar.gz) tar xzf $arg ;;
*.tar.xz) tar xzf $arg ;;
*.bz2) bunzip2 $arg ;;
*.gz) gunzip $arg ;;
*.tar) tar xf $arg ;;
*.tbz2) tar xjf $arg ;;
*.tgz) tar xzf $arg ;;
*.zip) unzip $arg ;;
*.Z) uncompress $arg ;;
*.rar) rar x $arg ;; # 'rar' must to be installed
*.jar) jar -xvf $arg ;; # 'jdk' must to be installed
*) echo "'$arg' cannot be extracted via extract()" ;;
esac
else
echo "'$arg' is not a valid file"
fi
done
}

pushd $tmp
Expand Down
89 changes: 50 additions & 39 deletions bin/.local/bin/installer
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,77 @@

#=== HELPER METHODS ===================================[[[

function _err() { echo -e "\e[38;5;82m[ERROR]\e[39m:\e[38;5;198m $1" && exit 1; }
function _log() { echo -e " \e[32m[INFO]\e[39m: $1"; }
_err() { echo -e "\e[38;5;82m[ERROR]\e[39m:\e[38;5;198m $1" && exit 1; }
_log() { echo -e " \e[32m[INFO]\e[39m: $1"; }
has() { command -v "$1" 1> /dev/null 2>&1; }

PROGRAM_SRC=$1; SRC_URL=$2; PROGRAM_TARBALL=$(basename "$2"); MAKE_OPTS=$3
PROGRAM_SRC=$1
SRC_URL=$2
PROGRAM_TARBALL=$(basename "$2")
MAKE_OPTS=$3

_log "installing $PROGRAM_SRC from $SRC_URL"

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORK_DIR=$(mktemp -d)

if [[ ! $WORK_DIR || ! -d $WORK_DIR ]]; then
_err "failed creating temp build directory"
_err "failed creating temp build directory"
fi

function cleanup {
sudo rm -rf "$WORK_DIR"
_log "cleaned up tmp build directory"
cleanup() {
sudo rm -rf "$WORK_DIR"
_log "cleaned up tmp build directory"
}

trap cleanup EXIT # cleanup build artifacts on EXIT signals

if command -v curl &>/dev/null; then DL_CMD="curl -Lk --output $PROGRAM_TARBALL"
elif command -v wget &>/dev/null; then DL_CMD="wget --output-document $PROGRAM_TARBALL:"
else _err "unable to find cURL or wget"
if command -v curl &> /dev/null; then
DL_CMD="curl -Lk --output $PROGRAM_TARBALL"
elif command -v wget &> /dev/null; then
DL_CMD="wget --output-document $PROGRAM_TARBALL:"
else
_err "unable to find cURL or wget"
fi

pushd "$WORK_DIR"
pushd "$WORK_DIR" || exit
if eval "$DL_CMD $SRC_URL"; then
_log "downloaded $PROGRAM_TARBALL tarball"
mkdir "$PROGRAM_SRC"
if tar -xvf "$PROGRAM_TARBALL" -C "$PROGRAM_SRC" --strip-components 1; then
_log "unpacked $PROGRAM_SRC tarball"
fi
mkdir "$PROGRAM_SRC"
if tar -xvf "$PROGRAM_TARBALL" -C "$PROGRAM_SRC" --strip-components 1; then
_log "unpacked $PROGRAM_SRC tarball"
fi
fi

pushd "$PROGRAM_SRC"
pushd "$PROGRAM_SRC" || exit

if [[ ! -e 'Makefile' ]]; then
_log "configuring $PROGRAM_SRC"
if has autoconf && autoconf; then
_log "autoconf successful"
elif has autoreconf && autoreconf -iv; then
_log "autoreconf successful"
elif [ -e autogen.sh ] && sh autogen.sh; then
_log "autogen.sh successful"
elif mkdir build && pushd build && cmake .. && popd; then
_log "cmake successful"
elif has automake && [ -f configure.ac ]; then
_log "found configure.ac, running automake"
automake && _log "automake successful"
else
_log "failed $PROGRAM_SRC configuration"
fi
fi

_log "configuring $PROGRAM_SRC"
if autoconf; then _log "autoconf successful"
elif autoreconf -iv; then _log "autoreconf successful"
elif sh autogen.sh; then _log "autogen.sh successful"
elif mkdir build && pushd build && cmake . && popd; then _log "cmake successful"
else _log "failed $PROGRAM_SRC configuration"
fi

if [[ -f configure.ac ]]; then
_log "found configure.ac, running automake"
automake && _log "automake successful" fi
fi

if ./configure $MAKE_OPTS; then _log "configured install"
elif ./Configure; then _log "configured install"
else _log "failed to configure $PROGRAM_SRC"
fi
if sh configure $MAKE_OPTS; then
_log "configured install"
elif ./Configure; then
_log "configured install"
else
_log "failed to configure $PROGRAM_SRC"
fi

sudo make --jobs 8 install \
&& _log "$PROGRAM_SRC installed" \
&& exit 0 \
|| _err "failed to install $PROGRAM_SRC" \
&& exit 1
if sudo make --jobs 8 install; then
_log "$PROGRAM_SRC installed" && exit 0
else
_err "failed to install $PROGRAM_SRC"
fi
Loading

0 comments on commit d0f455e

Please sign in to comment.