Repository navigation
Expand file tree
/
Copy path0setup
More file actions
executable file
·133 lines (118 loc) · 4.61 KB
/
Copy path0setup
File metadata and controls
executable file
·133 lines (118 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# Slackware script to setup the 0 scripts environment
# Copyright 2025-2026 Antonio Leal, Porto Salvo, Oeiras, Portugal
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
clear
if ! [ -f "$HOME/.config/0scriptsrc" ]; then
install -Dm644 /usr/share/0scripts/0scriptsrc "$HOME/.config/0scriptsrc"
else
read -p "Do you with to overwrite $HOME/.config/0scriptsrc with the default? (y/N) " op
if [ "$op" = "y" ] || [ "$op" = "Y" ]; then
install -Dm644 /usr/share/0scripts/0scriptsrc "$HOME/.config/0scriptsrc"
echo "installed new $HOME/.config/0scriptsrc"
fi
fi
source "$HOME/.config/0scriptsrc"
echo
set -e
if [ "$(id -u)" == "0" ]; then
echo "This script cannot be run as root" 1>&2
exit 1
fi
deploy()
{ # the parameters are: $1="category" $2="package name" $3="slackbuild extension"
AUX=$(ls /var/log/packages/ -1 | grep $2)
if [ "$AUX" = "" ]; then
mkdir -p /tmp/0
cd /tmp/0
wget https://slackbuilds.org/slackbuilds/15.0/$1/$2.$3
tar xvf $2.$3
cd $2
source $2.info
set +e
wget $DOWNLOAD
wget $DOWNLOAD_x86_64
set -e
./$2.SlackBuild
PKG=`ls -1 /tmp/$2*.t?z | sort -r | head -1`
upgradepkg --install-new --reinstall $PKG
else
echo "$2 is already installed."
fi
}
FUNC=$(declare -f deploy)
echo "Checking missing dependencies:"
su - -c "
rm -rf /tmp/0
$FUNC
deploy development github-cli tar.gz
deploy system sbo-maintainer-tools tar.gz
deploy system jq tar.gz
deploy development meld tar.gz
deploy desktop xarchiver tar.gz
"
echo
echo "Installing the workspace environment in $HOME/slackware-builds by"
echo "cloning your 'myslackbuilds' and 'slackbuilds' fork from github.com:"
mkdir -p $HOME/slackware-builds
cd $HOME/slackware-builds
read -p "Please type your github username: " ghuser
read -p "Please copy-paste your github account (classic) token: " ghtoken
AUX=$(curl -s https://api.github.com/repos/${ghuser}/myslackbuilds | jq '.id')
if [ "$AUX" = "null" ]; then
echo
echo "https://api.github.com/repos/${ghuser}/myslackbuilds does not exist."
echo "Make sure a (classic) token is also exists for your http://github.com account."
echo "Aborting."
exit
fi
AUX=$(curl -s https://api.github.com/repos/${ghuser}/slackbuilds | jq '.id')
if [ "$AUX" = "null" ]; then
echo
echo "https://api.github.com/repos/${ghuser}/slackbuilds fork does not exist."
echo "Login into you http://github.com account and create a fork of https://github.com/SlackBuildsOrg/slackbuilds"
echo "Make sure a (classic) token is also exists for your http://github.com account."
echo "Aborting."
exit
fi
echo
if [ -d "$HOME/slackware-builds/myslackbuilds" ]; then
echo "$HOME/slackware-builds/myslackbuilds directory already exists. Skipping git cloning."
else
git clone https://${ghuser}:${ghtoken}@github.com/${ghuser}/myslackbuilds.git
fi
echo
if [ -d "$HOME/slackware-builds/slackbuilds" ]; then
echo "$HOME/slackware-builds/slackbuilds directory already exists. Skipping git cloning."
else
git clone https://${ghuser}:${ghtoken}@github.com/${ghuser}/slackbuilds.git
fi
# Install the plus42 example
echo
read -p "do you with to install the plus42 calculator example in $HOME/slackware-builds/myslackbuilds/academic/plus42? (y/N) " op
if [ "$op" = "y" ] || [ "$op" = "Y" ]; then
mkdir -p "$HOME/slackware-builds/myslackbuilds/academic"
tar -xvf /usr/share/0scripts/plus42.tar.gz -C "$HOME/slackware-builds/myslackbuilds/academic/"
fi
echo
echo
echo "Done."
echo "You should now adapt the file $HOME/.config/0scriptsrc"
echo