about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/deploy-chroot.sh28
-rwxr-xr-xscripts/deploy-local.sh15
-rwxr-xr-xscripts/deploy.sh24
-rw-r--r--scripts/include/mirrorlist30
-rw-r--r--scripts/include/pacman.conf104
-rwxr-xr-xscripts/mkdeps36
-rwxr-xr-xscripts/nuget-to-nix.sh88
-rwxr-xr-xscripts/reset-submodules.sh9
8 files changed, 334 insertions, 0 deletions
diff --git a/scripts/deploy-chroot.sh b/scripts/deploy-chroot.sh
new file mode 100755
index 0000000..f5c7394
--- /dev/null
+++ b/scripts/deploy-chroot.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+#  if [ -f "/tmp/mru-build/dev/null" ]; then sudo umount /tmp/mru-build/dev || exit 1; fi
+#  if [ -f "/tmp/mru-build/proc/uptime" ]; then sudo umount /tmp/mru-build/proc || exit 1; fi
+#  if [ -d "/tmp/mru-build/sys/power" ]; then sudo umount /tmp/mru-build/sys || exit 1; fi
+#  sudo rm -rf /tmp/mru-build
+#  mkdir /tmp/mru-build
+#  
+#  # ARCH
+#  #sudo pacstrap -C ./pacman.conf -c -G -M -P /tmp/mru-build  dotnet-sdk aspnet-runtime busybox kitty-terminfo
+#  #sudo arch-chroot /tmp/mru-build sh -c 'for i in `busybox --list-full`; do busybox ln /bin/busybox /$i; done'
+#  
+#  # DEBIAN 
+#  sudo debootstrap stable /tmp/mru-build http://deb.debian.org/debian
+#  sudo arch-chroot /tmp/mru-build bash --login -c 'apt update; apt upgrade -y; apt install -y curl'
+#  sudo arch-chroot /tmp/mru-build bash --login -c 'curl https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb; echo $PATH; dpkg -i packages-microsoft-prod.deb; rm packages-microsoft-prod.deb'
+#  sudo arch-chroot /tmp/mru-build bash --login -c 'apt update; apt upgrade -y; apt install -y dotnet-sdk-8.0'
+
+
+#git clone --recursive .git /tmp/mru-build/tmp
+sudo rm -rf /tmp/mru-build/build/
+cp ./ /tmp/mru-build/build/ -r
+#sudo arch-chroot /tmp/mru-build bash --login -c 'ping nuget.org -c 4'
+sudo arch-chroot /tmp/mru-build bash --login -c 'cd /build; dotnet restore -v:n'
+sudo arch-chroot /tmp/mru-build bash --login -c 'cd /build; dotnet clean --r -v:n'
+#sudo arch-chroot /tmp/mru-build sh -c 'cd /build; dotnet build -v d'
+
+echo "-- End of script! --"
\ No newline at end of file
diff --git a/scripts/deploy-local.sh b/scripts/deploy-local.sh
new file mode 100755
index 0000000..a030a21
--- /dev/null
+++ b/scripts/deploy-local.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+ssh 192.168.0.13 "bash -xc 'sudo rm -rf /tmp/mru-build'"
+ssh 192.168.0.13 "bash -xc 'sudo mkdir /tmp/mru-build'"
+ssh 192.168.0.13 "bash -xc 'sudo chown \`basename \$PWD\`: /tmp/mru-build'"
+rsync -raP ./ 192.168.0.13:/tmp/mru-build
+ssh 192.168.0.13 "sh -c 'cd /tmp/mru-build/MatrixRoomUtils.Web; dotnet clean --r -v:n'"
+#ssh 192.168.0.13 "sh -c 'cd /tmp/mru-build/MatrixRoomUtils.Web; dotnet build -c Release'"
+ssh 192.168.0.13 "sh -c 'cd /tmp/mru-build/MatrixRoomUtils.Web; dotnet publish -c Release'"
+rsync -raP 192.168.0.13:/tmp/mru-build/MatrixRoomUtils.Web/bin/Release/net8.0/publish/wwwroot/ /tmp/mru-wwwroot --delete
+rsync -raP /tmp/mru-wwwroot/ rory.gay:/data/nginx/html_mru --delete
+ssh rory.gay chmod o+r /data/nginx/html_mru -Rc
+ssh rory.gay sudo find /data/nginx/html_mru -type d -exec chmod o+rx {} +
+
+echo "-- End of script! --"
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
new file mode 100755
index 0000000..df79ace
--- /dev/null
+++ b/scripts/deploy.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+if [[ -z $(git status -s) ]]
+then
+  echo "tree is clean"
+else
+  echo "tree is dirty, please commit changes before running this"
+#  exit
+fi
+
+BASE_DIR=`pwd`
+rm -rf **/bin/Release
+cd MatrixRoomUtils.Web
+dotnet publish -c Release
+rsync -raP bin/Release/net8.0/publish/wwwroot/ rory.gay:/data/nginx/html_mru/
+cd bin/Release/net8.0/publish/wwwroot
+tar cf - ./ | xz -z -9 - > $BASE_DIR/MRU-BIN.tar.xz
+#rsync -raP $BASE_DIR/MRU-BIN.tar.xz rory.gay:/data/nginx/html_mru/MRU-BIN.tar.xz
+rm -rf $BASE_DIR/MRU-BIN.tar.xz
+cd $BASE_DIR
+git clone .git -b `git branch --show-current` src --recursive
+rm -rf src/.git
+tar cf - src/ | xz -z -9 - > MRU-SRC.tar.xz
+rsync -raP $BASE_DIR/MRU-SRC.tar.xz rory.gay:/data/nginx/html_mru/MRU-SRC.tar.xz
+rm -rf src/
diff --git a/scripts/include/mirrorlist b/scripts/include/mirrorlist
new file mode 100644
index 0000000..2929fbc
--- /dev/null
+++ b/scripts/include/mirrorlist
@@ -0,0 +1,30 @@
+################################################################################
+################# Arch Linux mirrorlist generated by Reflector #################
+################################################################################
+
+# With:       reflector @/etc/xdg/reflector/reflector.conf
+# When:       2021-07-23 10:41:38 UTC
+# From:       https://www.archlinux.org/mirrors/status/json/
+# Retrieved:  2021-07-23 10:40:59 UTC
+# Last Check: 2021-07-23 09:53:23 UTC
+
+Server = https://mirror.osbeck.com/archlinux/$repo/os/$arch
+Server = https://archmirror.it/repos/$repo/os/$arch
+Server = https://mirror.pkgbuild.com/$repo/os/$arch
+Server = https://europe.mirror.pkgbuild.com/$repo/os/$arch
+Server = https://mirror.chaoticum.net/arch/$repo/os/$arch
+Server = https://ftp.rnl.tecnico.ulisboa.pt/pub/archlinux/$repo/os/$arch
+Server = https://mirror.pseudoform.org/$repo/os/$arch
+Server = https://mirror.f4st.host/archlinux/$repo/os/$arch
+Server = https://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch
+Server = https://mirror.telepoint.bg/archlinux/$repo/os/$arch
+Server = https://phinau.de/arch/$repo/os/$arch
+Server = https://arch.mirror.constant.com/$repo/os/$arch
+Server = https://archlinux.thaller.ws/$repo/os/$arch
+Server = https://arch.mirror.square-r00t.net/$repo/os/$arch
+Server = https://mirror.lty.me/archlinux/$repo/os/$arch
+Server = https://archmirror1.octyl.net/$repo/os/$arch
+Server = https://archlinux.uk.mirror.allworldit.com/archlinux/$repo/os/$arch
+Server = https://america.mirror.pkgbuild.com/$repo/os/$arch
+Server = https://archlinux.za.mirror.allworldit.com/archlinux/$repo/os/$arch
+Server = https://asia.mirror.pkgbuild.com/$repo/os/$arch
diff --git a/scripts/include/pacman.conf b/scripts/include/pacman.conf
new file mode 100644
index 0000000..8f2650c
--- /dev/null
+++ b/scripts/include/pacman.conf
@@ -0,0 +1,104 @@
+#
+# /etc/pacman.conf
+#
+# See the pacman.conf(5) manpage for option and repository directives
+
+#
+# GENERAL OPTIONS
+#
+[options]
+# The following paths are commented out with their default values listed.
+# If you wish to use different paths, uncomment and update the paths.
+#RootDir     = /
+#DBPath      = /var/lib/pacman/
+CacheDir    = /tmp/
+#LogFile     = /var/log/pacman.log
+#GPGDir      = ./gnupg/
+#HookDir     = ./hooks/
+#HoldPkg     = pacman glibc
+#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
+#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
+#CleanMethod = KeepInstalled
+Architecture = auto
+
+# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
+#IgnorePkg   =
+#IgnoreGroup =
+
+#NoUpgrade   =
+#NoExtract   =
+
+# Misc options
+#UseSyslog
+Color
+#NoProgressBar
+CheckSpace
+#VerbosePkgLists
+ParallelDownloads = 32
+ILoveCandy
+
+# By default, pacman accepts packages signed by keys that its local keyring
+# trusts (see pacman-key and its man page), as well as unsigned packages.
+#SigLevel    = Required DatabaseOptional
+SigLevel = Never
+LocalFileSigLevel = Never
+RemoteFileSigLevel = Never
+
+# NOTE: You must run `pacman-key --init` before first using pacman; the local
+# keyring can then be populated with the keys of all official Arch Linux
+# packagers with `pacman-key --populate archlinux`.
+
+#
+# REPOSITORIES
+#   - can be defined here or included from another file
+#   - pacman will search repositories in the order defined here
+#   - local/custom mirrors can be added here or in separate files
+#   - repositories listed first will take precedence when packages
+#     have identical names, regardless of version number
+#   - URLs will have $repo replaced by the name of the current repo
+#   - URLs will have $arch replaced by the name of the architecture
+#
+# Repository entries are of the format:
+#       [repo-name]
+#       Server = ServerName
+#       Include = IncludePath
+#
+# The header [repo-name] is crucial - it must be present and
+# uncommented to enable the repo.
+#
+
+# The testing repositories are disabled by default. To enable, uncomment the
+# repo name header and Include lines. You can add preferred servers immediately
+# after the header, and they will be used before the default mirrors.
+
+#[testing]
+#Include = ./mirrorlist
+
+[core]
+#Include = ./mirrorlist
+Server = https://mirror.pkgbuild.com/$repo/os/$arch
+
+[extra]
+#Include = ./mirrorlist
+Server = https://mirror.pkgbuild.com/$repo/os/$arch
+
+#[community-testing]
+#Include = ./mirrorlist
+
+#[community]
+#Include = ./mirrorlist
+
+# If you want to run 32 bit applications on your x86_64 system,
+# enable the multilib repositories as required here.
+
+#[multilib-testing]
+#Include = ./mirrorlist
+
+#[multilib]
+#Include = ./mirrorlist
+
+# An example of a custom package repository.  See the pacman manpage for
+# tips on creating your own repositories.
+#[custom]
+#SigLevel = Optional TrustAll
+#Server = file:///home/custompkgs
diff --git a/scripts/mkdeps b/scripts/mkdeps
new file mode 100755
index 0000000..ccb1370
--- /dev/null
+++ b/scripts/mkdeps
@@ -0,0 +1,36 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i "bash -x" -p bash nuget-to-nix git dotnet-sdk_8 nix curl jq yq
+projects=(
+  MatrixRoomUtils.Web
+)
+
+find . | grep -E '(bin|obj)$' | while read -r d; do rm -rf "$d" & done
+wait
+
+execDir=$(pwd)
+
+for p in $projects
+do
+  (
+    set -euo pipefail
+    cd "$p" || exit
+    pwd
+    MSBUILDLIVELOGGER=false dotnet restore --packages=packages -v n --ucr || exit 1
+
+    #for blazor: https://globalcdn.nuget.org/packages/microsoft.netcore.app.runtime.mono.browser-wasm.7.0.10.nupkg
+#    if [ -f wwwroot/index.html ]; then
+#      curl -L https://globalcdn.nuget.org/packages/microsoft.netcore.app.runtime.mono.browser-wasm.7.0.10.nupkg -o Microsoft.NETCore.App.Runtime.Mono.browser-wasm.7.0.10.nupkg
+#      mkdir -p packages/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/7.0.10
+#      unzip -d packages/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/7.0.10 Microsoft.NETCore.App.Runtime.Mono.browser-wasm.7.0.10.nupkg
+#      rm Microsoft.NETCore.App.Runtime.Mono.browser-wasm.7.0.10.nupkg
+#    fi
+
+    "${execDir}"/nuget-to-nix.sh packages | tee deps.nix
+    pwd
+    du -sh packages
+    rm -rf packages
+    git add deps.nix
+  )
+  nix flake update
+  git add flake.lock
+done
diff --git a/scripts/nuget-to-nix.sh b/scripts/nuget-to-nix.sh
new file mode 100755
index 0000000..7aa35fb
--- /dev/null
+++ b/scripts/nuget-to-nix.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+#patched version of nuget-to-nix to inherit env
+
+set -euo pipefail
+shopt -s nullglob
+
+#export PATH="@binPath@"
+# used for glob ordering of package names
+export LC_ALL=C
+
+if [ $# -eq 0 ]; then
+  >&2 echo "Usage: $0 <packages directory> [path to a file with a list of excluded packages] > deps.nix"
+  exit 1
+fi
+
+pkgs=$1
+tmp=$(realpath "$(mktemp -td nuget-to-nix.XXXXXX)")
+trap 'rm -r "$tmp"' EXIT
+
+excluded_list=$(realpath "${2:-/dev/null}")
+
+export DOTNET_NOLOGO=1
+export DOTNET_CLI_TELEMETRY_OPTOUT=1
+
+mapfile -t sources < <(dotnet nuget list source --format short | awk '/^E / { print $2 }')
+
+declare -A base_addresses
+
+for index in "${sources[@]}"; do
+  base_addresses[$index]=$(
+    curl --compressed --netrc -fsL "$index" | \
+      jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"')
+done
+
+echo "{ fetchNuGet }: ["
+
+cd "$pkgs"
+for package in *; do
+  cd "$package"
+  for version in *; do
+    id=$(xq -r .package.metadata.id "$version/$package".nuspec)
+
+    if grep -qxF "$id.$version.nupkg" "$excluded_list"; then
+      continue
+    fi
+
+    used_source="$(jq -r '.source' "$version"/.nupkg.metadata)"
+    for source in "${sources[@]}"; do
+      url="${base_addresses[$source]}$package/$version/$package.$version.nupkg"
+      if [[ "$source" == "$used_source" ]]; then
+        sha256="$(nix-hash --type sha256 --flat --base32 "$version/$package.$version".nupkg)"
+        found=true
+        break
+      else
+        if sha256=$(nix-prefetch-url "$url" 2>"$tmp"/error); then
+          # If multiple remote sources are enabled, nuget will try them all
+          # concurrently and use the one that responds first. We always use the
+          # first source that has the package.
+          echo "$package $version is available at $url, but was restored from $used_source" 1>&2
+          found=true
+          break
+        else
+          if ! grep -q 'HTTP error 404' "$tmp/error"; then
+            cat "$tmp/error" 1>&2
+            exit 1
+          fi
+        fi
+      fi
+    done
+
+    if ! ${found-false}; then
+      echo "couldn't find $package $version" >&2
+      exit 1
+    fi
+
+    if [[ "$source" != https://api.nuget.org/v3/index.json ]]; then
+      echo "  (fetchNuGet { pname = \"$id\"; version = \"$version\"; sha256 = \"$sha256\"; url = \"$url\"; })"
+    else
+      echo "  (fetchNuGet { pname = \"$id\"; version = \"$version\"; sha256 = \"$sha256\"; })"
+    fi
+  done
+  cd ..
+done
+
+cat << EOL
+]
+EOL
diff --git a/scripts/reset-submodules.sh b/scripts/reset-submodules.sh
new file mode 100755
index 0000000..60f2267
--- /dev/null
+++ b/scripts/reset-submodules.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+find . -type d | grep --invert '\.git' | while read dir
+do
+    (
+        (git -C $dir submodule init 2>/dev/null) \
+        && (git -C $dir submodule update 2>/dev/null)
+    ) || echo $dir does not contain submodules
+done