From c5111b3482bd867e13b1d835c9779765dff73d4f Mon Sep 17 00:00:00 2001 From: gennyble Date: Thu, 23 Nov 2023 14:15:40 -0600 Subject: init :) --- cutrel.sh | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++ git-mailmap-history | 2 + git-new-repo | 31 ++++++++++++++ git-new-section | 28 +++++++++++++ git-set-desc | 11 +++++ git-unique-comitters | 2 + 6 files changed, 186 insertions(+) create mode 100755 cutrel.sh create mode 100755 git-mailmap-history create mode 100755 git-new-repo create mode 100755 git-new-section create mode 100755 git-set-desc create mode 100755 git-unique-comitters diff --git a/cutrel.sh b/cutrel.sh new file mode 100755 index 0000000..83e613e --- /dev/null +++ b/cutrel.sh @@ -0,0 +1,112 @@ +#!/usr/local/bin/fish +# +# A very messy script for making building Rust programs for +# various platforms and then stuffing them into archives + +set cargocmd cargo metadata --format-version 1 --no-deps +set packageCount ($cargocmd | jq '.packages | length') + +set package $argv[1] +if test $packageCount -gt 1 -a -z "$argv[1]" + echo "Multiple packages in workspace, but none provided!" + echo "What package do I build for?" + exit +else if test $packageCount -eq 1 -a -z "$argv[1]" + set parsedPackage ($cargocmd | jq --raw-output '.packages[0].name') + set package $parsedPackage +end + +set packageVersion ($cargocmd | jq --raw-output '.packages[] | select(.name == "'$package'") | .version') + +echo "building for $package version $packageVersion" + +set target ($cargocmd | jq --raw-output '.target_directory') +set workroot ($cargocmd | jq --raw-output '.workspace_root') +set temp $target/cutrel/working +set done $target/cutrel +set license $workroot/LICENSE + +echo "target=$target" +echo "" + +if test ! -e $license + echo "!! No license file in root!" + #exit +end + +mkdir -p $done +mkdir -p $temp + +function build -a triple outName + set windows false + echo $triple | grep windows &>/dev/null + if test $status -eq 0 + echo "Windows detected, using xwin!" + set windows true + end + + set final "$done/$package-v$packageVersion""_""$outName.tar.gz" + if test $windows = true + set final "$done/$package-v$packageVersion""_""$outName.zip" + end + + echo "window = $windows | final = $final" + if test -e $final + echo "Skipping $outName, already exists!" + return + end + + set thisWork $temp/$packageVersion-$outName + set thisTarName $package-$packageVersion + set thisTar $thisWork/$thisTarName + + echo "building for $outName..." + + set buildCmd cargo build + if test $windows = true + set buildCmd cargo xwin build + end + + $buildCmd --release --target $triple &>/dev/null + if test $status -ne 0 + echo "!! ERROR building for $outName ($triple)" + echo "!! Run the command below for more information" + echo "!! \$ cargo build --release --target $triple" + exit + else + echo "Build for $outName successful, compressing" + end + + rm -rf $thisWork + mkdir -p $thisTar + + cp $license $thisTar/LICENSE + if test $windows = true + cp $target/$triple/release/$package.exe $thisTar/ + else + cp $target/$triple/release/$package $thisTar/ + end + set wasAtDir (pwd) + + cd $thisWork + + if test $windows = true + zip -r $final $thisTarName &>/dev/null + else + tar -czf $final $thisTarName &>/dev/null + end + + if test $status -ne 0 + echo "compressing failed!" + exit + end + cd $wasAtDir +end + +build x86_64-unknown-linux-gnu linux-x64 +build aarch64-unknown-linux-gnu linux-aarch64 +build x86_64-apple-darwin macos-x64 +build aarch64-apple-darwin macos-aarch64 +build x86_64-pc-windows-msvc windows-x64 + +rm -rf $temp diff --git a/git-mailmap-history b/git-mailmap-history new file mode 100755 index 0000000..f280abb --- /dev/null +++ b/git-mailmap-history @@ -0,0 +1,2 @@ +#!/usr/local/bin/fish +git filter-repo --mailmap ~/.ssh/mailmap $argv diff --git a/git-new-repo b/git-new-repo new file mode 100755 index 0000000..ef5fead --- /dev/null +++ b/git-new-repo @@ -0,0 +1,31 @@ +#! /usr/bin/env bash +# +# usage: +# git new-repo section/repo-name +# +# example: +# git new-repo fonts/scientifica +# creates: user@remote:fonts/scientifica +# +# script written by Akshay and seen on +# +# and gently modified by me +# (added the echo and got carried away with colour) + +HOST=gen@quartet +CGIT_ROOT=git + +if [ $# -eq 0 ]; then + echo "requires an arg" + exit 1 +fi + +IBlack="\033[0;90m" +White="\033[0;37m" +Yellow="\033[0;33m" +Reset="\033[0m" + +echo -en "${IBlack}" +ssh $HOST git init --bare "$CGIT_ROOT/$1"; +echo -e "${White}Add it as remote 'origin' with the command" +echo -e "${IBlack}$ ${Yellow}git remote add origin ${HOST}:$CGIT_ROOT/$1${Reset}" diff --git a/git-new-section b/git-new-section new file mode 100755 index 0000000..d276f43 --- /dev/null +++ b/git-new-section @@ -0,0 +1,28 @@ +#! /usr/bin/env bash +# +# usage: +# git new-section section +# +# example: +# git new-section games +# creates: user@remote:games/ +# +# modified from a script by Akshay on +# + +HOST=gen@quartet +CGIT_ROOT=git + +if [ $# -eq 0 ]; then + echo "requires an arg" + exit 1 +fi + +IBlack="\033[0;90m" +White="\033[0;37m" +Yellow="\033[0;33m" +Reset="\033[0m" + +echo -en "${IBlack}" +ssh $HOST mkdir "$CGIT_ROOT/$1"; +echo -e "${White}section '$1' created" diff --git a/git-set-desc b/git-set-desc new file mode 100755 index 0000000..bb35695 --- /dev/null +++ b/git-set-desc @@ -0,0 +1,11 @@ +#! /usr/bin/env bash +# +# usage: +# enter repo description into .git/description and run: +# git set-desc +# +# script written by Akshay and seen on +# + +remote=$(git remote get-url --push origin) +scp .git/description "$remote/description" \ No newline at end of file diff --git a/git-unique-comitters b/git-unique-comitters new file mode 100755 index 0000000..0bd8834 --- /dev/null +++ b/git-unique-comitters @@ -0,0 +1,2 @@ +#!/usr/local/bin/fish +git log --format="%an <%ae>" | sort -u -- cgit 1.4.1-3-g733a5