forked from SuperSimplePackageManager/SSPM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spm
executable file
·56 lines (51 loc) · 1.3 KB
/
spm
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
#! /usr/bin/env bash
set -e
export CWD=$(pwd)
export REPO="https://raw.githubusercontent.com/OS-1337/pkgs/main/bin/"
export SPM_DIR=/usr/local/spm
export ACTION="NONE"
check_spm_foler(){
if [ ! -d ${spm_DIR} ]; then
mkdir -pv ${spm_DIR}
fi
}
install_package(){
. ${PACKAGE}.spm
mkdir -p ${PACKAGE}-src
cd ${spm_DIR}/${PACKAGE}-src
wget -q ${source}
if [ ${format} == "bz2" ]; then
tar xvf *.bz2 &>/dev/null
elif [ ${format} == "xz" ]; then
tar xvf *.xz &>/dev/null
fi
cd ${spm_DIR}/${PACKAGE}-src/
cp -r */. . &>/dev/null
${PACKAGE} ${ACTION} &>/dev/null
cd ${spm_DIR}
rm -rf ${PACKAGE}*
echo "Done!"
}
for PACKAGE in $*
do
if [ "${PACKAGE}" == "install" ]; then
export ACTION="INSTALL"
elif [ "${PACKAGE}" == "remove" ]; then
export ACTION="REMOVE"
elif [ ! -f ${CWD}/${PACKAGE}.spm ]; then
echo "Installing ${PACKAGE} from repo"
check_spm_foler
cd ${spm_DIR}
rm -rf ${PACKAGE}*
wget -q ${REPO}/${PACKAGE}.spm
install_package
else
echo "Installing ${CWD}/${PACKAGE}.spm"
check_spm_foler
cd ${spm_DIR}
rm -rf ${PACKAGE}*
cd ${CWD}
cp ${CWD}/${PACKAGE}.spm ${spm_DIR}/${PACKAGE}.spm
install_package
fi
done