summarylogtreecommitdiffstats
path: root/pamac.install
blob: 5588e68f0486bced731f75e3e2487646e6249bd0 (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
msg() {
    ALL_OFF="\e[1;0m"
    BOLD="\e[1;1m"
    GREEN="${BOLD}\e[1;32m"
    local mesg=$1; shift
    printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}

restore_conf() {
  PAMAC_NEW="$(date +%m%d%M%S)"
  if [ -f "/etc/pamac.conf.pacsave" ]; then
     msg "You had an old /etc/pamac.conf.pacsave file. We restore it for you."
     msg "You can find your new pamac.conf saved as \`/etc/pamac-new-${PAMAC_NEW}.conf\`"
     mv /etc/pamac.conf /etc/pamac-new-${PAMAC_NEW}.conf
     mv /etc/pamac.conf.pacsave /etc/pamac.conf
  fi
}

post_install() {
    # enable flatpak repo
    if [ -f /usr/bin/flatpak ]; then
        flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
        flatpak remote-add --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
    fi
    # enable systemd timers
    mkdir -p /etc/systemd/system/timers.target.wants
    ln -sf /usr/lib/systemd/system/pamac-cleancache.timer /etc/systemd/system/timers.target.wants/pamac-cleancache.timer
    
    # restore old conf
    restore_conf
}

post_upgrade() {
    # enable flatpak repo
    if [ -f /usr/bin/flatpak ]; then
        flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
    fi
  
    # restore old conf
    restore_conf
}

post_remove() {
    # disable systemd timers
    rm -f /etc/systemd/system/timers.target.wants/pamac-cleancache.timer
    #rm -f /etc/systemd/system/timers.target.wants/pamac-mirrorlist.timer
}