Skip to content

Instantly share code, notes, and snippets.

@d-faure
Last active July 2, 2024 16:19
Show Gist options
  • Save d-faure/5f89d9d2692f24d54cf336a8c12dda98 to your computer and use it in GitHub Desktop.
Save d-faure/5f89d9d2692f24d54cf336a8c12dda98 to your computer and use it in GitHub Desktop.
How-to make a busybox-w32 installation more or less portable

Make a directory somewhere to be used as base directory for the busybox-w32 stuff itself (eg. C:\Tools\busybox). The busybox-start.cmd script would be useful to start an interactive command line from the desktop.

Busybox-win32 file layout

busybox-start.cmd (see below)

busybox/ (base dir)

busybox.exe (https://frippery.org/files/busybox/busybox.exe)

busybox64.exe (https://frippery.org/files/busybox/busybox64.exe)

etc/

ashrc (see below)

profile (see below)

home/

.profile (see below)

man/

cat1/

busybox.1.gz (https://frippery.org/files/busybox/busybox.1.gz)

ConEmu

"C:\Tools\busybox\busybox64.exe" sh -s -i -c "export BB_ROOT=C:/Tools/busybox && . $BB_ROOT/etc/profile" -new_console:t:"BusyBox"

Windows Terminal

"C:\Tools\busybox\busybox64.exe" sh -s -i -c "export BB_ROOT=C:/Tools/busybox && . $BB_ROOT/etc/profile"

@echo off
rem mode con: cols=15 lines=1
set __=%~dp0
if #\#==#%__:~-1%# set __=%__:~0,-1%
set BUSYBOX_EXE=busybox64.exe
if "%PROCESSOR_ARCHITECTURE%"=="X86" set BUSYBOX_EXE=busybox.exe
set BUSYBOX_EXE=%__%\busybox\%BUSYBOX_EXE%
start "%BUSYBOX_EXE%" /d "%__%" "%BUSYBOX_EXE%" sh -s -i -c "export BB_ROOT=%__:\=/%/busybox && . $BB_ROOT/etc/profile"
# -*- /etc/ashrc --- mode: shell-script -*-
#
function show_banner() {
head --help 2>&1 | head -n 2 # in order to get a busybox banner
cat << EOF
BB_ROOT....: $BB_ROOT
HOME.......: $HOME
USERPROFILE: $USERPROFILE
ENV........: $ENV
EOF
}
function set_prompt() {
local _c='\[\033[01;32m\]'
[ $(id -u) -eq 0 ] && _c='\[\033[01;31m\]'
export PS1="\n${_c}\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\n\$ "
}
function set_aliases() {
alias ll='ls -l'
}
# -*- /etc/profile --- mode: shell-script -*-
#
# Startup command line (Windows Terminal/ConEmu):
# "C:/Tools/BusyBox/busybox64.exe" sh -s -i -c "export BB_ROOT=C:/Tools/BusyBox && . $BB_ROOT/etc/profile"
# "C:/Tools/BusyBox/busybox.exe" sh -s -i -c "export BB_ROOT=C:/Tools/BusyBox && . $BB_ROOT/etc/profile"
#
#export BB_ROOT="$PWD"
[ -f "$HOME/.profile" ] && . "$HOME/.profile"
[ -f "$BB_ROOT/home/.profile" ] && . "$BB_ROOT/home/.profile"
[ -z "$ENV" ] && export ENV="$BB_ROOT/etc/ashrc" && . "$ENV"
set_prompt
set_aliases
show_banner
# -*- ~/.profile --- mode: shell-script -*-
#
#export HOME="$BB_ROOT/home"
#cli_path=$(realpath $BB_ROOT/../cli-tools)
#if [ "$PROCESSOR_ARCHITECTURE" = "X86" ]; then
# export JQ=jq-win32.exe
# rsync_path=cygwin-x86
# curl_path=curl-7.65.3-win32-mingw
# sevenzip_path=7z
# ffmpeg_path=ffmpeg-20190812-faa9cd3-win32-shared/bin
#else
# export JQ=jq-win64.exe
# rsync_path=cygwin-x86_64
# curl_path=curl-7.65.3-win64-mingw
# sevenzip_path=7z/x64
# ffmpeg_path=ffmpeg-20190812-faa9cd3-win64-shared/bin
#fi
#jq_path=jq
#alias jq=$JQ
#export PATH=$cli_path/$jq_path:$cli_path/$rsync_path:$cli_path/$curl_path:$cli_path/$sevenzip_path:$cli_path/$ffmpeg_path:$PATH
[ ! -z "$CONEMUWORKDIR" ] && cd "$CONEMUWORKDIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment