Page 1 of 1
Bash script to install Pure and Spider Basic (Debian/Ubuntu)
Posted: Thu Apr 20, 2023 7:18 am
by dmontaine
Code: Select all
#!/bin/bash
# this assumes the pure and spider basic tgz
# downloads and this script are in the Downloads directory
# This script is for Debian 11 & 12 and Ubuntu 20.04 or later and derivatives
# Packages are installed in related groups so that those that are not needed
# can be commented out.
#
# 3 Oct 2023 - added checks for existing installs
# - uncapitalized downloads directory
# - and missing install files
# - added additional messages
# - changed to apt-get and routed output to /dev/null
#
# 15 Oct 2023
# - removed routing of apt-get output to /dev/null
# - Disabled ability to run as root user
# - Changed some echo messages
#
#----------------------------------------------------------------------------------------
# Disallow running script as root user
#----------------------------------------------------------------------------------------
#
if [[ $EUID -eq 0 ]]; then
echo "This script must NOT be run as root" 1>&2
exit 1
fi
#
#----------------------------------------------------------------------------------------
# PRE-INSTALLATION TESTS
#----------------------------------------------------------------------------------------
#
echo "Working ..."
#
if test -d ~/Downloads; then
cd ~/Downloads
else
cd ~/downloads
fi
#
if test -d ~/purebasic; then
echo "Pure Basic is already installed"
fi
if ! test -f PureBasic*.tgz; then
echo "No Pure Basic install file available"
fi
if test -d ~/spiderbasic; then
echo "Spider Basic is already installed"
fi
if ! test -f SpiderBasic*.tgz; then
echo "No Spider Basic install file available"
fi
if test -d ~/purebasic && test -d ~/spiderbasic; then
echo "Pure Basic and Spider Basic are already installed"
echo "Nothing to do!"
exit
fi
if ! test -f PureBasic*.tgz && ! test -f SpiderBasic*.tgz; then
echo "Pure Basic and Spider Basic install files missing"
echo "Nothing to do!"
exit
fi
#
#----------------------------------------------------------------------------------------
# MAKE SURE MIME AND APPLICATIONS DIRECTORIES EXIST
#----------------------------------------------------------------------------------------
#
if [ ! -d ~/.local/share/mime/packages ]; then mkdir -p ~/.local/share/mime/packages; fi
if [ ! -d ~/.local/share/applications ]; then mkdir -p ~/.local/share/applications; fi
#
#----------------------------------------------------------------------------------------
# MAKE SURE desktop-file-utils ARE INSTALLED
#----------------------------------------------------------------------------------------
#
sudo apt-get -y install desktop-file-utils
#
#----------------------------------------------------------------------------------------
# PURE BASIC INSTALL
#----------------------------------------------------------------------------------------
#
if test -f PureBasic*.tgz && ! test -d ~/purebasic; then
tar -xf PureBasic*.tgz
mv purebasic ..
cd ../purebasic
#
#----------------------------------------------------------------------------------------
# START OF LIBRARIES and PACKAGES INSTALLATION
#----------------------------------------------------------------------------------------
#
sudo apt-get -y install build-essential gcc g++
sudo apt-get -y install libxxf86vm-dev libxine2-dev unixodbc-dev libsdl1.2-dev libsdl2-dev libssl-dev
sudo apt-get -y install libgtk2.0-dev libgtk-3-dev
sudo apt-get -y install libwebkit2gtk-4.0-dev
#
#----------------------------------------------------------------------------------------
# VLC development libraries
#----------------------------------------------------------------------------------------
#
sudo apt-get -y install libvlc-dev
#
#----------------------------------------------------------------------------------------
# Mesa development libraries
#----------------------------------------------------------------------------------------
#
sudo apt-get -y install libgl1-mesa-dev libgl1-mesa-glx
#
#----------------------------------------------------------------------------------------
# qt5 development libraries
#----------------------------------------------------------------------------------------
#
sudo apt-get -y install qtbase5-dev qttools5-dev qtmultimedia5-dev qtdeclarative5-dev libqt5svg5-dev libqt5webkit5-dev libqt5multimedia5-plugins
#
#----------------------------------------------------------------------------------------
# Other necessary packages
#----------------------------------------------------------------------------------------
#
sudo apt-get -y install libcanberra-gtk-module
#
#----------------------------------------------------------------------------------------
# END OF LIBRARIES and PACKAGES INSTALLATION
#----------------------------------------------------------------------------------------
#
#----------------------------------------------------------------------------------------
# MIME INFO FOR PURE BASIC
#----------------------------------------------------------------------------------------
#
# change to dir for purebasic.xml
cd ~/.local/share/mime/packages
# purebasic.xml create
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > purebasic.xml
echo "<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>" >> purebasic.xml
echo " <mime-type type=\"text/purebasic\">" >> purebasic.xml
echo " <comment>PureBasic source code</comment>" >> purebasic.xml
echo " <glob pattern=\"*.pb\"/>" >> purebasic.xml
echo " <glob pattern=\"*.pbi\"/>" >> purebasic.xml
echo " <glob pattern=\"*.pbf\"/>" >> purebasic.xml
echo " </mime-type>" >> purebasic.xml
echo "</mime-info>" >> purebasic.xml
update-mime-database ~/.local/share/mime
#
#----------------------------------------------------------------------------------------
# Create Pure Basic Desktop File
#----------------------------------------------------------------------------------------
#
# change to dir for PureBasic.desktop
cd ~/.local/share/applications
#
# Create PureBasic.desktop file
echo "[Desktop Entry]" > PureBasic.desktop
echo "Comment=PureBasic IDE" >> PureBasic.desktop
echo "Terminal=false" >> PureBasic.desktop
echo "Name=PureBasic" >> PureBasic.desktop
echo "Type=Application" >> PureBasic.desktop
echo "MimeType=text/purebasic" >> PureBasic.desktop
echo "Categories=Development;" >> PureBasic.desktop
echo "StartupNotify=true" >> PureBasic.desktop
echo "Exec=${HOME}/purebasic/compilers/purebasic" >> PureBasic.desktop
echo "Icon=${HOME}/purebasic/logo.png" >> PureBasic.desktop
update-desktop-database ~/.local/share/applications
if test -d ~/purebasic; then
echo "PureBasic installed"
fi
fi
#
if test -d ~/Downloads; then
cd ~/Downloads
else
cd ~/downloads
fi
#
#----------------------------------------------------------------------------------------
# SPIDER BASIC INSTALL SECTION
#----------------------------------------------------------------------------------------
#
if test -f SpiderBasic*.tgz && ! test -d ~/spiderbasic; then
#
tar -xf SpiderBasic*.tgz
mv spiderbasic ..
#
#----------------------------------------------------------------------------------------
# Create Spider Basic Desktop File
#----------------------------------------------------------------------------------------
#
cd ~/.local/share/applications
# Create SpiderBasic.desktop file
echo "[Desktop Entry]" > SpiderBasic.desktop
echo "Comment=SpiderBasic IDE" >> SpiderBasic.desktop
echo "Terminal=false" >> SpiderBasic.desktop
echo "Name=SpiderBasic" >> SpiderBasic.desktop
echo "Type=Application" >> SpiderBasic.desktop
echo "Categories=Development;" >> SpiderBasic.desktop
echo "StartupNotify=true" >> SpiderBasic.desktop
echo "Exec=${HOME}/spiderbasic/compilers/spiderbasic" >> SpiderBasic.desktop
echo "Icon=${HOME}/spiderbasic/logo.png" >> SpiderBasic.desktop
update-desktop-database ~/.local/share/applications
if test -d ~/spiderbasic; then
echo "SpiderBasic installed"
fi
fi
#
#----------------------------------------------------------------------------------------
# end of script message
#----------------------------------------------------------------------------------------
#
if ! test -d ~/purebasic; then
echo "Pure Basic not installed"
fi
if ! test -d ~/spiderbasic; then
echo "Spider Basic not installed"
fi
#
echo "Pure and Spider Basic install script completed"
Re: Install bash script for Pure and Spider basic (Unbutu based 22.04 and later)
Posted: Fri Apr 21, 2023 9:39 pm
by NicTheQuick
I tried to modify that script a bit. I also wanted to implement arguments so it can be used more dynamically but I was too lazy in the end.
Anyway, here's what I came up with.
Modify the `install_path` if you want to install it somewhere else. You can also set "simulate=true" if you want to simulate the whole process.
Cause I like to install every Purebasic version in its dedicated path I also implemented that behavior in this script. So you can have multiple Purebasic/Spiderbasic versions installed at the same time. However the Desktop link will exist only once.
Code: Select all
#!/bin/bash
simulate=false
script_path="$(dirname "$0")"
archive_path="${1-${script_path}}"
install_path="${HOME}/programme"
mime_path="${HOME}/.local/share/mime/packages"
dependencies=(
build-essential
gcc
g++
libxxf86vm-dev
libxine2-dev
unixodbc-dev
libsdl1.2-dev
libsdl2-dev
libssl-dev
libgtk2.0-dev
libgtk-3-dev
libwebkit2gtk-4.0-dev
libvlc-dev
libgl1-mesa-dev
libgl1-mesa-glx
qtbase5-dev
qttools5-dev
qtmultimedia5-dev
qtdeclarative5-dev
libqt5svg5-dev
libqt5webkit5-dev
libqt5multimedia5-plugins
libcanberra-gtk-module
)
function echo::msg() {
if $simulate; then
echo "$@" "(dry-run)"
else
echo "$@"
fi
}
function echo::err() {
local msg="$1"
echo -e "\e[31m${msg}\e[0m" >&2
}
function echo::h1() {
echo -ne "\n\e[1m## \e[93;1m"
echo::msg -e "$@" "\e[0m"
}
function echo::h2() {
echo -ne "\e[1m# \e[92;1m"
echo::msg -e "$@" "\e[0m"
}
function echo::dot() {
echo -ne "\e[1m > \e[33;1m"
echo -e "$@" "\e[0m"
}
echo::h1 "Scanning path '${archive_path}'"
# Find latest archive according to timestamp
latest_pb_archive="$(find "${archive_path}" -maxdepth 1 -iname "purebasic*.tgz" -printf "%T@\t%p\0" | sort -zg | cut -zf2 | tail -zn1 | tr -d '\0')"
latest_sb_archive="$(find "${archive_path}" -maxdepth 1 -iname "spiderbasic*.tgz" -printf "%T@\t%p\0" | sort -zg | cut -zf2 | tail -zn1 | tr -d '\0')"
is_pb=false
is_sb=false
if [ -n "${latest_pb_archive}" ]; then
echo::dot "${latest_pb_archive}"
is_pb=true
fi
if [ -n "${latest_sb_archive}" ]; then
echo::dot "${latest_sb_archive}"
is_sb=true
fi
function extract::archive() {
local archive="$1"
#local tmp_dir="$(mktemp -dp "${install_path}")"
local tmp_dir="$(mktemp -d)"
tar -xf "${archive}" --strip-components=1 -C "${tmp_dir}" 1>&2
echo "${tmp_dir}"
}
function extract::version() {
local spb_path="$1"
if [ -x "${spb_path}/compilers/pbcompiler" ]; then
"${spb_path}/compilers/pbcompiler" --version | grep -oiE "^purebasic( [^ (]+)+"
return 0
fi
if [ -x "${spb_path}/compilers/sbcompiler" ]; then
"${spb_path}/compilers/sbcompiler" --version | grep -oiE "^spiderbasic( [^ (]+)+"
return 0
fi
return 1
}
function pb::install::mime() {
local mime_file="${mime_path}/purebasic.xml"
echo::dot "${mime_file}"
if $simulate; then
return 0
fi
mkdir -p "${mime_path}"
tee "${mime_file}" > /dev/null <<EOT
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/purebasic">
<comment>PureBasic source code</comment>
<glob pattern="*.pb"/>
<glob pattern="*.pbi"/>
<glob pattern="*.pbp"/>
<glob pattern="*.pbf"/>
</mime-type>
</mime-info>
EOT
}
function sb::install::mime() {
local mime_file="${mime_path}/spiderbasic.xml"
echo::dot "${mime_file}"
if $simulate; then
return 0
fi
mkdir -p "${mime_path}"
tee "${mime_file}" > /dev/null <<EOT
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="text/spiderbasic">
<comment>Spiderbasic source code</comment>
<glob pattern="*.sb"/>
<glob pattern="*.sbi"/>
<glob pattern="*.sbp"/>
<glob pattern="*.sbf"/>
</mime-type>
</mime-info>
EOT
}
echo::h1 "Extract archives temporarily"
# Extract archives
if $is_pb; then
tmp_pb_dir="$(extract::archive "${latest_pb_archive}")"
echo::dot "${latest_pb_archive} --> ${tmp_pb_dir}"
fi
if $is_sb; then
tmp_sb_dir="$(extract::archive "${latest_sb_archive}")"
echo::dot "${latest_sb_archive} --> ${tmp_sb_dir}"
fi
echo::h1 "Show version"
if $is_pb; then
pb_version="$(extract::version "${tmp_pb_dir}")"
echo::dot "${pb_version}"
fi
if $is_sb; then
sb_version="$(extract::version "${tmp_sb_dir}")"
echo::dot "${sb_version}"
fi
echo::h1 "Check target path"
if $is_pb; then
pb_install_path="${install_path}/$(sed 's/ /_/g' <<< "${pb_version}")"
if [ -d "${pb_install_path}" ]; then
echo::err "Path already exists: ${pb_install_path}"
exit 1
else
echo::dot "Installation path: ${pb_install_path}"
fi
fi
if $is_sb; then
sb_install_path="${install_path}/$(sed 's/ /_/g' <<< "${sb_version}")"
if [ -d "${sb_install_path}" ]; then
echo::err "Path already exists: ${sb_install_path}"
exit 1
else
echo::dot "Installation path: ${sb_install_path}"
fi
fi
echo ""
read -rp "Install Purebasic/Spiderbasic to these directories? [y/N]" yesNo
if ! [[ "$yesNo" =~ y|Y ]]; then
rm -rf "${tmp_pb_dir}" "${tmp_sb_dir}"
exit 0
fi
echo::h1 "Installation"
echo::h2 "Move extracted archive to correct path"
if $is_pb; then
echo::dot "${tmp_pb_dir} -> ${pb_install_path}"
if ! $simulate; then
mv "${tmp_pb_dir}" "${pb_install_path}"
fi
fi
if $is_sb; then
echo::dot "${tmp_sb_dir} -> ${sb_install_path}"
if ! $simulate; then
mv "${tmp_sb_dir}" "${sb_install_path}"
fi
fi
echo::h2 "Install dependencies"
if $simulate; then
apt install --simulate "${dependencies[@]}"
else
sudo apt install "${dependencies[@]}"
fi
echo::h2 "Install MIME type"
pb::install::mime
sb::install::mime
echo::h2 "Install Shortcut"
if ! $simulate; then
if $is_pb; then
mkdir -p "${HOME}/.local/share/applications"
tee "${HOME}/.local/share/applications/Purebasic.desktop" > /dev/null <<EOT
[Desktop Entry]
Comment=PureBasic IDE
Terminal=false
Name=${pb_version}
Type=Application
MimeType=text/purebasic
Categories=Development;
StartupNotify=true
Exec=${pb_install_path}/compilers/purebasic
Icon=${pb_install_path}/logo.png
EOT
fi
if $is_sb; then
mkdir -p "${HOME}/.local/share/applications"
tee "${HOME}/.local/share/applications/Spiderbasic.desktop" > /dev/null <<EOT
[Desktop Entry]
Comment=SpiderBasic IDE
Terminal=false
Name=${sb_version}
Type=Application
MimeType=text/spiderbasic
Categories=Development;
StartupNotify=true
Exec=${sb_install_path}/compilers/spiderbasic
Icon=${sb_install_path}/logo.png
EOT
fi
update-desktop-database ~/.local/share/applications
update-mime-database ~/.local/share/mime
fi
This is an example output:
Code: Select all
## Scanning path '.'
> ./PureBasic_Linux2_beta_X64_6.01_(r7yarj).tgz
> ./spiderbasic-free_2_x64.tgz
## Extract archives temporarily
> ./PureBasic_Linux2_beta_X64_6.01_(r7yarj).tgz --> /tmp/tmp.Ie9ychXOMN
> ./spiderbasic-free_2_x64.tgz --> /tmp/tmp.CEJOkrLHEB
## Show version
> PureBasic 6.01 LTS beta 4
> SpiderBasic 2.40
## Check target path
> Installation path: /home/nicolas/programme/PureBasic_6.01_LTS_beta_4
> Installation path: /home/nicolas/programme/SpiderBasic_2.40
Install Purebasic/Spiderbasic to these directories? [y/N]y
## Installation
# Move extracted archive to correct path
> /tmp/tmp.Ie9ychXOMN -> /home/nicolas/programme/PureBasic_6.01_LTS_beta_4
> /tmp/tmp.CEJOkrLHEB -> /home/nicolas/programme/SpiderBasic_2.40
# Install dependencies
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
build-essential ist schon die neueste Version (12.9ubuntu3).
g++ ist schon die neueste Version (4:11.2.0-1ubuntu1).
gcc ist schon die neueste Version (4:11.2.0-1ubuntu1).
libxxf86vm-dev ist schon die neueste Version (1:1.1.4-1build3).
unixodbc-dev ist schon die neueste Version (2.3.9-5).
libcanberra-gtk-module ist schon die neueste Version (0.30-10ubuntu1).
libgtk2.0-dev ist schon die neueste Version (2.24.33-2ubuntu2).
libqt5multimedia5-plugins ist schon die neueste Version (5.15.3-1).
libqt5svg5-dev ist schon die neueste Version (5.15.3-1).
libqt5webkit5-dev ist schon die neueste Version (5.212.0~alpha4-15ubuntu1).
libsdl1.2-dev ist schon die neueste Version (1.2.15+dfsg2-6).
libvlc-dev ist schon die neueste Version (3.0.16-1build7).
libxine2-dev ist schon die neueste Version (1.2.11-2).
qtdeclarative5-dev ist schon die neueste Version (5.15.3+dfsg-1).
qtmultimedia5-dev ist schon die neueste Version (5.15.3-1).
qttools5-dev ist schon die neueste Version (5.15.3-1).
libgl1-mesa-dev ist schon die neueste Version (22.2.5-0ubuntu0.1~22.04.1).
libgtk-3-dev ist schon die neueste Version (3.24.33-1ubuntu2).
libssl-dev ist schon die neueste Version (3.0.2-0ubuntu1.8).
libwebkit2gtk-4.0-dev ist schon die neueste Version (2.38.5-0ubuntu0.22.04.1).
libgl1-mesa-glx ist schon die neueste Version (22.2.5-0ubuntu0.1~22.04.1).
libsdl2-dev ist schon die neueste Version (2.0.20+dfsg-2ubuntu1.22.04.1).
qtbase5-dev ist schon die neueste Version (5.15.3+dfsg-2ubuntu0.2).
Die folgenden Pakete wurden automatisch installiert und werden nicht mehr benötigt:
liblc3-0 libstd-rust-1.61 libtinycompress-dev xserver-xorg-video-amdgpu
Verwenden Sie »sudo apt autoremove«, um sie zu entfernen.
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 11 nicht aktualisiert.
# Install MIME type
> /home/nicolas/.local/share/mime/packages/purebasic.xml
> /home/nicolas/.local/share/mime/packages/spiderbasic.xml
# Install Shortcut
I may will create an updated version for that.
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Mon Sep 11, 2023 5:37 am
by dmontaine
Original script updated Sep 10 2023
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Fri Sep 15, 2023 7:25 am
by Jeromyal
This is nice. I used it to install both on Mint 21.2
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Sat Sep 30, 2023 7:31 am
by dmontaine
Original script updated Sep 30 2023
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Sat Sep 30, 2023 1:44 pm
by NicTheQuick
dmontaine wrote: Sat Sep 30, 2023 7:31 am
Original script updated Sep 30 2023
What did you change?
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Sun Oct 01, 2023 5:37 pm
by dmontaine
Just added additional comments and moved creation of the mime and applications directories into their own section. Didn't change any functionality, just made the script look better. Since users might want to comment out sections they don't need, I tried to organize and document what each section does.
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Mon Oct 02, 2023 9:31 pm
by Quin
This is really cool, well done!
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Tue Oct 03, 2023 5:03 pm
by dmontaine
Script updated 3 Oct 2023
# 3 Oct 2023 - added checks for existing installs
# - added check for uncapitalized downloads directory
# - and missing install files
# - added additional messages
# - changed to apt-get and routed output to null
Re: Bash script to install Pure and Spider basic (Unbutu based 22.04 and later and Debian 12)
Posted: Sun Oct 15, 2023 6:25 pm
by dmontaine
Script updated 15 Oct 2023
# - removed routing of apt-get output to /dev/null
# - Disabled ability to run as root user
# - Changed some echo messages
Re: Bash script to install Pure and Spider Basic (Debian/Ubuntu)
Posted: Tue Oct 17, 2023 1:39 pm
by Jeromyal
@ dmontaine,
Questions.
Why did you omit mime generation for SpiderBasic?
Did you forget file type .pbp for PureBasic, or is it not suppose to be added? I see that Fantaisie Software didn't add it to there register .sh either. So I just wonder if you are in the know as to why and could clue me in.
Re: Bash script to install Pure and Spider Basic (Debian/Ubuntu)
Posted: Wed Oct 18, 2023 4:41 am
by dmontaine
I just aggregated and restructured the scripts provided for Pure and Spider Basic. I did not add anything functionally to the scripts other than the checks for the existence of files and directories. If there are additional installs or configuration beyond what was provided in the install scripts and directions provided by the authors of those compilers that I used as the source material for my bash script, then you need to take it up with them.
Re: Bash script to install Pure and Spider Basic (Debian/Ubuntu)
Posted: Wed Oct 18, 2023 9:49 am
by NicTheQuick
Jeromyal wrote: Tue Oct 17, 2023 1:39 pm
@ dmontaine,
Questions.
Why did you omit mime generation for SpiderBasic?
Did you forget file type .pbp for PureBasic, or is it not suppose to be added? I see that Fantaisie Software didn't add it to there register .sh either. So I just wonder if you are in the know as to why and could clue me in.
You can also use my script. It does a bit more than the default one and also registers all file extensions for Purebasic and Spiderbasic.