Added GitHub Actions and updated build framework

This commit is contained in:
takeshix 2020-07-15 22:13:51 +02:00
parent 1f9bc44c60
commit 2e95cb4f0f
23 changed files with 1065 additions and 31 deletions

43
.github/README.md vendored Normal file
View file

@ -0,0 +1,43 @@
# static-toolbox
This repository includes prebuild static binaries and build-recipes for various tools like Nmap and OpenSSH.
The Linux versions are compiled with the musl-cross toolchain and the openssl-pm-snapshot fork of OpenSSL in order to support a wide range of SSL/TLS features (Warning: some of them are insecure!).
Compilation is done automatically with GitHub Actions.
## Tools
### Nmap
![Nmap x86_64](https://github.com/takeshixx/workflow-test/workflows/Nmap%20x86_64/badge.svg)
![Nmap x86](https://github.com/takeshixx/workflow-test/workflows/Nmap%20x86/badge.svg)
![Nmap ARMHF](https://github.com/takeshixx/workflow-test/workflows/Nmap%20ARMHF/badge.svg)
![Nmap AARCH64](https://github.com/takeshixx/workflow-test/workflows/Nmap%20AARCH64/badge.svg)
### OpenSSH
![OpenSSH x86_64](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20x86_64/badge.svg)
![OpenSSH x86](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20x86/badge.svg)
![OpenSSH ARMHF](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20ARMHF/badge.svg)
![OpenSSH AARCH64](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20AARCH64/badge.svg)
### socat
![socat x86_64](https://github.com/takeshixx/workflow-test/workflows/socat%20x86_64/badge.svg)
![socat x86](https://github.com/takeshixx/workflow-test/workflows/socat%20x86/badge.svg)
![OpenSSH ARMHF](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20ARMHF/badge.svg)
![OpenSSH AARCH64](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20AARCH64/badge.svg)
### GDB
![GDB x86_64](https://github.com/takeshixx/workflow-test/workflows/GDB%20x86_64/badge.svg)

25
.github/workflows/build-gdb-x86_64.yml vendored Normal file
View file

@ -0,0 +1,25 @@
name: GDB x86_64
on:
workflow_dispatch
jobs:
build:
name: Build GDB x86_64
runs-on: ubuntu-latest
container: muslcc/x86_64:x86_64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build GDB
id: build_gdb
run: $GITHUB_WORKSPACE/build/targets/build_gdb.sh x86_64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_gdb.outputs.PACKAGED_NAME }}
path: ${{ steps.build_gdb.outputs.PACKAGED_NAME_PATH }}

View file

@ -0,0 +1,35 @@
name: Nmap AARCH64
on:
workflow_dispatch
jobs:
build:
name: Build Nmap AARCH64
runs-on: ubuntu-latest
container: muslcc/x86_64:aarch64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build Nmap
run: $GITHUB_WORKSPACE/build/targets/build_nmap.sh aarch64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Package Nmap
id: package_nmap
run: $GITHUB_WORKSPACE/package/targets/nmap/package.sh /output aarch64
- name: List packaged artifacts
run: ls -la /packaged
- name: Upload tarball
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL }}
path: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL_PATH }}
- name: Upload zip
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_ZIP }}
path: ${{ steps.package_nmap.outputs.PACKAGED_ZIP_PATH }}

35
.github/workflows/build-nmap-armhf.yml vendored Normal file
View file

@ -0,0 +1,35 @@
name: Nmap ARMHF
on:
workflow_dispatch
jobs:
build:
name: Build Nmap ARMHF
runs-on: ubuntu-latest
container: muslcc/x86_64:armel-linux-musleabihf
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build Nmap
run: $GITHUB_WORKSPACE/build/targets/build_nmap.sh armhf
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Package Nmap
id: package_nmap
run: $GITHUB_WORKSPACE/package/targets/nmap/package.sh /output armhf
- name: List packaged artifacts
run: ls -la /packaged
- name: Upload tarball
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL }}
path: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL_PATH }}
- name: Upload zip
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_ZIP }}
path: ${{ steps.package_nmap.outputs.PACKAGED_ZIP_PATH }}

35
.github/workflows/build-nmap-x86.yml vendored Normal file
View file

@ -0,0 +1,35 @@
name: Nmap x86
on:
workflow_dispatch
jobs:
build:
name: Build Nmap x86
runs-on: ubuntu-latest
container: muslcc/x86_64:i686-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build Nmap
run: $GITHUB_WORKSPACE/build/targets/build_nmap.sh x86
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Package Nmap
id: package_nmap
run: $GITHUB_WORKSPACE/package/targets/nmap/package.sh /output x86
- name: List packaged artifacts
run: ls -la /packaged
- name: Upload tarball
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL }}
path: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL_PATH }}
- name: Upload zip
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_ZIP }}
path: ${{ steps.package_nmap.outputs.PACKAGED_ZIP_PATH }}

