Skip to content

Instantly share code, notes, and snippets.

@DC3
Forked from CodeIter/termux-pacman-glibc-setup.sh
Created October 26, 2024 06:26
Show Gist options
  • Select an option

  • Save DC3/21d2320dbf355411a7aa0c58646d8832 to your computer and use it in GitHub Desktop.

Select an option

Save DC3/21d2320dbf355411a7aa0c58646d8832 to your computer and use it in GitHub Desktop.

Revisions

  1. @CodeIter CodeIter revised this gist Jun 11, 2024. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions termux-pacman-glibc-setup.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,8 @@

    set -xeuo pipefail

    pkg install pacman patchelf
    pkg install pacman patchelf \
    which time ldd tree

    echo
    echo
    @@ -91,7 +92,7 @@ fi
    cd "\${_oldpwd}"
    LD_PRELOAD= exec "\${_dir}/${i}.orig" "\${@}"
    # Or
    #exec grun "$\{_dir}/${i}.orig" "\${@}"
    #exec grun "\${_dir}/${i}.orig" "\${@}"
    EOF

  2. @CodeIter CodeIter revised this gist May 17, 2024. 1 changed file with 46 additions and 6 deletions.
    52 changes: 46 additions & 6 deletions termux-pacman-glibc-setup.sh
    Original file line number Diff line number Diff line change
    @@ -32,12 +32,12 @@ grun --help
    echo
    echo

    curl -fsSL https://deno.land/install.sh | sh
    curl -fsSL https://deno.land/install.sh | time sh

    echo
    echo

    curl -fsSL https://bun.sh/install | bash
    curl -fsSL https://bun.sh/install | time bash

    echo
    echo
    @@ -76,17 +76,57 @@ ldd "$(which bun)"
    echo
    echo

    LD_PRELOAD= deno --version
    for i in deno bun ; do
    cat - << EOF > ~/".${i}/bin/${i}.glibc.sh"
    #!/usr/bin/env sh
    _oldpwd="\${PWD}"
    _dir="\$(dirname "\${0}")"
    cd "\${_dir}"
    if ! [ -h "${i}" ] ; then
    >&2 mv -fv "${i}" "${i}.orig"
    >&2 ln -sfv "${i}.glibc.sh" "${i}"
    fi
    cd "\${_oldpwd}"
    LD_PRELOAD= exec "\${_dir}/${i}.orig" "\${@}"
    # Or
    #exec grun "$\{_dir}/${i}.orig" "\${@}"
    EOF

    chmod -c u+x ~/".${i}/bin/${i}.glibc.sh"
    done

    echo
    echo

    deno.glibc.sh --version

    echo
    echo

    bun.glibc.sh --version

    echo
    echo

    tree -a ~/.deno ~/.bun

    echo
    echo

    cat -n ~/.deno/bin/deno.glibc.sh

    echo
    echo

    LD_PRELOAD= bun --version
    cat -n ~/.bun/bin/bun.glibc.sh

    echo
    echo

    LD_PRELOAD= deno <<< "console.log('Hello world')"
    deno <<< "console.log('Hello world')"

    echo
    echo
    @@ -95,7 +135,7 @@ file="$(mktemp -p ~/.cache --suffix .js hello-XXX)"

    echo "console.log('Hello world')" > "${file}"

    LD_PRELOAD= bun run "${file}"
    bun run "${file}"

    echo
    echo
  3. @CodeIter CodeIter revised this gist May 17, 2024. 1 changed file with 33 additions and 6 deletions.
    39 changes: 33 additions & 6 deletions termux-pacman-glibc-setup.sh
    Original file line number Diff line number Diff line change
    @@ -49,26 +49,53 @@ export PATH="${PATH}:${DENO_INSTALL}/bin:${BUN_INSTALL}/bin"
    echo
    echo

    grun $(which deno) --version
    patchelf --print-interpreter --print-needed "$(which deno)"

    echo
    echo

    grun $(which bun) --version
    patchelf --print-interpreter --print-needed "$(which bun)"

    echo
    echo

    grun $(which deno) <<< "console.log('Hello world')"
    patchelf --set-rpath "${PREFIX}/glibc/lib" --set-interpreter "${PREFIX}/glibc/lib/ld-linux-aarch64.so.1" "$(which deno)"

    patchelf --set-rpath "${PREFIX}/glibc/lib" --set-interpreter "${PREFIX}/glibc/lib/ld-linux-aarch64.so.1" "$(which bun)"

    echo
    echo

    ldd "$(which deno)"

    echo
    echo

    ldd "$(which bun)"

    echo
    echo

    LD_PRELOAD= deno --version

    echo
    echo

    LD_PRELOAD= bun --version

    echo
    echo

    LD_PRELOAD= deno <<< "console.log('Hello world')"

    echo
    echo

    file=$(mktemp -p ~/.cache --suffix .js hello-XXX )
    file="$(mktemp -p ~/.cache --suffix .js hello-XXX)"

    echo "console.log('Hello world')" > $file
    echo "console.log('Hello world')" > "${file}"

    grun $(which bun) run $file
    LD_PRELOAD= bun run "${file}"

    echo
    echo
  4. @CodeIter CodeIter created this gist May 16, 2024.
    75 changes: 75 additions & 0 deletions termux-pacman-glibc-setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    #!/usr/bin/env -S bash -xeuo pipefail

    set -xeuo pipefail

    pkg install pacman patchelf

    echo
    echo

    pacman-key --init

    echo
    echo

    pacman-key --populate

    echo
    echo

    pacman -Syu

    echo
    echo

    pacman -Sy glibc-runner --assume-installed bash,patchelf,resolv-conf

    echo
    echo

    grun --help

    echo
    echo

    curl -fsSL https://deno.land/install.sh | sh

    echo
    echo

    curl -fsSL https://bun.sh/install | bash

    echo
    echo

    export DENO_INSTALL="${HOME}/.deno"
    export BUN_INSTALL="$HOME/.bun"
    export PATH="${PATH}:${DENO_INSTALL}/bin:${BUN_INSTALL}/bin"

    echo
    echo

    grun $(which deno) --version

    echo
    echo

    grun $(which bun) --version

    echo
    echo

    grun $(which deno) <<< "console.log('Hello world')"

    echo
    echo

    file=$(mktemp -p ~/.cache --suffix .js hello-XXX )

    echo "console.log('Hello world')" > $file

    grun $(which bun) run $file

    echo
    echo