summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 24d9a9285fa9d8f31d14fe6a5bf69db640c3bcfb (plain)
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
# Maintainer: dakataca <馃惉danieldakataca@gmail.com>

pkgname=bypass_utility-bin
_pkgname=${pkgname%-*}
pkgver=1.4.2
pkgrel=1
pkgdesc='Small utility to disable bootrom protection (SLA and DAA) to smartphones with supported mediatek processors.'
url='https://github.com/MTK-bypass'
arch=(x86_64)
license=(MIT)
makedepends=('rsync')
depends=('python-pyusb' 'python-json5' 'python-pyserial' 'linux-kamakiri-bin' 'translate-shell')
pkgname_provides=exploits_collection
pkgver_provides=1.6
provides=("$pkgname_provides=$pkgver_provides")
source=(
    $url/$_pkgname/archive/refs/tags/v.$pkgver.tar.gz
    v.$pkgver.tar.gz.sig
    $url/$pkgname_provides/archive/refs/tags/v$pkgver_provides.tar.gz
    v$pkgver_provides.tar.gz.sig
)
sha256sums=('61606367f706a07277636488890b9a3622324223b50ca9f21e49b4cb5c409eb0'
            'SKIP'
            '3195c8df2539a6ec3c25bd64aad732b2291070454f45f86df5a675796cbae731'
            'SKIP')
validpgpkeys=(4BA1F928CBA7CA219A14741B24FB14CFDD5D0319)  # dakataca

# Preparar fuentes. 
prepare() {
    cp -r $pkgname_provides-$pkgver_provides/* $_pkgname-v.$pkgver/
}


# Alistar ficheros en el directorio de instalaci贸n.
package() {
    local -r dirbypass=$_pkgname-v.$pkgver/
    cat $dirbypass/README.md 
    
    # Cree el directorio de destino y copia en 茅l, el contenido de bypass_utility/.
    rsync -a "$dirbypass/" --mkpath "$pkgdir/opt/$_pkgname/"
    
    # Script de ejecuci贸n bypass_utility.
    install -Dvm755 <(cat <<'EOF'
#!/usr/bin/env bash

translate_str() {
   local -r lang=${LANG%_[A-Z][A-Z].UTF-8}
   local str=""
   if [[ $lang == en ]]; then
       str=$1 
   elif [[ $lang == es ]]; then
       str=$2
   else
       str=`trans -b :$lang "$str"`
   fi
   echo "$str"
}

# Comprobar si el usuario es root.
if [ "$EUID" -ne 0 ]; then
    translate_str "Error: You can't perform this operation unless you're superuser."\
    "Error: No puede realizar esta operaci贸n, a menos que sea superusuario."
else
    # kernel actual.
    declare -r current_kernel=`uname -r` kernel=linux-kamakiri

    # Expresi贸n regular o patr贸n.
    declare -r pattern="^[0-9]+\.[0-9]+\.[0-9]+-arch[0-9]+-[0-9]+-kamakiri$"

    # Comprueba si la versi贸n del kernel coincide con el patr贸n.
    if [[ $current_kernel =~ $pattern ]]; then
        translate_str "Kernel $kernel validated correctly..."\
	"Kernel $kernel validado correctamente..."
        cd /opt/bypass_utility/
        ./main.py
        cd -
    else
        declare -r installed_kernel_kamakiri=`pacman -Qs linux-kamakiri*`

        # Comprueba si est谩 instalado el kernel linux-kamakiri.
        if [[ $installed_kernel_kamakiri ]]; then
            translate_str "'"$kernel"' kernel installed, manually initialize it in your bootloader and re-run bypass_utility."\
	    "Kernel '"$kernel"' instalado, inicial铆zelo manualmente en su bootloader y vuelva a ejecutar bypass_utility."
        else
	    translate_str "Currently incompatible kernel '"$current_kernel"', you need to install the \"linux-kamakiri\" variant provided by \"linux-kamakiri-bin\" or \"linux-kamakiri\":" "Kernel actual '"$current_kernel"' incompatible, necesita instalar la variante \"linux-kamakiri\" provista por \"linux-kamakiri-bin\" 贸 \"linux-kamakiri\":"
            echo ">> paru -S linux-kamakiri-bin
>> yay -S linux-kamakiri-bin"
	fi
    fi
fi
EOF
) $pkgdir/usr/bin/$_pkgname

}

## References:
# https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html 

## Test:
# updpkgsums
# makepkg --printsrcinfo > .SRCINFO
# git clean -dfx

# 馃懁 Autor: https://t.me/dakataca 馃捇 馃惉 #