34
.github/workflows/build-nmap-x86_64.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: Nmap x86_64
on:
workflow_dispatch
jobs:
build:
name: Build Nmap x86_64
runs-on: ubuntu-latest
container: muslcc/x86_64:x86_64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build Nmap
run: $GITHUB_WORKSPACE/build/targets/build_nmap.sh x86_64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Package Nmap
id: package_nmap
run: $GITHUB_WORKSPACE/package/targets/nmap/package.sh /output x86_64
- name: List packaged artifacts
run: ls -la /packaged
- name: Upload tarball
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL }}
path: ${{ steps.package_nmap.outputs.PACKAGED_TARBALL_PATH }}
- name: Upload zip
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package_nmap.outputs.PACKAGED_ZIP }}
path: ${{ steps.package_nmap.outputs.PACKAGED_ZIP_PATH }}

View file

@ -0,0 +1,25 @@
name: OpenSSH AARCH64
on:
workflow_dispatch
jobs:
build:
name: Build OpenSSH AARCH64
runs-on: ubuntu-latest
container: muslcc/x86_64:aarch64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build OpenSSH
id: build_openssh
run: $GITHUB_WORKSPACE/build/targets/build_openssh.sh aarch64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_openssh.outputs.PACKAGED_NAME }}
path: ${{ steps.build_openssh.outputs.PACKAGED_NAME_PATH }}

View file

@ -0,0 +1,25 @@
name: OpenSSH ARMHF
on:
workflow_dispatch
jobs:
build:
name: Build OpenSSH ARMHF
runs-on: ubuntu-latest
container: muslcc/x86_64:armel-linux-musleabihf
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build OpenSSH
id: build_openssh
run: $GITHUB_WORKSPACE/build/targets/build_openssh.sh armhf
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_openssh.outputs.PACKAGED_NAME }}
path: ${{ steps.build_openssh.outputs.PACKAGED_NAME_PATH }}

25
.github/workflows/build-openssh-x86.yml vendored Normal file
View file

@ -0,0 +1,25 @@
name: OpenSSH x86
on:
workflow_dispatch
jobs:
build:
name: Build OpenSSH x86
runs-on: ubuntu-latest
container: muslcc/x86_64:i686-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build OpenSSH
id: build_openssh
run: $GITHUB_WORKSPACE/build/targets/build_openssh.sh x86
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_openssh.outputs.PACKAGED_NAME }}
path: ${{ steps.build_openssh.outputs.PACKAGED_NAME_PATH }}

View file

@ -0,0 +1,25 @@
name: OpenSSH x86_64
on:
workflow_dispatch
jobs:
build:
name: Build OpenSSH x86_64
runs-on: ubuntu-latest
container: muslcc/x86_64:x86_64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Checkout
uses: actions/checkout@v2
- name: Build OpenSSH
id: build_openssh
run: $GITHUB_WORKSPACE/build/targets/build_openssh.sh x86_64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_openssh.outputs.PACKAGED_NAME }}
path: ${{ steps.build_openssh.outputs.PACKAGED_NAME_PATH }}

View file

@ -0,0 +1,34 @@
name: socat AARCH64
on:
workflow_dispatch
jobs:
build:
name: Build socat AARCH64
runs-on: ubuntu-latest
container: muslcc/x86_64:aarch64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Install testing dependencies
run: apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing yodl
- name: Install build compiler
run: /bin/sh -c "apk update && apk upgrade && apk add --no-cache curl rsync sudo util-linux && cd / && curl -so ${ARCH}-cross.tgz ${HOST}/${ARCH}-cross.tgz && tar -xf ${ARCH}-cross.tgz && rm ${ARCH}-cross.tgz && cd ${ARCH}-cross"
env:
ARCH: x86_64-linux-musl
HOST: https://more.musl.cc/9.2.1/x86_64-linux-musl
TEMP: /tmp
USER: 0
- name: Checkout
uses: actions/checkout@v2
- name: Build socat
id: build_socat
run: $GITHUB_WORKSPACE/build/targets/build_socat.sh aarch64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_socat.outputs.PACKAGED_NAME }}
path: ${{ steps.build_socat.outputs.PACKAGED_NAME_PATH }}

