-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
killer.sh
executable file
·139 lines (119 loc) · 3.49 KB
/
killer.sh
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
#!/bin/bash
# Lista el Directorio Actual
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Agregar el Archivo con la Configuracion
source "$DIR/config"
# Exporta las Variables de Archivo de Configuracion
export PKGEXT
export COMPRESSXZ
export PACKAGER
export GPGKEY
export BUILDDIR="$DIR/cache"
export PKGDEST="$BUILDDIR/bin"
export SRCDEST="$BUILDDIR/src"
# Salga inmediatamente si un comando sale con un estado distinto de cero
set -e
shopt -s expand_aliases
# Mustra Menu de Ayuda
usage() {
echo -e "Menu de Ayuda" ;
}
# Agregar PKGBUILD y Actualizar Repo de GitHub
add() {
pushd "$DIR" || exit
git submodule add --force https://aur.archlinux.org/"$pkg" ./pkgbuild/"$pkg"
# git add .
# git commit -m "Add $pkg"
# git push origin main
popd || exit
}
# Eliminar PKGBUILD y Actualizar Repo de GitHub
delete() {
pushd "$DIR" || exit
git rm --cached "$DIR/pkgbuild/${OPTARG}"
rm -rf "$DIR/pkgbuild/${OPTARG}"
rm -rf "$DIR/.git/modules/pkgbuild/${OPTARG}"
git config -f .gitmodules --remove-section "submodule.pkgbuild/${OPTARG}"
git config -f .git/config --remove-section "submodule.pkgbuild/${OPTARG}"
# git add .
# git commit -m "Removed ${OPTARG}"
# git push origin main
popd || exit
}
# Compilar o Generar PKG
build() {
git submodule update --recursive --remote
pushd "$DIR/pkgbuild"
for f in *; do
if [ -d "$f" ]; then
echo "Prosesando $f..."
pushd "$f"
if [ -f "PKGBUILD" ]; then
echo "Se Encontro el PKGBUILD de $f. Empezando a Compilar..."
# limpiar construir forzar sobrescribir y firmar
makepkg -C -s -f --sign --noconfirm
fi
popd
fi
done
}
# Actualizar PKGBUILD
refresh() {
pushd "$DIR/pkgbuild" > /dev/null 2>&1 || exit
echo -e "\n\e[1;33mActualizando todos los submódulos...\e[0m"
# Actualizar todos los submódulos
for D in */; do
cd "$D" || exit;
echo -e "\n\e[1;34mActualizando $D\e[0m"
# Limpiar los cambios no deseados realizados en los submódulos localmente
git clean -x -d -f -q
git stash --quiet
# Rebase
git rebase HEAD master
# Actualizar submódulos
git pull origin master
cd ..;
sleep 0.25s;
done
popd > /dev/null 2>&1 || exit
}
# Crear Repositorio
deploy() {
# Mover paquetes construidos en caché/
pushd "$DIR/ctlos_dev/x86_64"
for f in *${PKGEXT}; do > /dev/null 2>&1 || exit
[ -f "$f" ] || break
echo "Archivando $f..."
mv "$f" "$BUILDDIR"
mv "${f}.sig" "$BUILDDIR"
done
# Agregar paquetes construidos a la base de datos del repositorio
for f in ${PKGDEST}/*${PKGEXT}; do
[ -f "$f" ] || break
echo "Desplegando $f..."
mv "$f" "./"
mv "${f}.sig" "./"
repo-add -R -s -v "${REPONAME}.db.tar.zst" "$(basename "$f")"
done || exit
popd
}
# Actualizar Repositorio
sync() {
# Killer-Hacker-Oficial
# rsync --copy-links --delete -avr "$DIR/ctlos_dev" -avr "$DIR/ctlos_repo" "$KILLER"
# CTLOS Linux
rsync --copy-links --delete -avr "$DIR/ctlos_dev" "$CTLOS"
rm -rfv "$DIR"/cache/*
}
# Opciones
[ $# -eq 0 ] && usage
while getopts "ad:rbh:" arg; do
case $arg in
a) shift $(( OPTIND - 1 )); for pkg in "$@"; do add; done ;;
b) build; deploy; sync; exit 0 ;;
r) refresh ;;
d) delete ;;
h) usage ;;
*) usage ;;
esac
done