summaryrefslogtreecommitdiff
path: root/raveos-mirrorlist/raveos-mirrorlist.install
blob: c44a35e99a2299d09bae1b3c81300520a8483bdb (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
post_install() {
    _patch_pacman_conf
}

post_upgrade() {
    _patch_pacman_conf
}

_patch_pacman_conf() {
    conf=/etc/pacman.conf
    [ -f "$conf" ] || return 0

    # 1) Regi, egysoros Server= allapot -> Include= (GitHub tartalek szerverrel).
    if grep -qF 'Server = https://page.rp1.hu/x86_64/' "$conf" \
        && ! grep -qF 'Include = /etc/pacman.d/raveos-core-mirrorlist' "$conf"; then
        sed -i \
            '\|^Server = https://page.rp1.hu/x86_64/$|c\Include = /etc/pacman.d/raveos-core-mirrorlist' \
            "$conf"
        sed -i '\|^Server = https://github.com/rave-os/RaveOS-core-repo-mirror/releases/download/core-repo-x86_64/$|d' "$conf"
        echo "raveos-mirrorlist: /etc/pacman.conf frissitve (raveos-core-repo -> Include mirrorlist, GitHub tartalek szerverrel)"
    fi

    # 2) [raveos-core-repo] szekcio athelyezese a [core] ELE.
    #    A pacman az ELSO repot valasztja azonos nevu csomagra, verziotol
    #    fuggetlenul - ha a raveos repo hatul van, az official csomagok nyernek.
    core_line=$(grep -n '^\[core\]' "$conf" | head -n1 | cut -d: -f1)
    rav_line=$(grep -n '^\[raveos-core-repo\]' "$conf" | head -n1 | cut -d: -f1)
    if [ -n "$core_line" ] && [ -n "$rav_line" ] && [ "$rav_line" -gt "$core_line" ]; then
        [ -f "$conf.raveos-bak" ] || cp -f "$conf" "$conf.raveos-bak" 2>/dev/null || true
        if awk '
            NR==FNR {
                if ($0 ~ /^\[raveos-core-repo\]/) grab=1
                else if (grab && $0 ~ /^\[/) grab=0
                if (grab) block = block $0 "\n"
                next
            }
            {
                if (skip) {
                    if ($0 ~ /^\[/) { skip=0; print; next }
                    next
                }
                if ($0 ~ /^\[raveos-core-repo\]/) { skip=1; next }
                if ($0 ~ /^\[core\]/ && !moved) { printf "%s", block; moved=1 }
                print
            }
        ' "$conf" "$conf" > "$conf.raveos-new" && mv -f "$conf.raveos-new" "$conf"; then
            echo "raveos-mirrorlist: [raveos-core-repo] athelyezve a [core] ele (repo-sorrend javitas)"
        else
            rm -f "$conf.raveos-new"
            echo "raveos-mirrorlist: FIGYELEM - a [raveos-core-repo] athelyezes nem sikerult"
        fi
    fi

    # 3) IgnorePkg: a gnome lista torlese (a repo-sorrend mar nyer; az IgnorePkg
    #    blokkolna a sajat frissiteseinket). A kernel pin meghagyva.
    if grep -q '^IgnorePkg' "$conf"; then
        sed -i 's/^IgnorePkg.*/IgnorePkg = linux-cachyos linux-cachyos-headers/' "$conf"
    fi

    echo "raveos-mirrorlist: kesz - futtass meg egy 'pacman -Syu'-t a GNOME 50 pin ervenyesitesehez"
}