piston/packages/init

65 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2021-03-13 12:14:06 +01:00
#!/usr/bin/env bash
if [[ $# -lt 3 ]]; then
echo "Usage: $0 [name] [version] [source]"
echo ""
echo "Initializes an empty package"
exit 1
fi
NAME=$1
VERSION=$2
SOURCE=$3
DIR=$NAME/$VERSION
mkdir -p $DIR
build_instructions(){
echo 'PREFIX=$(realpath $(dirname $0))'
echo
echo 'mkdir -p build'
echo
echo 'cd build'
echo
echo "curl \"$SOURCE\" -o $NAME.tar.gz"
echo
echo "tar xzf $NAME.tar.gz --strip-components=1"
2021-03-28 21:29:28 +02:00
echo
2021-03-13 12:14:06 +01:00
echo "# === autoconf based ==="
echo './configure --prefix "$PREFIX"'
echo
echo 'make -j$(nproc)'
echo 'make install -j$(nproc)'
echo 'cd ../'
echo 'rm -rf build'
}
cd $DIR
for name in build.sh environment run compile; do
echo "#!/usr/bin/env bash" > "$name"
echo "" >> "$name"
done
echo "# Put instructions to build your package in here" >> build.sh
echo ""
build_instructions >> build.sh
echo "# Put 'export' statements here for environment variables" >> environment
echo "export PATH=\$PWD/bin:\$PATH" >> environment
echo "# Put instructions to run the runtime" >> run
echo "$NAME-$VERSION \"\$@\"" >> run
2021-03-13 12:14:06 +01:00
echo "# Put instructions to compile source code, remove this file if the language does not require this stage" >> compile
2021-03-28 21:29:28 +02:00
jq '.language = "'$NAME'" | .version = "'$VERSION'" | .aliases = []' <<< "{}" > metadata.json
2021-03-13 12:14:06 +01:00
cd - > /dev/null
echo $DIR