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

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" $@