34
.github/workflows/build-socat-armhf.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: socat ARMHF
on:
workflow_dispatch
jobs:
build:
name: Build socat ARMHF
runs-on: ubuntu-latest
container: muslcc/x86_64:armel-linux-musleabihf
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Install testing dependencies
run: apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing yodl
- name: Install build compiler
run: /bin/sh -c "apk update && apk upgrade && apk add --no-cache curl rsync sudo util-linux && cd / && curl -so ${ARCH}-cross.tgz ${HOST}/${ARCH}-cross.tgz && tar -xf ${ARCH}-cross.tgz && rm ${ARCH}-cross.tgz && cd ${ARCH}-cross"
env:
ARCH: x86_64-linux-musl
HOST: https://more.musl.cc/9.2.1/x86_64-linux-musl
TEMP: /tmp
USER: 0
- name: Checkout
uses: actions/checkout@v2
- name: Build socat
id: build_socat
run: $GITHUB_WORKSPACE/build/targets/build_socat.sh armhf
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_socat.outputs.PACKAGED_NAME }}
path: ${{ steps.build_socat.outputs.PACKAGED_NAME_PATH }}

27
.github/workflows/build-socat-x86.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: socat x86
on:
workflow_dispatch
jobs:
build:
name: Build socat x86
runs-on: ubuntu-latest
container: muslcc/x86_64:i686-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Install testing dependencies
run: apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing yodl
- name: Checkout
uses: actions/checkout@v2
- name: Build socat
id: build_socat
run: $GITHUB_WORKSPACE/build/targets/build_socat.sh x86
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_socat.outputs.PACKAGED_NAME }}
path: ${{ steps.build_socat.outputs.PACKAGED_NAME_PATH }}

View file

@ -0,0 +1,27 @@
name: socat x86_64
on:
workflow_dispatch
jobs:
build:
name: Build socat x86_64
runs-on: ubuntu-latest
container: muslcc/x86_64:x86_64-linux-musl
steps:
- name: Install dependencies
run: apk update && apk add bash git perl make cmake flex bison automake autoconf libtool qemu-arm qemu-aarch64 file texinfo zip
- name: Install testing dependencies
run: apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing yodl
- name: Checkout
uses: actions/checkout@v2
- name: Build socat
id: build_socat
run: $GITHUB_WORKSPACE/build/targets/build_socat.sh x86_64
- name: List build directory
run: ls -la /build
- name: List build artifacts
run: ls -la /output
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.build_socat.outputs.PACKAGED_NAME }}
path: ${{ steps.build_socat.outputs.PACKAGED_NAME_PATH }}

View file

