From 5fc7252ece731a0640e5a090971e79db9e0755d2 Mon Sep 17 00:00:00 2001 From: Anas Sheashaey Date: Sat, 6 Jan 2024 01:48:11 +0200 Subject: [PATCH 1/5] Add boilerplate in scripts/install/tesseract_5_install.sh --- scripts/install/tesseract_5_install.sh | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/scripts/install/tesseract_5_install.sh b/scripts/install/tesseract_5_install.sh index 18c90e69..19902ff5 100644 --- a/scripts/install/tesseract_5_install.sh +++ b/scripts/install/tesseract_5_install.sh @@ -1,5 +1,6 @@ #!/bin/bash +install_debian() { sudo apt-get install apt-transport-https echo "deb https://notesalexp.org/tesseract-ocr5/$(lsb_release -cs)/ $(lsb_release -cs) main" \ | sudo tee /etc/apt/sources.list.d/notesalexp.list > /dev/null @@ -7,3 +8,45 @@ sudo apt-get update -oAcquire::AllowInsecureRepositories=true sudo apt-get install notesalexp-keyring -oAcquire::AllowInsecureRepositories=true sudo apt-get update sudo apt-get install tesseract-ocr +} + +install_fedora() { + echo "Automatic install not implemented yet on this distribution (Fedora)" +} + +install_arch() { + echo "Automatic install not implemented yet on this distribution (Arch Linux)" +} + +install_mac() { + echo "Automatic install not implemented yet on this distribution (macOS)" +} + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + if [[ -f /etc/os-release ]]; then + . /etc/os-release + case $ID in + debian|ubuntu|linuxmint) + install_debian + ;; + fedora) + install_fedora + ;; + arch|manjaro) + install_arch + ;; + *) + echo "Unsupported Linux distribution: $ID" + exit 1 + ;; + esac + else + echo "Cannot determine the Linux distribution" + exit 1 + fi +elif [[ "$OSTYPE" == "darwin"* ]]; then + install_mac +else + echo "Unsupported Operating System: $OSTYPE" + exit 1 +fi From 36d00cd8659b6808d0ac4f04e66ecc0ae1d081cb Mon Sep 17 00:00:00 2001 From: Anas Sheashaey Date: Sat, 6 Jan 2024 01:53:25 +0200 Subject: [PATCH 2/5] Explain code in scripts/install/tesseract_5_install.sh --- scripts/install/tesseract_5_install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/install/tesseract_5_install.sh b/scripts/install/tesseract_5_install.sh index 19902ff5..aa4046b3 100644 --- a/scripts/install/tesseract_5_install.sh +++ b/scripts/install/tesseract_5_install.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Functions to install Tesseract on Debian-based systems install_debian() { sudo apt-get install apt-transport-https echo "deb https://notesalexp.org/tesseract-ocr5/$(lsb_release -cs)/ $(lsb_release -cs) main" \ @@ -10,18 +11,23 @@ sudo apt-get update sudo apt-get install tesseract-ocr } +# Functions to install Tesseract on Fedora-based systems install_fedora() { echo "Automatic install not implemented yet on this distribution (Fedora)" } +# Functions to install Tesseract on Arch-based systems install_arch() { echo "Automatic install not implemented yet on this distribution (Arch Linux)" } +# Functions to install Tesseract on macOS install_mac() { echo "Automatic install not implemented yet on this distribution (macOS)" } +# Main "Function" +# Detecting the Operating System and calling the respective install function if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [[ -f /etc/os-release ]]; then . /etc/os-release From 52fd35520014c430cf8e2b6f6eb7af8aa6415917 Mon Sep 17 00:00:00 2001 From: Anas Sheashaey Date: Sat, 6 Jan 2024 02:16:45 +0200 Subject: [PATCH 3/5] Implement system-specific functions --- scripts/install/tesseract_5_install.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/install/tesseract_5_install.sh b/scripts/install/tesseract_5_install.sh index aa4046b3..f70765b0 100644 --- a/scripts/install/tesseract_5_install.sh +++ b/scripts/install/tesseract_5_install.sh @@ -1,6 +1,7 @@ #!/bin/bash # Functions to install Tesseract on Debian-based systems +# Will this function work on linux-mint, ubuntu and debian? install_debian() { sudo apt-get install apt-transport-https echo "deb https://notesalexp.org/tesseract-ocr5/$(lsb_release -cs)/ $(lsb_release -cs) main" \ @@ -12,18 +13,33 @@ sudo apt-get install tesseract-ocr } # Functions to install Tesseract on Fedora-based systems +# DELETE THIS LINE WHEN YOU TEST THIS ON FEDORA. I DIDN'T!!! install_fedora() { - echo "Automatic install not implemented yet on this distribution (Fedora)" + sudo dnf install tesseract } # Functions to install Tesseract on Arch-based systems +# Tested on Archlinux, Not Manjaro. install_arch() { - echo "Automatic install not implemented yet on this distribution (Arch Linux)" + sudo pacman -S tesseract tesseract-data-eng } # Functions to install Tesseract on macOS +# DELETE THIS LINE WHEN YOU TEST THIS ON MAC. I DIDN'T!!! install_mac() { - echo "Automatic install not implemented yet on this distribution (macOS)" + if ! command -v brew &> /dev/null; + then + echo "Homebrew is not installed." + read -r -p "Do you want to install Homebrew? (y/n) " choice + + case "$choice" in + y|Y ) echo "Now I should run an install script for Homebrew. I am not implemented yet.";; + n|N ) echo "Exiting. Please install Homebrew and re-run the script." + exit 1;; + * ) echo "Invalid choice. Exiting. Please install Homebrew and re-run the script." + exit 1;; + esac + fi } # Main "Function" From c7d9f4bfae5a296bdf925252ef1b52e3e27ac29c Mon Sep 17 00:00:00 2001 From: Anas Sheashaey Date: Sat, 6 Jan 2024 02:19:57 +0200 Subject: [PATCH 4/5] Install homebrew when you need to. --- scripts/install/tesseract_5_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/tesseract_5_install.sh b/scripts/install/tesseract_5_install.sh index f70765b0..cba9469f 100644 --- a/scripts/install/tesseract_5_install.sh +++ b/scripts/install/tesseract_5_install.sh @@ -33,7 +33,7 @@ install_mac() { read -r -p "Do you want to install Homebrew? (y/n) " choice case "$choice" in - y|Y ) echo "Now I should run an install script for Homebrew. I am not implemented yet.";; + y|Y ) /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)";; n|N ) echo "Exiting. Please install Homebrew and re-run the script." exit 1;; * ) echo "Invalid choice. Exiting. Please install Homebrew and re-run the script." From 6c368db86626a61d5214f9345e7dfeeccaa8c0cc Mon Sep 17 00:00:00 2001 From: Anas Sheashaey Date: Sat, 6 Jan 2024 02:24:37 +0200 Subject: [PATCH 5/5] Actually install tesseract on mac. --- scripts/install/tesseract_5_install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install/tesseract_5_install.sh b/scripts/install/tesseract_5_install.sh index cba9469f..1a47014d 100644 --- a/scripts/install/tesseract_5_install.sh +++ b/scripts/install/tesseract_5_install.sh @@ -40,6 +40,9 @@ install_mac() { exit 1;; esac fi + + #install tesseract + brew install tesseract } # Main "Function"