rustmon/build/debian/debian.sh

59 lines
1.3 KiB
Bash
Raw Normal View History

2024-03-25 03:28:53 +08:00
#!/bin/sh
2024-03-25 22:48:30 +08:00
# get the script location
SCRIPT_DIR=$(dirname "$0")
# Variables
2024-03-25 15:35:00 +08:00
PKG_NAME=rustmon
2024-03-25 22:48:30 +08:00
BUILD_DIR=$SCRIPT_DIR/build/debian
RELEASE_DIR=$SCRIPT_DIR/../../target/release
DEBIAN_DIR=$BUILD_DIR/$PKG_NAME/DEBIAN
BIN_DIR=$BUILD_DIR/$PKG_NAME/usr/bin
2024-03-25 15:35:00 +08:00
AUTO_INSTALL=${1:-"no"}
2024-03-25 12:52:40 +08:00
2024-03-25 15:35:00 +08:00
# check for rust
if ! command -v rustc &> /dev/null
then
if [ "$AUTO_INSTALL" = "-y" ]; then
echo "Rust is not installed. Auto-installing..."
sudo apt install rustc
source $HOME/.cargo/env
else
echo "Rust is not installed. Would you like to install it now? (yes/no)"
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
2024-03-25 15:36:17 +08:00
sudo apt install rustc
2024-03-25 15:35:00 +08:00
source $HOME/.cargo/env
else
echo "Rust is required to continue. Exiting."
exit 1
fi
fi
fi
2024-03-25 03:28:53 +08:00
2024-03-25 15:35:00 +08:00
# create directory structure
mkdir -p $DEBIAN_DIR
mkdir -p $BIN_DIR
# Bbild the executable
2024-03-25 03:28:53 +08:00
cd ../..
cargo build --release
2024-03-25 15:35:00 +08:00
cd $BUILD_DIR
2024-03-25 03:28:53 +08:00
# copy the executable
2024-03-25 15:35:00 +08:00
cp $RELEASE_DIR/$PKG_NAME $BIN_DIR/
2024-03-25 03:28:53 +08:00
# create the control file
2024-03-25 15:35:00 +08:00
touch $DEBIAN_DIR/control
2024-03-25 03:28:53 +08:00
# edit the control file
2024-03-25 15:35:00 +08:00
echo "Package: $PKG_NAME
2024-03-25 03:28:53 +08:00
Version: 1.0.0
Section: base
Priority: optional
Architecture: amd64
Maintainer: Vomitblood <tohyouxuan@gmail.com>
2024-03-25 15:35:00 +08:00
Description: Pokemon Colorscripts written in Rust" > $DEBIAN_DIR/control
2024-03-25 03:28:53 +08:00
2024-03-25 15:35:00 +08:00
# build the package
dpkg-deb --build $PKG_NAME