Compare commits

...

2 commits

Author SHA1 Message Date
33a0228c9c
0.3.4: bump release version
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
2024-04-12 20:27:47 +03:00
d501843f06
Remove unused HASH_CALCULATION_SH static
It was used in early stages of this project to provide sha256 feature
flag before 0.3.0.

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
2024-03-17 18:17:58 +03:00
5 changed files with 20 additions and 14 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "binhost"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
license = "MIT"
repository = "https://github.com/ivabus/binhost"

View file

@ -1,6 +1,6 @@
[package]
name = "runner"
version = "0.1.0"
version = "0.3.4"
edition = "2021"
[dependencies]
@ -12,7 +12,7 @@ numtoa = "0.2.4"
[profile.release]
strip = true
opt-level = "s"
lto = true
lto = "fat"
panic = "abort"
codegen-units = 1

View file

@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// "Runner" is written in no_std Rust for the smaller executable size: ~49KiB (Darwin arm64) vs ~300KiB
// "Runner" is written in no_std Rust for the smaller executable size: ~49KiB (Darwin arm64)
#![no_main]
#![no_std]
@ -19,7 +19,6 @@ pub unsafe extern "C" fn main(_argc: i32, _argv: *const *const c_char) -> i32 {
printf("Starting runner\n\0".as_bytes().as_ptr() as *const c_char);
let mut buff_public_key = [0_u8; PUBKEY_LEN];
let a = 0;
read(
open("public_key\0".as_bytes().as_ptr() as *const c_char, O_RDONLY),
buff_public_key.as_mut_ptr() as *mut c_void,

View file

@ -72,8 +72,6 @@ static MANIFEST: Lazy<Vec<u8>> = Lazy::new(|| {
});
static WEB_SH: &str = include_str!("../web.sh");
static HASH_CALCULATION_SH: &str = "";
async fn reload_bins(args: &Args) {
let (bins, time) = &mut *BINS.write().await;
if (Instant::now() - *time).as_secs() > args.refresh {
@ -160,7 +158,6 @@ async fn get_script(bin: &str) -> ScriptResponse {
Some(bin) => {
let mut script = String::from(WEB_SH);
script = script
.replace("{{HASH_CALCULATION}}", HASH_CALCULATION_SH)
.replace("{{NAME}}", &bin.name)
.replace("{{PLATFORM_LIST}}", &format_platform_list(bin))
.replace("{{EXTERNAL_ADDRESS}}", &args.url);
@ -224,6 +221,7 @@ async fn rocket() -> _ {
}
let _ = &*BINS.read().await;
let _ = &*MANIFEST;
let figment = Figment::from(rocket::Config::default())
.merge(("ident", "Binhost"))

21
web.sh
View file

@ -23,17 +23,28 @@ requireCommands uname cut dd chmod rm realpath expr
# Finding alternative, but supported sha256sums
SHA256SUM=""
SHASUMFLAGS=""
PLATFORM="$(uname)"
ARCH="$(uname -m)"
if command -v sha256sum > /dev/null 2>&1; then
SHA256SUM="sha256sum"
SHASUMFLAGS="-c hashes --ignore-missing"
else
if command -v sha256 > /dev/null 2>&1; then
SHA256SUM="sha256"
SHASUMFLAGS="-C hashes runner-$PLATFORM-$ARCH"
fi
if command -v shasum > /dev/null 2>&1; then
SHASUMVER=$(shasum -v | cut -c 1)
if [ "$SHASUMVER" -ge 6 ]; then
SHA256SUM="shasum -a 256"
SHASUMFLAGS="-c hashes --ignore-missing"
fi
else
fi
fi
if [ SHA256SUM = "" ]; then
fail "Could not find suitable sha256sum executable"
fi
fi
if [ "$(realpath "$SHA256SUM" 2> /dev/null)" = "/bin/busybox" ]; then
@ -47,8 +58,6 @@ DOWNLOAD_COMMAND="curl"
OUTPUT_ARG="-o"
DIR="/tmp/binhost-$NAME-$(date +%s)"
FILE="$DIR/$NAME"
PLATFORM="$(uname)"
ARCH="$(uname -m)"
if ! command -v curl > /dev/null 2>&1; then
if ! command -v wget > /dev/null 2>&1; then
@ -75,7 +84,7 @@ cd "$DIR"
print ":: Downloading manifest"
$DOWNLOAD_COMMAND $EXTERNAL_ADDRESS/runner/manifest $OUTPUT_ARG manifest
MANIFEST_HASHSUM=$($SHA256SUM manifest)
MANIFEST_HASHSUM=$(cat manifest | $SHA256SUM)
if [ -n "$KEY" ]; then
if [ ! "$KEY" = "$(echo "$MANIFEST_HASHSUM" | cut -c 1-${#KEY})" ]; then
@ -95,7 +104,7 @@ print ":: Downloading runner"
$DOWNLOAD_COMMAND "$EXTERNAL_ADDRESS/runner/runner-$PLATFORM-$ARCH" $OUTPUT_ARG "runner-$PLATFORM-$ARCH"
if ! $SHA256SUM -c hashes --ignore-missing >&2 ; then
if ! $SHA256SUM $SHASUMFLAGS >&2 ; then
fail "Incorrect hashsum of runner"
fi