This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
sbb
executable file
·605 lines (525 loc) · 21.1 KB
/
sbb
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
#!/bin/sh
# _____ ____ ____
# / ___// __ )/ __ )
# \__ \/ __ / __ |
# ___/ / /_/ / /_/ /
# /____/_____/_____/
# File: sbb
# Description: Dotfiles-manager framework that SuperB
# Main author: NNB
# └─ https://github.com/NNBnh
# URL: https://github.com/NNBnh/superb-bootstrap
# License: GPLv3
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Values
WD="${WD:-$PWD}"
TMPDIR="${TMPDIR:-/tmp}"
TEMPORARY="$TMPDIR/sbb"; mkdir -p "$TEMPORARY"
if [ -x "$(command -v sudo)" ]; then
PERMISSION_COMMAND='sudo'
elif [ -x "$(command -v doas)" ]; then
PERMISSION_COMMAND='doas'
elif [ -x "$(command -v termux-setup-storage)" ]; then
PACKAGEMANAGER_MAIN='Termux'
else
printf '\n\033[1;7;31m%s\033[0m\n' "Permission command not found or unsupported" >&2
exit 1
fi
APK_MARK='APK'; APK_PM='apk' ; APK_COMMAND="$PERMISSION_COMMAND $APT_PM add"
APT_MARK='APT'; APT_PM='apt' ; APT_COMMAND="$PERMISSION_COMMAND $APT_PM install --assume-yes"
DNF_MARK='DNF'; DNF_PM='dnf' ; DNF_COMMAND="$PERMISSION_COMMAND $DNF_PM install --assumeyes"
EOPKG_MARK='EOP'; EOPKG_PM='eopkg' ; EOPKG_COMMAND="$PERMISSION_COMMAND $EOPKG_PM install --yes-all"
Mports_MARK='MPT'; Mports_PM='mports' ; Mports_COMMAND="$PERMISSION_COMMAND $Mports_PM install"
OpenBSD_MARK='OBP'; OpenBSD_PM='pkg_add' ; OpenBSD_COMMAND="$PERMISSION_COMMAND $OpenBSD_PM -I"
Pacman_MARK='PAC'; Pacman_PM='pacman' ; Pacman_COMMAND="$PERMISSION_COMMAND $Pacman_PM --sync --noconfirm --needed"
Portage_MARK='PTG'; Portage_PM='emerge' ; Portage_COMMAND="$PERMISSION_COMMAND $Portage_PM"
PKGIN_MARK='PIN'; PKGIN_PM='pkgin' ; PKGIN_COMMAND="$PERMISSION_COMMAND $PKGIN_PM install -y"
PKGNG_MARK='PNG'; PKGNG_PM='pkg' ; PKGNG_COMMAND="$PERMISSION_COMMAND $PKGNG_PM install -y"
Slackpkg_MARK='SLK'; Slackpkg_PM='slackpkg' ; Slackpkg_COMMAND="$PERMISSION_COMMAND $Slackpkg_PM install"
Termux_MARK='TMP'; Termux_PM='pkg' ; Termux_COMMAND="$Termux_PM install --assume-yes"
URPMI_MARK='URP'; URPMI_PM='urpmi' ; URPMI_COMMAND="$PERMISSION_COMMAND $URPMI_PM --force"
XBPS_MARK='XBP'; XBPS_PM='xbps-install'; XBPS_COMMAND="$PERMISSION_COMMAND $XBPS_PM --yes"
YUM_MARK='YUM'; YUM_PM='yum' ; YUM_COMMAND="$PERMISSION_COMMAND $YUM_PM install --assumeyes"
Zypper_MARK='ZPR'; Zypper_PM='zypper' ; Zypper_COMMAND="$PERMISSION_COMMAND $Zypper_PM --non-interactive install"
AUR_MARK='AUR'; AUR_PM='paru' ; AUR_COMMAND="$AUR_PM --sync --skipreview --useask --noconfirm --needed"
Flatpak_MARK='FLA'; Flatpak_PM='flatpak' ; Flatpak_COMMAND="$PERMISSION_COMMAND $Flatpak_PM install"
Homebrew_MARK='HBR'; Homebrew_PM='brew' ; Homebrew_COMMAND="$Homebrew_PM install"
MacPorts_MARK='MCP'; MacPorts_PM='port' ; MacPorts_COMMAND="$PERMISSION_COMMAND $MacPorts_PM install"
MAS_MARK='MAS'; MAS_PM='mas' ; MAS_COMMAND="$MAS_PM install"
Nix_MARK='NIX'; Nix_PM='nix-env' ; Nix_COMMAND="NIXPKGS_ALLOW_UNFREE='1' $Nix_PM --install --attr"
SBO_MARK='SBO'; SBO_PM='sbopkg' ; SBO_COMMAND="$PERMISSION_COMMAND $SBO_PM -ifq"
Snap_MARK='SNA'; Snap_PM='snap' ; Snap_COMMAND="$PERMISSION_COMMAND $Snap_PM install"
Basher_MARK='BSR'; Basher_PM='sbb_basher' ; Basher_COMMAND="$Basher_PM"
BPKG_MARK='BPK'; BPKG_PM='sbb_bpkg' ; BPKG_COMMAND="$BPKG_PM"
NPM_MARK='NPM'; NPM_PM='npm' ; NPM_COMMAND="$PERMISSION_COMMAND $NPM_PM install --global"
PIP_MARK='PIP'; PIP_PM='pip' ; PIP_COMMAND="$PIP_PM install --user"
Yarn_MARK='YRN'; Yarn_PM='yarn' ; Yarn_COMMAND="$Yarn_PM global add"
if [ -z "$PACKAGEMANAGER_MAIN" ]; then
case $(uname -s | tr '[:upper:]' '[:lower:]') in
'darwin'*)
KERNEL='darwin'
PACKAGEMANAGER_LIST='Homebrew MacPorts MAS'
;;
'freebsd'*)
KERNEL='freebsd'
PACKAGEMANAGER_MAIN='PKGNG'
;;
'midnightbsd'*)
KERNEL='midnightbsd'
PACKAGEMANAGER_MAIN='Mports'
;;
'netbsd'*)
KERNEL='netbsd'
PACKAGEMANAGER_MAIN='PKGIN'
;;
'openbsd'*)
KERNEL='openbsd'
PACKAGEMANAGER_MAIN='OpenBSD'
;;
'linux'*)
KERNEL='linux'
for packagemanager_check in 'APK' 'APT' 'EOPKG' 'DNF' 'Nix' 'Pacman' 'Portage' 'Slackpkg' 'URPMI' 'XBPS' 'YUM' 'Zypper'; do
[ -x "$(eval command -v \$${packagemanager_check}_PM)" ] && {
PACKAGEMANAGER_MAIN="$packagemanager_check"
break
}
done
[ "$PACKAGEMANAGER_MAIN" = 'Pacman' ] && PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST AUR"
[ "$PACKAGEMANAGER_MAIN" = 'Slackpkg' ] && PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST SBO"
PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST Flatpak Homebrew"
if [ "$PACKAGEMANAGER_MAIN" = 'APT' ] || [ "$PACKAGEMANAGER_MAIN" = 'Pacman' ]; then
PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST Snap"
fi
PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST Basher BPKG NPM PIP Yarn"
;;
*)
printf '\n\033[1;7;31m%s\033[0m\n' "Kernel unsupported" >&2
;;
esac
fi
PACKAGEMANAGER_LIST="$PACKAGEMANAGER_MAIN" # This is a list of package managers supported on bootstrapping OS
[ "$PACKAGEMANAGER_MAIN" != 'Nix' ] && PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST Nix"
PACKAGEMANAGER_LIST="$PACKAGEMANAGER_LIST $PACKAGEMANAGER_LIST"
# Functions
sbb_install_packages() {
if [ -f "$1" ]; then
packages_list=$(sed -e 's/#.*$//g' "$1")
elif [ -z "$PACKAGEMANAGER_MAIN" ]; then
printf '\n\033[1;7;31m%s\033[0m\n' "Main packages manager not found or unsupported" >&2
exit 1
else
printf '\n\033[1;7;31m%s\033[0m\n' 'Packages list not found' >&2
exit 1
fi
for packagemanager in $PACKAGEMANAGER_LIST; do
# Find packages with mark
eval "mark=\"\$${packagemanager}_MARK\""
packages_installing=$(printf '%s' "$packages_list" | sed -e "/^.*$mark:.*\$/!d;s/.*$mark://g" -e 's/[[:space:]].*$//g;/^$/d' | tr '\n' ' ')
# If finded, setup package manager then install packages
[ -n "$packages_installing" ] && {
# Remove lines with current mark so packages don't get reinstall on another package managers later on
packages_list=$(printf '%s' "$packages_list" | sed -e "s/^.*$mark.*\$//g")
printf '\n\033[1;7;35m%s\033[0m\n' "Setting up $packagemanager" >&2
eval "sbb_setup_$packagemanager"
cd "$WD" || exit 1
printf '\n\033[1;7;32m%s\033[0m\n' "Installing $packagemanager packages" >&2
eval "\$${packagemanager}_COMMAND $packages_installing"
}
done
}
sbb_make_install_command() {
eval "
sbb_$1() {
for ${1}_package in \"\$@\"; do
$2 \"\$${1}_package\"
done
}
"
}
sbb_install_git() {
if [ ! -x "$(command -v 'git')" ]; then
if [ "$KERNEL" = 'darwin' ]; then
if [ -x "$(command -v "$MacPorts_PM")" ]; then $MacPorts_COMMAND git
elif [ -x "$(command -v "$MAS_PM")" ]; then $MAS_COMMAND git
else
[ ! -x "$(command -v "$Homebrew_PM")" ] && sbb_setup_Homebrew
$Homebrew_COMMAND git
fi
else
case "$PACKAGEMANAGER_MAIN" in
'APK') $APK_COMMAND git ;;
'APT') $APT_COMMAND git ;;
'DNF') $DNF_COMMAND git ;;
'EOPKG') $EOPKG_COMMAND git ;;
'Mports') $Mports_COMMAND devel/git ;;
'OpenBSD') $OpenBSD_COMMAND devel/git ;;
'Pacman') $Pacman_COMMAND git ;;
'Portage') $Portage_COMMAND dev-vcs/git ;;
'PKGIN') $PKGIN_COMMAND devel/git ;;
'PKGNG') $PKGNG_COMMAND devel/git ;;
'Slackpkg') $Slackpkg_COMMAND git ;;
'Termux') $Termux_COMMAND git ;;
'URPMI') $URPMI_COMMAND git ;;
'XBPS') $XBPS_COMMAND git ;;
'YUM') $DNF_COMMAND git ;;
'Zypper') $Zypper_COMMAND git ;;
esac
fi
else
printf '%s\n' "Git has been installed" >&2
fi
}
sbb_install_curl() {
if [ ! -x "$(command -v 'curl')" ]; then
if [ "$KERNEL" = 'darwin' ]; then
if [ -x "$(command -v "$MacPorts_PM")" ]; then $MacPorts_COMMAND curl
elif [ -x "$(command -v "$MAS_PM")" ]; then $MAS_COMMAND curl
else
[ ! -x "$(command -v "$Homebrew_PM")" ] && sbb_setup_Homebrew
$Homebrew_COMMAND curl
fi
else
case "$PACKAGEMANAGER_MAIN" in
'APK') $APK_COMMAND curl ;;
'APT') $APT_COMMAND curl ;;
'DNF') $DNF_COMMAND curl ;;
'EOPKG') $EOPKG_COMMAND curl ;;
'Mports') $Mports_COMMAND ftp/curl ;;
'OpenBSD') $OpenBSD_COMMAND net/curl ;;
'Pacman') $Pacman_COMMAND curl ;;
'Portage') $Portage_COMMAND net-misc/curl ;;
'PKGIN') $PKGIN_COMMAND ftp/curl ;;
'PKGNG') $PKGNG_COMMAND ftp/curl ;;
'Slackpkg') $Slackpkg_COMMAND curl ;;
'Termux') $Termux_COMMAND curl ;;
'URPMI') $URPMI_COMMAND curl ;;
'XBPS') $XBPS_COMMAND curl ;;
'YUM') $YUM_COMMAND curl ;;
'Zypper') $Zypper_COMMAND curl ;;
esac
fi
else
printf '%s\n' "Curl has been installed" >&2
fi
}
sbb_install_python() {
if [ ! -x "$(command -v 'python')" ]; then
if [ "$KERNEL" = 'darwin' ]; then
if [ -x "$(command -v "$MacPorts_PM")" ]; then $MacPorts_COMMAND python
elif [ -x "$(command -v "$MAS_PM")" ]; then $MAS_COMMAND python
else
[ ! -x "$(command -v "$Homebrew_PM")" ] && sbb_setup_Homebrew
$Homebrew_COMMAND python
fi
else
case "$PACKAGEMANAGER_MAIN" in
'APK') $APK_COMMAND python ;;
'APT') $APT_COMMAND python ;;
'DNF') $DNF_COMMAND python3 ;;
'EOPKG') $EOPKG_COMMAND python ;;
'Mports') $Mports_COMMAND lang/python38 ;;
'OpenBSD') $OpenBSD_COMMAND lang/python/3.9 ;;
'Pacman') $Pacman_COMMAND python ;;
'Portage') $Portage_COMMAND dev-lang/python ;;
'PKGIN') $PKGIN_COMMAND lang/python39 ;;
'PKGNG') $PKGNG_COMMAND lang/python39 ;;
'Slackpkg') $Slackpkg_COMMAND python3 ;;
'Termux') $Termux_COMMAND python ;;
'URPMI') $URPMI_COMMAND python3 ;;
'XBPS') $XBPS_COMMAND python3 ;;
'YUM') $YUM_COMMAND python3 ;;
'Zypper') $Zypper_COMMAND python3 ;;
esac
fi
else
printf '%s\n' "Python has been installed" >&2
fi
}
## Setup main packages manager
sbb_setup_APK() {
"$PERMISSION_COMMAND" apt update
"$PERMISSION_COMMAND" apt upgrade
}
sbb_setup_APT() {
"$PERMISSION_COMMAND" apt update --assume-yes
"$PERMISSION_COMMAND" apt upgrade --assume-yes
}
sbb_setup_DNF() {
"$PERMISSION_COMMAND" dnf upgrade --assumeyes
}
sbb_setup_EOPKG() {
"$PERMISSION_COMMAND" eopkg update-repo --yes-all
"$PERMISSION_COMMAND" eopkg upgrade --yes-all
}
sbb_setup_Mports() {
"$PERMISSION_COMMAND" mport index
"$PERMISSION_COMMAND" mport upgrade
}
sbb_setup_OpenBSD() {
"$PERMISSION_COMMAND" syspatch
}
sbb_setup_Pacman() {
while :; do
printf '%s\n' 'y'
done \
| LC_ALL=en_US.UTF-8 "$PERMISSION_COMMAND" pacman --sync --sysupgrade --refresh --needed
}
sbb_setup_Portage() {
"$PERMISSION_COMMAND" emerge --sync
"$PERMISSION_COMMAND" emerge --update --newuse --deep --with-bdeps=y @world
}
sbb_setup_PKGIN() {
"$PERMISSION_COMMAND" pkgin update -y
"$PERMISSION_COMMAND" pkgin upgrade -y
}
sbb_setup_PKGNG() {
"$PERMISSION_COMMAND" pkg update -y
"$PERMISSION_COMMAND" pkg upgrade -y
}
sbb_setup_Slackpkg() {
"$PERMISSION_COMMAND" slackpkg update gpg
"$PERMISSION_COMMAND" slackpkg update
}
sbb_setup_Termux() {
pkg update --assume-yes
pkg upgrade --assume-yes
}
sbb_setup_URPMI() {
"$PERMISSION_COMMAND" urpmi.update --force --all
"$PERMISSION_COMMAND" urpmi --force --auto-update
}
sbb_setup_XBPS() {
"$PERMISSION_COMMAND" xbps-install --sync --yes --update xbps
"$PERMISSION_COMMAND" xbps-install --sync --yes void-repo-nonfree void-repo-multilib void-repo-multilib-nonfree void-repo-debug
}
sbb_setup_YUM() {
"$PERMISSION_COMMAND" yum upgrade --assumeyes
}
sbb_setup_Zypper() {
"$PERMISSION_COMMAND" zypper --non-interactive update
}
## Setup additional packages manager
sbb_setup_AUR() {
if [ ! -x "$(command -v 'paru')" ]; then
$Pacman_COMMAND git base-devel
git clone 'https://aur.archlinux.org/paru-bin.git' "$TEMPORARY/paru"
cd "$TEMPORARY/paru" || exit 1
makepkg --syncdeps --noconfirm
"$PERMISSION_COMMAND" $Pacman_PM --needed --noconfirm --upgrade paru-bin-*.zst
else
printf '%s\n' "Paru has been installed" >&2
$AUR_COMMAND --sysupgrade --refresh --aur
fi
}
sbb_setup_Flatpak() {
if [ ! -x "$(command -v 'flatpak')" ]; then
case "$PACKAGEMANAGER_MAIN" in
'APK') $APT_COMMAND flatpak ;;
'APT') $APT_COMMAND flatpak gnome-software-plugin-flatpak ;;
'DNF') $DNF_COMMAND flatpak ;;
'EOPKG') $APT_COMMAND flatpak xdg-desktop-portal-gtk ;;
'Portage') $Portage_COMMAND sys-apps/flatpak ;;
'Pacman') $Pacman_COMMAND flatpak ;;
'URPMI') $URPMI_COMMAND flatpak ;;
'XBPS') $XBPS_COMMAND flatpak ;;
'YUM') $YUM_COMMAND flatpak ;;
'Zypper') $Zypper_COMMAND flatpak ;;
'Slackpkg')
[ ! -x "$(command -v "$SBO_PM")" ] && sbb_setup_SBO
$SBO_COMMAND flatpak
;;
esac
else
printf '%s\n' "Flatpak has been installed" >&2
fi
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
}
sbb_setup_Homebrew() {
if [ ! -x "$(command -v 'brew')" ] >/dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
printf '%s\n' "Homebrew has been installed" >&2
fi
}
sbb_setup_MacPorts() {
[ ! -x "$(command -v 'xcode')" ] && {
printf '\n\033[1;7;31m%s\033[0m\n' 'Please install XCode first: https://guide.macports.org/#installing.xcode' >&2
exit 1
}
xcode-select --install
"$PERMISSION_COMMAND" xcodebuild -license
cd "$TEMPORARY" || exit 1
curl --remote-header-name --location --remote-name "https://github.com/macports/macports-base/releases/latest/download/MacPorts-$MACPORT_VERSION-$OS_VERSION_NUMBER-$OS_VERSION_NAME.pkg"
"$PERMISSION_COMMAND" installer -pkg "$TEMPORARY/MacPorts-$MACPORT_VERSION-$OS_VERSION_NUMBER-$OS_VERSION_NAME.pkg" -target '/'
}
sbb_setup_MAS() {
if [ ! -x "$(command -v "$MAS_PM")" ]; then
if [ -x "$(command -v "$Homebrew_PM")" ]; then $Homebrew_COMMAND mas
elif [ -x "$(command -v "$MacPorts_PM")" ]; then $MacPorts_COMMAND mas
else
[ ! -x "$(command -v "$Homebrew_PM")" ] && sbb_setup_Homebrew
$Homebrew_COMMAND mas
fi
else
printf '%s\n' "MAS has been installed" >&2
fi
mas account
mas signin --dialog "$APPLE_ID"
}
sbb_setup_Nix() {
if [ ! -x "$(command -v 'nix-env')" ]; then
sbb_install_curl
curl -L 'https://nixos.org/nix/install' | sh
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
else
printf '%s\n' "Nix has been installed" >&2
fi
}
sbb_setup_SBO() {
if [ ! -x "$(command -v 'sbopkg')" ]; then
sbb_install_curl
SBO_VERSION=$(curl -s "https://api.github.com/repos/sbopkg/sbopkg/releases/latest" | grep -e 'tag_name' | cut -f '4' -d '"')
cd "$TEMPORARY" || exit 1
curl --remote-header-name --location --remote-name "https://github.com/sbopkg/sbopkg/releases/download/$SBO_VERSION/sbopkg-$SBO_VERSION-noarch-1_wsr.tgz"
upgradepkg --install-new "$TEMPORARY/sbopkg-$SBO_VERSION-noarch-1_wsr.tgz"
"$PERMISSION_COMMAND" mkdir -p "/var/lib/sbopkg/SBo/$(cut -f '2' -d ' ' '/etc/slackware-version')" "/var/lib/sbopkg/queues" "/var/log/sbopkg" "/var/cache/sbopkg"
"$PERMISSION_COMMAND" sbopkg -rq
"$PERMISSION_COMMAND" sqg -a
else
printf '%s\n' "Sbopkg has been installed" >&2
fi
}
sbb_setup_Snap() {
if [ ! -x "$(command -v 'snap')" ]; then
case "$PACKAGEMANAGER_MAIN" in
'APT') $APT_COMMAND snapd ;;
'EOPKG') $EOPKG_COMMAND snapd ;;
'DNF') "$PERMISSION_COMMAND" dnf install snapd ;;
'YUM') "$PERMISSION_COMMAND" yum install snapd ;;
'Pacman')
sbb_install_git
git clone 'https://aur.archlinux.org/snapd.git' "$TEMPORARY/snap"
cd "$TEMPORARY/snap" || exit 1
makepkg -si
;;
'Zypper')
"$PERMISSION_COMMAND" zypper addrepo --refresh 'https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.2' snappy
"$PERMISSION_COMMAND" zypper --gpg-auto-import-keys refresh
"$PERMISSION_COMMAND" zypper dup --from snappy
"$PERMISSION_COMMAND" zypper install snapd
"$PERMISSION_COMMAND" systemctl enable --now snapd
"$PERMISSION_COMMAND" systemctl enable --now snapd.apparmor
;;
esac
case "$PACKAGEMANAGER_MAIN" in
'DNF'|'Pacman'|'YUM')
"$PERMISSION_COMMAND" systemctl enable --now snapd.socket
"$PERMISSION_COMMAND" ln -s '/var/lib/snapd/snap' '/snap'
;;
esac
else
printf '%s\n' "Snapd has been installed" >&2
fi
snap install core
}
## Setup language packages manager
sbb_setup_Basher() {
sbb_install_git
git clone 'https://github.com/basherpm/basher.git' "${BASHER_ROOT:-$HOME/.basher}"
sbb_make_install_command 'basher' "${BASHER_ROOT:-$HOME/.basher}/bin/basher install"
}
sbb_setup_BPKG() {
sbb_install_git
git clone 'https://github.com/bpkg/bpkg.git' "$TEMPORARY/bpkg"
cd "$TEMPORARY/bpkg" || exit 1
"$PERMISSION_COMMAND" "$TEMPORARY/bpkg/setup.sh"
sbb_make_install_command 'bpkg' "$PERMISSION_COMMAND bpkg install"
}
sbb_setup_NPM() {
if [ ! -x "$(command -v 'npm')" ]; then
if [ "$KERNEL" = 'darwin' ]; then
if [ -x "$(command -v "$MacPorts_PM")" ]; then $MacPorts_COMMAND npm
elif [ -x "$(command -v "$MAS_PM")" ]; then $MAS_COMMAND npm
else
[ ! -x "$(command -v "$Homebrew_PM")" ] && sbb_setup_Homebrew
$Homebrew_COMMAND npm
fi
else
case "$PACKAGEMANAGER_MAIN" in
'APK') $APK_COMMAND npm ;;
'APT') $APT_COMMAND npm ;;
'DNF') $DNF_COMMAND npm ;;
'EOPKG') $EOPKG_COMMAND npm ;;
'Mports') $Mports_COMMAND www/npm ;;
'OpenBSD') $OpenBSD_COMMAND www/npm ;;
'Pacman') $Pacman_COMMAND npm ;;
'Portage') $Portage_COMMAND net-libs/nodejs ;;
'PKGIN') $PKGIN_COMMAND www/npm ;;
'PKGNG') $PKGNG_COMMAND www/npm ;;
'Slackpkg') $Slackpkg_COMMAND python/npm ;;
'Termux') $Termux_COMMAND npm ;;
'URPMI') $URPMI_COMMAND npm ;;
'XBPS') $XBPS_COMMAND npm ;;
'YUM') $YUM_COMMAND npm ;;
'Zypper') $Zypper_COMMAND npm ;;
esac
fi
else
printf '%s\n' "NPM has been installed" >&2
fi
"$PERMISSION_COMMAND" npm install --global npm@latest
}
sbb_setup_PIP() {
sbb_install_curl
sbb_install_python
cd "$TEMPORARY" || exit 1
curl --remote-header-name --location --remote-name "https://bootstrap.pypa.io/get-pip.py"
python get-pip.py
pip install --upgrade pip
}
sbb_setup_Yarn() {
if [ ! -x "$(command -v 'yarn')" ]; then
if [ "$KERNEL" = 'darwin' ]; then
if [ -x "$(command -v "$MacPorts_PM")" ]; then $MacPorts_COMMAND yarn
elif [ -x "$(command -v "$MAS_PM")" ]; then $MAS_COMMAND yarn
else
[ ! -x "$(command -v "$Homebrew_PM")" ] && sbb_setup_Homebrew
$Homebrew_COMMAND yarn
fi
else
case "$PACKAGEMANAGER_MAIN" in
'APK') $APK_COMMAND yarn ;;
'APT') $APT_COMMAND node-yarnpkg ;;
'DNF') $DNF_COMMAND yarn ;;
'EOPKG') $EOPKG_COMMAND yarn ;;
'Mports') $Mports_COMMAND www/yarn ;;
'OpenBSD') $OpenBSD_COMMAND devel/yarn ;;
'Pacman') $Pacman_COMMAND yarn ;;
'Portage') $Portage_COMMAND sys-apps/yarn ;;
'PKGIN') $PKGIN_COMMAND www/yarn ;;
'PKGNG') $PKGNG_COMMAND devel/yarn ;;
'Slackpkg') $Slackpkg_COMMAND development/yarn ;;
'URPMI') $URPMI_COMMAND yarn ;;
'Termux') $Termux_COMMAND yarn ;;
'XBPS') $XBPS_COMMAND yarn ;;
'YUM') $YUM_COMMAND yarn ;;
'Zypper') $Zypper_COMMAND yarn ;;
esac
fi
else
printf '%s\n' "Yarn has been installed" >&2
fi
cd "$HOME" || exit 1
yarn set version berry
}