@ -1,49 +1,43 @@
# static-toolbox
This repository includes prebuild static binaries and build-recipes for various tools like Nmap.
This repository includes prebuild static binaries and build-recipes for various tools like Nmap and OpenSSH.
The Linux versions are compiled with the [musl-cross](https://github.com/takeshixx/musl-cross) toolchain and the [openssl-pm-snapshot](https://github.com/drwetter/openssl-pm-snapshot) fork of OpenSSL in order to support a wide range of SSL/TLS features (Warning: some of them are insecure!).
The Linux versions are compiled with the musl-cross toolchain and the openssl-pm-snapshot fork of OpenSSL in order to support a wide range of SSL/TLS features (Warning: some of them are insecure!).
## Release Packages
Compilation is done automatically with GitHub Actions.
Precompiled and packaged releases are available in the tags/release section.
## Tools
## Nmap
### Nmap
Precompiled versions of Nmap are available for the following operating systems/architectures:
![Nmap x86_64](https://github.com/takeshixx/workflow-test/workflows/Nmap%20x86_64/badge.svg)
* Linux x86 (nmap, ncat, nping)
* Linux x86_64 (nmap, ncat, nping)
* Linux armhf (nmap, ncat, nping)
* Linux aarch64 (nmap, ncat, nping)
* Windows x86 (nmap)
![Nmap x86](https://github.com/takeshixx/workflow-test/workflows/Nmap%20x86/badge.svg)
## Socat
![Nmap ARMHF](https://github.com/takeshixx/workflow-test/workflows/Nmap%20ARMHF/badge.svg)
Precompiled versions of socat are available for the following operating systems/architectures:
![Nmap AARCH64](https://github.com/takeshixx/workflow-test/workflows/Nmap%20AARCH64/badge.svg)
* Linux x86
* Linux x86_64
### OpenSSH
## GDB
![OpenSSH x86_64](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20x86_64/badge.svg)
Precompiled versions of `gdb` and `gdbserver` are available for the following operating systems/architecturs:
![OpenSSH x86](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20x86/badge.svg)
* Linux x86
* Linux x86_64
* Linux armhf
* Linux aarch64
![OpenSSH ARMHF](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20ARMHF/badge.svg)
# Building with Vagrant
![OpenSSH AARCH64](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20AARCH64/badge.svg)
The recipes are supposed to be built in Docker containers. In case Docker is not available, it is recommended to use Vagrant to built everything in a VM, e.g. Nmap for Linux x86:
### socat
```
vagrant up
vagrant ssh
cd /vagrant/recipes/nmap/linux_x86
sudo docker build -t static-toolbox-nmap-x86 .
sudo docker run -v $(pwd)/output:/output static-toolbox-nmap-x86
```
![socat x86_64](https://github.com/takeshixx/workflow-test/workflows/socat%20x86_64/badge.svg)
This is also the recommended way to run the build scripts without Docker without creating directories like `/build` and `/output` on your host system.
![socat x86](https://github.com/takeshixx/workflow-test/workflows/socat%20x86/badge.svg)
![OpenSSH ARMHF](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20ARMHF/badge.svg)
![OpenSSH AARCH64](https://github.com/takeshixx/workflow-test/workflows/OpenSSH%20AARCH64/badge.svg)
### GDB
![GDB x86_64](https://github.com/takeshixx/workflow-test/workflows/GDB%20x86_64/badge.svg)

267
build/lib.sh Executable file
View file

@ -0,0 +1,267 @@
#!/bin/bash
GIT_OPENSSL="https://github.com/drwetter/openssl-pm-snapshot.git"
GIT_BINUTILS_GDB="https://github.com/bminor/binutils-gdb.git"
GIT_READLINE="https://git.savannah.gnu.org/git/readline.git"
GIT_NCURSES="https://github.com/ThomasDickey/ncurses-snapshots.git"
BUILD_DIRECTORY="/build"
OUTPUT_DIRECTORY="/output"
GCC_OPTS="-static -fPIC"
GXX_OPTS="-static -static-libstdc++ -fPIC"
TMP_DIR=$(mktemp -dt building_lib.XXXXXX)
trap "rm -rf ${TMP_DIR}" EXIT TERM
# The init function that has to
# be called before running any
# other function. Should be used
# to configure the building env.
init_lib(){
CURRENT_ARCH="$1"
if [ ! -d "$BUILD_DIRECTORY" ];then
mkdir -p $BUILD_DIRECTORY
fi
if [ ! -d "$OUTPUT_DIRECTORY" ];then
mkdir -p $OUTPUT_DIRECTORY
fi
}
# Set a HTTP proxy for fetching
# software via HTTP and Git.
set_http_proxy(){
proxy=$1
export http_proxy="$proxy"
export https_proxy="$proxy"
git config --global http.proxy "$proxy"
}
# Return a host triple for the
# selected architecture.
get_host_triple(){
local host
if [ "$CURRENT_ARCH" == "x86" ];then
host="i486-linux-musl"
elif [ "$CURRENT_ARCH" == "x86_64" ];then
host="x86_64-unknown-linux-musl"
elif [ "$CURRENT_ARCH" == "armhf" ];then
host="arm-linux-musleabihf"
elif [ "$CURRENT_ARCH" == "aarch64" ];then
host="aarch64-linux-musleabi"
fi
echo $host
}
# Fetch and extract a resource via
# HTTP or clone a Git repository.
fetch(){
if [ "$#" -ne 3 ];then
echo "fetch() requires a source, destination and method."
echo "Example: fetch http://github.com/test.git /build/test git"
exit 1
fi
source=$1
shift
destination=$1
shift
method=$@
# TODO: check if $source is a valid URL
if [ -d "$destination" ] || [ -f "$destination" ];then
echo "Destination ${destination} already exists, skipping."
return
fi
if [ "${method,,}" == "http" ];then
cd /tmp || { echo "Could not cd to /tmp"; exit 1; }
headers=$(mktemp headers.XXXXXX)
curl -L -D "$headers" -sOJ "$source"
filename=$(cat "$headers" | grep -o -E 'filename=.*$' | sed -e 's/filename=//')
filename=$(trim "$filename")
extract "$filename" "$destination"
trap "rm -rf ${headers} /tmp/'${filename}'" EXIT TERM
elif [ "${method,,}" == "git" ];then
git clone "$source" "$destination"
else
echo "Invalid method ${method}"
exit 1
fi
}
# Extract an archive to a
# destination directory.
extract(){
if [ "$#" -ne 2 ];then
echo "extract() requires a source and destination."
exit 1
fi
source=$1
destination=$2
if [ ! -d "$destination" ];then
mkdir -p "$destination"
fi
if [ -f "$source" ] ; then
case $source in
*.tar.bz2) tar xjf "$source" -C "$destination" --strip-components 1 ;;
*.tar.gz) tar xzf "$source" -C "$destination" --strip-components 1 ;;
*.tar.xz) tar xvfJ "$source" -C "$destination" --strip-components 1 ;;
*.tar) tar xf "$source" -C "$destination" --strip-components 1 ;;
*.tbz2) tar xjf "$source" -C "$destination" --strip-components 1 ;;
*.tgz) tar xzf "$source" -C "$destination" --strip-components 1 ;;
*) echo "'${source}' cannot be extracted via extract()" ;;
esac
else
echo "'${source}' is not a valid file"
fi
}
# Remove leading and
# trailing whitespaces.
trim(){
local var="$*"
var="${var#"${var%%[![:space:]]*}"}"
var="${var%"${var##*[![:space:]]}"}"
echo -n "$var"
}
# Determine the version of
# a binary after building.
get_version(){
local cmd="$1"
if [ -z "$cmd" ];then
echo "Please provide a command to determine the version" >&2
echo "Example: /build/test --version | awk '{print \$2}'" >&2
exit 1
fi
local version="-"
if [ "$CURRENT_ARCH" == "armhf" ];then
if which qemu-arm 1>&2 2>/dev/null;then
cmd="qemu-arm ${cmd}"
version+=$(eval "$cmd")
else
echo "qemu-arm not found, skipping ARMHF version checks." >&2
fi
elif [ "$CURRENT_ARCH" == "aarch64" ];then
if which qemu-aarch64 1>&2 2>/dev/null;then
cmd="qemu-aarch64 ${cmd}"
version+=$(eval "$cmd")
else
echo "qemu-aarch64 not found, skipping AARCH64 version checks." >&2
fi
else
version+=$(eval "$cmd")
fi
if [ "$version" == "-" ];then
version+="${CURRENT_ARCH}"
else
version+="-${CURRENT_ARCH}"
fi
echo "$version"
}
lib_create_tmp_dir(){
local tmp_dir=$(mktemp -dt -p ${TMP_DIR} tmpdir.XXXXXX)
echo "$tmp_dir"
}
lib_check_lib_arch(){
lib=$1
if [ ! -f "$lib" ];then
echo ""
return
fi
local tmp_dir=$(lib_create_tmp_dir)
cp "$lib" "$tmp_dir"
bash -c "cd ${tmp_dir}; ar x $(basename ${lib})"
local output=$(find "${tmp_dir}" -name "*.o" -exec file {} \;)
if echo "$output" | grep -q "Intel 80386";then
echo "Arch of ${lib} is x86" >&2
echo "x86"
elif echo "$output" | grep -q "x86-64";then
echo "Arch of ${lib} is x86_64" >&2
echo "x86_64"
elif echo "$output" | grep -q "ARM aarch64";then
echo "Arch of ${lib} is armhf" >&2
echo "armhf"
elif echo "$output" | grep -q "ARM,";then
echo "Arch of ${lib} is aarch64" >&2
echo "aarch64"
else
echo "Could not determine arch of library ${lib}" >&2
echo ""
fi
}
lib_build_openssl(){
local version=$1
fetch "$GIT_OPENSSL" "${BUILD_DIRECTORY}/openssl" git
cd "${BUILD_DIRECTORY}/openssl" || { echo "Cannot cd to ${BUILD_DIRECTORY}/openssl"; exit 1; }
if [ -n "$version" ];then
git checkout "$version" || echo "Version ${version} not found, continuing with master."
fi
if [ -f "${BUILD_DIRECTORY}/openssl/libssl.a" ];then
lib_arch=$(lib_check_lib_arch "${BUILD_DIRECTORY}/openssl/libssl.a")
if [ "$lib_arch" != "$CURRENT_ARCH" ];then
echo "Rebuild for current arch"
git clean -fdx || true
else
echo "[+] OpenSSL already available for current arch, skipping building"
return
fi
fi
local openssl_arch
if [ "${CURRENT_ARCH}" == "x86" ] ||
[ "${CURRENT_ARCH}" == "armhf" ];then
openssl_arch="linux-generic32"
elif [ "${CURRENT_ARCH}" == "x86_64" ];then
openssl_arch="linux-x86_64"
elif [ "${CURRENT_ARCH}" == "aarch64" ];then
openssl_arch="linux-generic64"
fi
CFLAGS="${GCC_OPTS}" \
./Configure \
no-shared \
"$openssl_arch"
make -j4
echo "[+] Finished building OpenSSL ${CURRENT_ARCH}"
}
lib_build_zlib(){
fetch "$GIT_BINUTILS_GDB" "${BUILD_DIRECTORY}/binutils-gdb" git
cd "${BUILD_DIRECTORY}/binutils-gdb/zlib" || { echo "Cannot cd to ${BUILD_DIRECTORY}/binutils-gdb/zlib"; exit 1; }
git clean -fdx
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
/bin/bash ./configure \
--host="$(get_host_triple)" \
--enable-static
make -j4
echo "[+] Finished building zlib ${CURRENT_ARCH}"
}
lib_build_readline(){
fetch "$GIT_READLINE" "${BUILD_DIRECTORY}/readline" git
cd "${BUILD_DIRECTORY}/readline" || { echo "Cannot cd to ${BUILD_DIRECTORY}/readline"; exit 1; }
git clean -fdx
CFLAGS="${GCC_OPTS}" \
CXXFLAGS="${GXX_OPTS}" \
./configure \
--host="$(get_host_triple)" \
--disable-shared \
--enable-static
make -j4
echo "[+] Finished building readline ${CURRENT_ARCH}"
}
lib_build_ncurses(){
fetch "$GIT_NCURSES" "${BUILD_DIRECTORY}/ncurses" git
cd "${BUILD_DIRECTORY}/ncurses" || { echo "Cannot cd to ${BUILD_DIRECTORY}/ncurses"; exit 1; }
git clean -fdx
git checkout v6_2
CMD="CFLAGS=\"${GCC_OPTS}\" "
CMD+="CXXFLAGS=\"${GXX_OPTS}\" "
CMD+="./configure --host=$(get_host_triple) --disable-shared --enable-static"
if [ "$CURRENT_ARCH"!="x86" -a "$CURRENT_ARCH"!="x86_64" ];then
CMD+=" --with-build-cc=/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc"
fi
eval "$CMD"
make -j4
echo "[+] Finished building ncurses ${CURRENT_ARCH}"
}

110
build/targets/build_gdb.sh Executable file
View file

@ -0,0 +1,110 @@
#!/bin/bash
set -e
set -o pipefail
set -x
if [ "$#" -ne 1 ];then
echo "Usage: ${0} [x86|x86_64|armhf|aarch64]"
echo "Example: ${0} x86_64"
exit 1
fi
source $GITHUB_WORKSPACE/build/lib.sh
init_lib $1
build_gdb() {
fetch "$GIT_BINUTILS_GDB" "${BUILD_DIRECTORY}/binutils-gdb" git
cd "${BUILD_DIRECTORY}/binutils-gdb/" || { echo "Cannot cd to ${BUILD_DIRECTORY}/binutils-gdb/"; exit 1; }
git checkout binutils-2_35-branch
#git clean -fdx
cd "${BUILD_DIRECTORY}/binutils-gdb/bfd"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--host="$(get_host_triple)" \
--disable-shared \
--enable-static
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/readline"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--host="$(get_host_triple)" \
--disable-shared \
--enable-static
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/opcodes"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--host="$(get_host_triple)" \
--disable-shared \
--enable-static
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/libiberty"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--host="$(get_host_triple)" \
--disable-shared \
--enable-static
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/libdecnumber"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--host="$(get_host_triple)" \
--disable-shared \
--enable-static
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/zlib"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
/bin/bash ./configure \
--host="$(get_host_triple)" \
--enable-static
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/gdb"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--enable-static=yes \
--host="$(get_host_triple)" \
--disable-interprocess-agent
make -j4
cd "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdbserver"
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
./configure \
--enable-static=yes \
--host="$(get_host_triple)" \
--disable-interprocess-agent
make -j4
strip "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdb" "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdbserver/gdbserver"
}
main() {
build_gdb
if [ ! -f "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdb" -o \
! -f "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdbserver/gdbserver" ];then
echo "[-] Building GDB ${CURRENT_ARCH} failed!"
exit 1
fi
GDB_VERSION=$(get_version "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print \$4}'")
GDBSERVER_VERSION=$(get_version "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print \$4}'")
cp "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdb" "${OUTPUT_DIRECTORY}/gdb${GDB_VERSION}"
cp "${BUILD_DIRECTORY}/binutils-gdb/gdb/gdbserver/gdbserver" "${OUTPUT_DIRECTORY}/gdbserver${GDBSERVER_VERSION}"
echo "[+] Finished building GDB ${CURRENT_ARCH}"
echo ::set-output name=PACKAGED_NAME::"gdb${GDB_VERSION}"
echo ::set-output name=PACKAGED_NAME_PATH::"/output/*"
}
main

70
build/targets/build_nmap.sh Executable file
View file

@ -0,0 +1,70 @@
#!/bin/bash
set -e
set -x
set -o pipefail
if [ "$#" -ne 1 ];then
echo "Usage: ${0} [x86|x86_64|armhf|aarch64]"
echo "Example: ${0} x86_64"
exit 1
fi
source $GITHUB_WORKSPACE/build/lib.sh
init_lib $1
build_nmap() {
fetch "https://github.com/nmap/nmap.git" "${BUILD_DIRECTORY}/nmap" git
cd "${BUILD_DIRECTORY}/nmap"
git clean -fdx || true
# make sure we only build the static libraries
sed -i '/build-zlib: $(ZLIBDIR)\/Makefile/!b;n;c\\t@echo Compiling zlib; cd $(ZLIBDIR) && $(MAKE) static;' "${BUILD_DIRECTORY}/nmap/Makefile.in"
CC='gcc -static -fPIC' \
CXX='g++ -static -static-libstdc++ -fPIC' \
LD=ld \
LDFLAGS="-L/build/openssl" \
./configure \
--host="$(get_host_triple)" \
--without-ndiff \
--without-zenmap \
--without-nmap-update \
--without-libssh2 \
--with-pcap=linux \
--with-openssl="${BUILD_DIRECTORY}/openssl"
sed -i -e "s/shared\: /shared\: #/" "${BUILD_DIRECTORY}/nmap/libpcap/Makefile"
make
strip nmap ncat/ncat nping/nping
}
main() {
lib_build_openssl
build_nmap
if [ ! -f "${BUILD_DIRECTORY}/nmap/nmap" -o \
! -f "${BUILD_DIRECTORY}/nmap/ncat/ncat" -o \
! -f "${BUILD_DIRECTORY}/nmap/nping/nping" ];then
echo "[-] Building Nmap ${CURRENT_ARCH} failed!"
exit 1
fi
VERSION_CMD=$(get_version "${BUILD_DIRECTORY}/nmap/nmap --version")
NMAP_VERSION=$(echo "$VERSION_CMD" | grep "Nmap version" | awk '{print $3}')
if [ -n "$NMAP_VERSION" ];then
NMAP_VERSION="-${NMAP_VERSION}"
fi
cp "${BUILD_DIRECTORY}/nmap/nmap" "${OUTPUT_DIRECTORY}/nmap${NMAP_VERSION}"
cp "${BUILD_DIRECTORY}/nmap/ncat/ncat" "${OUTPUT_DIRECTORY}/ncat${NMAP_VERSION}"
cp "${BUILD_DIRECTORY}/nmap/nping/nping" "${OUTPUT_DIRECTORY}/nping${NMAP_VERSION}"
echo "[+] Finished building Nmap ${CURRENT_ARCH}"
NMAP_COMMIT=$(cd "${BUILD_DIRECTORY}/nmap/" && git rev-parse --short HEAD)
NMAP_DIR="${OUTPUT_DIRECTORY}/nmap-data${NMAP_VERSION}-${NMAP_COMMIT}"
if [ ! -d "$NMAP_DIR" ];then
echo "[-] ${NMAP_DIR} does not exist, creating it"
mkdir -p "${NMAP_DIR}"
fi
if [ -n "$(ls $NMAP_DIR)" ];then
echo "[+] Data directory is not empty"
exit
fi
cd "${BUILD_DIRECTORY}/nmap"
make install
cp -r /usr/local/share/nmap/* $NMAP_DIR
echo "[+] Copied data to Nmap data dir"
}
main

51
build/targets/build_openssh.sh Executable file
View file

@ -0,0 +1,51 @@
#!/bin/bash
set -e
set -x
set -o pipefail
if [ "$#" -ne 1 ];then
echo "Usage: ${0} [x86|x86_64|armhf|aarch64]"
echo "Example: ${0} x86_64"
exit 1
fi
source $GITHUB_WORKSPACE/build/lib.sh
init_lib $1
build_openssh() {
fetch "https://github.com/openssh/openssh-portable.git" "${BUILD_DIRECTORY}/openssh-portable" git
cd "${BUILD_DIRECTORY}/openssh-portable"
git checkout V_7_9
git clean -fdx
autoreconf -i
CC="gcc ${GCC_OPTS}" \
CXX="g++ ${GXX_OPTS}" \
CXXFLAGS="-I${BUILD_DIRECTORY}/openssl -I${BUILD_DIRECTORY}/binutils-gdb/zlib" \
./configure \
--with-ssl-engine \
--with-ssl-dir="${BUILD_DIRECTORY}/openssl" \
--with-zlib="${BUILD_DIRECTORY}/binutils-gdb/zlib" \
--with-ldflags=-static \
--host="$(get_host_triple)"
make -j4
strip ssh sshd
}
main() {
lib_build_openssl
lib_build_zlib
build_openssh
if [ ! -f "${BUILD_DIRECTORY}/openssh-portable/ssh" -o \
! -f "${BUILD_DIRECTORY}/openssh-portable/sshd" ];then
echo "[-] Building OpenSSH ${CURRENT_ARCH} failed!"
exit 1
fi
OPENSSH_VERSION=$(get_version "${BUILD_DIRECTORY}/openssh-portable/ssh -V 2>&1 | awk '{print \$1}' | sed 's/,//g'")
cp "${BUILD_DIRECTORY}/openssh-portable/ssh" "${OUTPUT_DIRECTORY}/ssh${OPENSSH_VERSION}"
cp "${BUILD_DIRECTORY}/openssh-portable/sshd" "${OUTPUT_DIRECTORY}/sshd${OPENSSH_VERSION}"
echo "[+] Finished building OpenSSH ${CURRENT_ARCH}"
OPENSSH_VERSION=$(echo $OPENSSH_VERSION | sed 's/-//')
echo ::set-output name=PACKAGED_NAME::"${OPENSSH_VERSION}"
echo ::set-output name=PACKAGED_NAME_PATH::"/output/*"
}
main

43
build/targets/build_socat.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
set -e
set -x
set -o pipefail
if [ "$#" -ne 1 ];then
echo "Usage: ${0} [x86|x86_64|armhf|aarch64]"
echo "Example: ${0} x86_64"
exit 1
fi
source $GITHUB_WORKSPACE/build/lib.sh
init_lib "$1"
build_socat() {
fetch "http://repo.or.cz/socat.git" "${BUILD_DIRECTORY}/socat" git
cd "${BUILD_DIRECTORY}/socat"
git clean -fdx
autoconf
CFLAGS="${GCC_OPTS}" \
CXXFLAGS="${GXX_OPTS}" \
CPPFLAGS="-I${BUILD_DIRECTORY} -I${BUILD_DIRECTORY}/openssl/include -DNETDB_INTERNAL=-1" \
LDFLAGS="-L${BUILD_DIRECTORY}/readline -L${BUILD_DIRECTORY}/ncurses/lib -L${BUILD_DIRECTORY}/openssl" \
./configure \
--host="$(get_host_triple)"
make -j4
strip socat
}
main() {
#sudo apt install yodl
lib_build_openssl
lib_build_ncurses
lib_build_readline
build_socat
local version
version=$(get_version "${BUILD_DIRECTORY}/socat/socat -V | grep 'socat version' | awk '{print \$3}'")
cp "${BUILD_DIRECTORY}/socat/socat" "${OUTPUT_DIRECTORY}/socat${version}"
echo "[+] Finished building socat ${CURRENT_ARCH}"
echo ::set-output name=PACKAGED_NAME::"socat${version}"
echo ::set-output name=PACKAGED_NAME_PATH::"${OUTPUT_DIRECTORY}/*"
}
main

63
package/targets/nmap/package.sh Executable file
View file

@ -0,0 +1,63 @@
#!/bin/bash
set -x
if [ $# -lt 2 ];then
echo "Usage: ${0} <output directory> <arch>" >&2
echo "Example: ${0} /output x86_64" >&2
exit 2
fi
output_dir=$1
arch=$2
tmp_dir=$(mktemp -dt packaging.XXXXXX)
trap exit_script EXIT TERM
if [ ! -d "$output_dir" ];then
echo "Invalid directory ${output_dir}"
exit 1
fi
exit_script(){
rm -rf "$tmp_dir"
}
echo "tmp_dir: ${tmp_dir}"
version=""
for f in $(ls "$output_dir");do
case "$f" in
nmap-data*)
mv "${output_dir}/${f}" "${tmp_dir}/data"
;;
nmap*)
mv "${output_dir}/${f}" "${tmp_dir}/nmap"
version=${f//nmap-/}
;;
nping*)
mv "${output_dir}/${f}" "${tmp_dir}/nping"
;;
ncat*)
mv "${output_dir}/${f}" "${tmp_dir}/ncat"
;;
*)
echo "This file should not be there: ${output_dir}/${f}"
;;
esac
done
if [ ! -d /packaged ];then
mkdir /packaged
fi
cp $GITHUB_WORKSPACE/package/targets/nmap/run-nmap.sh "$tmp_dir"
cd "$tmp_dir"
TARBALL="nmap-${version}-${arch}-portable.tar.gz"
tar czf "${output}/${TARBALL}" -C "$tmp_dir" .
cp "${output}/${TARBALL}" /packaged
echo ::set-output name=PACKAGED_TARBALL::${TARBALL}
echo ::set-output name=PACKAGED_TARBALL_PATH::"/packaged/${TARBALL}"
ZIP="nmap-${version}-${arch}-portable.zip"
zip -r -q "${output}/${ZIP}" .
cp "${output}/${ZIP}" /packaged
echo ::set-output name=PACKAGED_ZIP::${ZIP}
echo ::set-output name=PACKAGED_ZIP_PATH::"/packaged/${ZIP}"

View file

@ -0,0 +1,3 @@
$allArgs = $PsBoundParameters.Values + $args
$env:NMAPDIR = "data"
.\nmap.exe $allArgs

View file

@ -0,0 +1,4 @@
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
NMAPDIR="$SCRIPT_DIR/data" "$SCRIPT_DIR/nmap" $@