mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
Install scripts:
- Windows: - install: Move repo URI into variable Remove -NoWinget check (was unused) - upgrade: Change -NoWinget to disable updating with winget (can take a while) Create function to check install of node packages which are put on Path. - Linux: - Install: Port install-windows to some linux distros Support for Apt (Ubuntu, possibly Debian/Mint) Support for Pacman (Arch/Manjaro/Garuda) - Upgrade: Port upgrade-windows to some linux distros
This commit is contained in:
parent
0634a90f58
commit
e8afacef18
60
setup-development/linux/install-linux.sh
Normal file
60
setup-development/linux/install-linux.sh
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#* linux-install.sh: First-run setup script
|
||||||
|
#* Ensures git is installed, clones the repo, and then runs
|
||||||
|
|
||||||
|
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
|
ELEVATE='';if (( $UID != 0 )); then ELEVATE='sudo';fi
|
||||||
|
|
||||||
|
help () {
|
||||||
|
echo "Usage: $0 [-g path/to/git/directory]"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GITDIR = "~/git"
|
||||||
|
|
||||||
|
# Get option flags:
|
||||||
|
dry=false
|
||||||
|
while getopts ghd arg; do
|
||||||
|
case $arg in
|
||||||
|
g) GITDIR="$OPTARG";;
|
||||||
|
h) help;;
|
||||||
|
d) dry=true;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
function dryrun {
|
||||||
|
if $dry; then
|
||||||
|
echo "> $* [dry]";
|
||||||
|
else
|
||||||
|
echo "> $*"
|
||||||
|
$@
|
||||||
|
}
|
||||||
|
|
||||||
|
SETUPDIR= "Mind_Reader/setup-development"
|
||||||
|
REPOURI = "https://github.com/We-Dont-Byte/Mind_Reader.git"
|
||||||
|
|
||||||
|
# Install git
|
||||||
|
if which git; then
|
||||||
|
echo "Git already installed."
|
||||||
|
elif which pacman; then
|
||||||
|
# using pacman
|
||||||
|
dryrun $ELEVATE pacman -Sy git
|
||||||
|
elif which apt; then
|
||||||
|
# using apt
|
||||||
|
dryrun $ELEVATE apt-get update && \
|
||||||
|
dryrun $ELEVATE apt-get install git -y
|
||||||
|
fi #? TODO: other package managers?
|
||||||
|
|
||||||
|
echo Cloning repository into "$GITDIR"
|
||||||
|
dryrun mkdir "$GITDIR"
|
||||||
|
cd $GITDIR && git clone "$REPOURI"
|
||||||
|
|
||||||
|
# TODO: remove this when merging!
|
||||||
|
cd Mind_Reader
|
||||||
|
dryrun git checkout origin/johnBreaux
|
||||||
|
# TODO: remove this when merging!
|
||||||
|
|
||||||
|
cd "$GITDIR/$SETUPDIR"
|
||||||
|
bash ./linux-update.sh
|
@ -0,0 +1,4 @@
|
|||||||
|
apt-transport-https
|
||||||
|
build-essential
|
||||||
|
python3
|
||||||
|
wget
|
@ -0,0 +1,5 @@
|
|||||||
|
base-devel
|
||||||
|
code
|
||||||
|
git
|
||||||
|
nvm
|
||||||
|
python3
|
100
setup-development/linux/upgrade-linux.sh
Normal file
100
setup-development/linux/upgrade-linux.sh
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#* linux-update.sh: Install and update dependencies of Mind_Reader, on linux.
|
||||||
|
#* Heads-up, this expects to be run from Mind_Reader/setup-development/linux.
|
||||||
|
|
||||||
|
|
||||||
|
# If run with bash -vx, print useful information instead of just a + sign
|
||||||
|
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
|
# If run as root, it could be because sudo isn't installed (some people disagree with sudo, especially on Arch)
|
||||||
|
ELEVATE='';if (( $UID != 0 )); then;ELEVATE='sudo';fi
|
||||||
|
|
||||||
|
# Get option flags:
|
||||||
|
dry=false
|
||||||
|
while getopts d arg; do
|
||||||
|
case $arg in
|
||||||
|
d) dry=true;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
function dryrun {
|
||||||
|
if $dry; then
|
||||||
|
echo "> $* [dry]";
|
||||||
|
else
|
||||||
|
echo "> $*"
|
||||||
|
$@
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set these variables if you need to install for a different architecture
|
||||||
|
# Valid architectures are "x64", "arm64", "armhf"
|
||||||
|
arch=""
|
||||||
|
case (uname -i) in
|
||||||
|
"x86_64") arch="x64";;
|
||||||
|
"armv[6-8]*") arch="armhf";;
|
||||||
|
"aarch64") arch="arm64";;
|
||||||
|
*) echo "Architecture '$(uname -i)' unknown. Assuming x86_64..."
|
||||||
|
arch="x64";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if which pacman; then
|
||||||
|
# Install dependencies with pacman
|
||||||
|
dryrun $ELEVATE pacman -S - < package-managers/pacman.dependencies
|
||||||
|
elif which apt-get; then
|
||||||
|
# Install dependencies using apt-get
|
||||||
|
dryrun xargs -a ./package-managers/apt.dependencies $ELEVATE apt-get install -y
|
||||||
|
|
||||||
|
# Install Node Version Manager (nvm)
|
||||||
|
# TODO: Find a better way to install nvm on Ubuntu, the official NodeJS for <20.04 is so out of date it's unsupported.
|
||||||
|
dryrun curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
|
||||||
|
|
||||||
|
# Check if vscode exists, if not, install it.
|
||||||
|
# Microsoft doesn't put it in any Ubuntu repos, you have to get it straight from them.
|
||||||
|
# This does have the side effect, however, of installing the official repository
|
||||||
|
if !(which code); then
|
||||||
|
#* Install VSCode
|
||||||
|
vscodepackagename="code_amd64.deb"
|
||||||
|
dryrun wget "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-$arch" -O ./code.deb
|
||||||
|
dryrun $ELEVATE apt install ./code.deb
|
||||||
|
dryrun rm ./code.deb
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cdir=$(pwd)
|
||||||
|
# Go back to source tree root
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Check the VSCode version
|
||||||
|
nodeversion="node"
|
||||||
|
electronversion = ""
|
||||||
|
#* Note:
|
||||||
|
#* When adding support for new VSCode versions, update this case
|
||||||
|
#* By the time you're working on this project, things are likely going to differ!
|
||||||
|
case (code --version) in
|
||||||
|
#* Each version of VSCode has a corresponding Electron version and Node version
|
||||||
|
#* These are used when
|
||||||
|
1.66.*) electronversion = "17.2.0"; nodeversion = "16.13.0";;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Install NodeJS and npm
|
||||||
|
dryrun nvm install "$nodeversion"
|
||||||
|
dryrun nvm use "$nodeversion"
|
||||||
|
|
||||||
|
# Use npm to install electron-rebuild and yo
|
||||||
|
dryrun npm install electron-rebuild yo generator-code
|
||||||
|
|
||||||
|
# use npm to acquire dependencies for Mind-Reader
|
||||||
|
dryrun npm install
|
||||||
|
|
||||||
|
# Use electron-rebuild to rebuild electron
|
||||||
|
if (( electronversion != "" )); then
|
||||||
|
dryrun electron-rebuild --version $electronversion
|
||||||
|
else
|
||||||
|
printf "%s/n%s/n%s/n%s/n" \
|
||||||
|
"Open Visual Studio Code, select the 'Help' tab in the toolbar, and go to 'About'." \
|
||||||
|
"Find the line that says 'Electron: [electron version]'" \
|
||||||
|
"Run the command below, filling in the Electron version with the one from that menu:" \
|
||||||
|
"electron-rebuild --version [electron version]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $cdir
|
@ -56,6 +56,7 @@ param (
|
|||||||
[switch]$DryRun # Run script without installing
|
[switch]$DryRun # Run script without installing
|
||||||
)
|
)
|
||||||
|
|
||||||
|
$RepoURI = "https://github.com/We-Dont-Byte/Mind_Reader.git"
|
||||||
$RepoPath = "$GitDir\Mind_Reader"
|
$RepoPath = "$GitDir\Mind_Reader"
|
||||||
$SetupPath = "$RepoPath\setup-development\windows"
|
$SetupPath = "$RepoPath\setup-development\windows"
|
||||||
|
|
||||||
@ -98,8 +99,8 @@ function Reload-Path {
|
|||||||
|
|
||||||
|
|
||||||
# Check if Winget is available
|
# Check if Winget is available
|
||||||
if ( $NoWinget -or -not (Command-Available winget) ) {
|
if ( -not (Command-Available winget) ) {
|
||||||
Write-Warning "[ Warning ]: It looks like winget isn't available.`n"
|
Write-Warning "It looks like winget isn't available.`n"
|
||||||
Write-Host "Update 'App Installer' through the Microsoft Store, or grab the '.msixbundle' from the winget-cli repository:"
|
Write-Host "Update 'App Installer' through the Microsoft Store, or grab the '.msixbundle' from the winget-cli repository:"
|
||||||
Write-Host "( https://github.com/microsoft/winget-cli/releases/latest )`n" -ForegroundColor White
|
Write-Host "( https://github.com/microsoft/winget-cli/releases/latest )`n" -ForegroundColor White
|
||||||
exit
|
exit
|
||||||
@ -148,12 +149,13 @@ if ( -not (Test-Path "$GitDir") ) {
|
|||||||
# Clone the repository in GitDir
|
# Clone the repository in GitDir
|
||||||
$dir = $pwd
|
$dir = $pwd
|
||||||
cd $GitDir
|
cd $GitDir
|
||||||
Dry-Run "git clone 'https://github.com/We-Dont-Byte/Mind_Reader.git'"
|
Dry-Run "git clone '$RepoURI'"
|
||||||
# TODO: Change this during merge onto main branch
|
|
||||||
|
# TODO: Remove this when merging
|
||||||
cd Mind_reader
|
cd Mind_reader
|
||||||
Dry-Run "git checkout johnBreaux"
|
Dry-Run "git checkout johnBreaux"
|
||||||
cd ..
|
cd ..
|
||||||
# END TODO
|
# TODO: Remove this when merging
|
||||||
|
|
||||||
# Run the install script
|
# Run the install script
|
||||||
if ( -not (Test-Path "$SetupPath")) {
|
if ( -not (Test-Path "$SetupPath")) {
|
||||||
|
@ -52,7 +52,7 @@ param (
|
|||||||
[switch]$NoPrompt, # Disable the 3-second wait and press-any-key prompt
|
[switch]$NoPrompt, # Disable the 3-second wait and press-any-key prompt
|
||||||
[switch]$Install, # Perform all installations, even when commands are present
|
[switch]$Install, # Perform all installations, even when commands are present
|
||||||
[switch]$DryRun, # Run script without installing
|
[switch]$DryRun, # Run script without installing
|
||||||
[switch]$NoWinget # Pretend Winget doesn't exist
|
[switch]$NoWinget # Don't update dependdencies with winget
|
||||||
)
|
)
|
||||||
|
|
||||||
# .description
|
# .description
|
||||||
@ -89,8 +89,8 @@ function Reload-Path {
|
|||||||
|
|
||||||
|
|
||||||
# Check if Winget is available
|
# Check if Winget is available
|
||||||
if ( $NoWinget -or -not (Command-Available winget) ) {
|
if ( -not (Command-Available winget) ) {
|
||||||
Write-Warning "[ Warning ]: It looks like winget isn't available.`n"
|
Write-Warning "It looks like winget isn't available.`n"
|
||||||
Write-Host "Update 'App Installer' through the Microsoft Store, or grab the '.msixbundle' from the winget-cli repository:"
|
Write-Host "Update 'App Installer' through the Microsoft Store, or grab the '.msixbundle' from the winget-cli repository:"
|
||||||
Write-Host "( https://github.com/microsoft/winget-cli/releases/latest )`n" -ForegroundColor White
|
Write-Host "( https://github.com/microsoft/winget-cli/releases/latest )`n" -ForegroundColor White
|
||||||
exit
|
exit
|
||||||
@ -121,11 +121,13 @@ if ( ([Security.Principal.WindowsIdentity]::GetCurrent().Groups -contains 'S-1-5
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Import the packages from dependencies.json (autogenerated file, do not edit!)
|
# Import the packages from dependencies.json (autogenerated file, do not edit!)
|
||||||
|
if ( -not $NoWinget) {
|
||||||
Write-Host "`nInstalling packages with winget..."
|
Write-Host "`nInstalling packages with winget..."
|
||||||
Dry-Run 'winget install Microsoft.VisualStudio.2022.BuildTools --override "--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"'
|
Dry-Run 'winget install Microsoft.VisualStudio.2022.BuildTools --override "--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"'
|
||||||
Dry-Run 'winget import winget/dependencies.json'
|
Dry-Run "winget import winget/dependencies.json"
|
||||||
# Reload the PATH, so we can use some of those sweet new commands we just installed
|
# Reload the PATH, so we can use some of those sweet new commands we just installed
|
||||||
Reload-Path
|
Reload-Path
|
||||||
|
}
|
||||||
|
|
||||||
# Check whether everything is available now:
|
# Check whether everything is available now:
|
||||||
$error = 0
|
$error = 0
|
||||||
@ -140,17 +142,32 @@ if ( -not (Command-Available npm ) ) {
|
|||||||
}
|
}
|
||||||
if ( $error ) { exit }
|
if ( $error ) { exit }
|
||||||
|
|
||||||
# Check if electron-rebuild is installed, if not, install it
|
# .description
|
||||||
if ( ($Install) -or -not (Command-Available electron-rebuild) ) {
|
# EnsureNodePackageInstalled:
|
||||||
Write-Host "`nInstalling Electron-Rebuild..."
|
# Checks for the presence of a cmdlet with a given name
|
||||||
Dry-Run 'npm install -g electron-rebuild'
|
# If it's not found, attempt to install it using npm
|
||||||
|
# If it's still not found, abort (this may not be good behavior?)
|
||||||
|
function EnsureNodePackageInstalled {
|
||||||
|
param (
|
||||||
|
[string[]]$command
|
||||||
|
)
|
||||||
|
if ( ($Install) -or -not (Command-Available $command[0]) ) {
|
||||||
|
Write-Host "`nInstalling $($command[0])..."
|
||||||
|
Dry-Run "npm install -g $([string]$command)"
|
||||||
Reload-Path
|
Reload-Path
|
||||||
if ( -not (Command-Available electron-rebuild)) {
|
if ( -not (Command-Available $command[0])) {
|
||||||
Throw "electron-rebuild failed to install. Aborting."
|
Throw "$command failed to install. Aborting."
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "`nElectron-Rebuild already installed." -ForegroundColor green
|
Write-Host "`n$($command[0]) already installed." -ForegroundColor green
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if electron-rebuild is installed, if not, install it
|
||||||
|
EnsureNodePackageInstalled electron-rebuild
|
||||||
|
|
||||||
|
# These are useful (but not necessary) packages to have installed when working on new VSCode extensions
|
||||||
|
EnsureNodePackageInstalled yo, generator-code
|
||||||
|
|
||||||
# We're about to do some path traversal, so save the current directory
|
# We're about to do some path traversal, so save the current directory
|
||||||
$prev_directory = $pwd
|
$prev_directory = $pwd
|
||||||
@ -158,7 +175,10 @@ $prev_directory = $pwd
|
|||||||
# install NodeJS dependencies for this extension
|
# install NodeJS dependencies for this extension
|
||||||
Write-Host "`nInstalling NodeJS Dependencies..."
|
Write-Host "`nInstalling NodeJS Dependencies..."
|
||||||
cd ..\..
|
cd ..\..
|
||||||
Dry-Run 'npm install'
|
Dry-Run "npm install"
|
||||||
|
|
||||||
|
# Run npm audit fix to upgrade vulnerable dependencies, except breaking changes.
|
||||||
|
Dry-Run "npm audit fix"
|
||||||
|
|
||||||
# if we're on a known VSCode version, go ahead and run electron-rebuild
|
# if we're on a known VSCode version, go ahead and run electron-rebuild
|
||||||
switch -Regex (code --version) {
|
switch -Regex (code --version) {
|
||||||
|
Loading…
Reference in New Issue
Block a user