Skip to content

Instantly share code, notes, and snippets.

Created January 20, 2017 20:54
Show Gist options
  • Save anonymous/a70eae6a49fecbe79c0d9f41067c3174 to your computer and use it in GitHub Desktop.
Save anonymous/a70eae6a49fecbe79c0d9f41067c3174 to your computer and use it in GitHub Desktop.
pacmenu offers a menu for pacman, the central package installer of Manjaro
#!/bin/bash
# This is pacmenu, a fork from a misnomer program which had a name few bother memorizing
# pacmenu offers a menu for pacman, the central package installer of Manjaro, the Arch derivate Linux distro.
# This spares everyone the bother to look up & memorize all those dreaded command line parameters of pacman and yaourt (installer from source code).
# Jan. 2017 release by Guccifer4
# online help page : https://gist.github.com/anonymous/036f327878c40ee8e295804b3c7b1de9
# change log: rename pacmenu, ESC instead of Q... , reformat hlp
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# ######################################################################
#
# Design based on IceFox script. Modified, adapted and improved by pekman, excalibur1234, Chrysostomus, papajoker, Guccifer4
# see also: https://github.com/excalibur1234/pacli-simple
# to diff pacmenu against for security
# all functions of pacmenu are defined here in almost the same order as they appear in pacmenu's UI:
function func_u
{
sudo pacman -Syu --color always
yaourt -Syua
}
function func_c
{
sudo pacman-mirrors -g -t 30 && echo "" && sudo pacman -Syy --color always
echo ""
yaourt -Qdt
echo ""
if [[ $(cat /proc/1/comm) == "systemd" ]] # if init system is systemd
then
# limit logs in journalctl to an ageo of 30 days and a combined size of 50mb
sudo journalctl --vacuum-size=50M --vacuum-time=30days
fi
echo ""
paccache -ruvk1
echo ""
paccache -rvk2
echo ""
# 1. extract the name of hard drive the / partition is installed on and write it to the "disk" variatble"
local disk # declare local variable
disk=$(lsblk -o "name,mountpoint" -pa | sed -n '/^\//h;/\/$/{g;p}' | cut -d/ -f3)
disk="${disk:0:3}"
# 2. check, whether "disk" is not empty and whether the path to "disk" exists
if [[ -n $disk && -e "/dev/$disk" ]]
then
# open the "rotational" file belonging to your "disk" and checking, whether it contains a "1" - this means your "disk" is a traditional hard drive and no SSD.
if [[ $(cat "$( find "/sys" -name "rotational" 2>/dev/null | grep "$disk/queue" )" ) == "1" ]]
then
# only execute the following line when your / parition is installed on a hard drive.
sudo pacman-optimize
fi
fi
}
function func_i
{
# the "package-query -Sl -f '%n %v - %d' " displays a list of all packages from the Manjaro repositories and formats them like "NAME VERSION - DESCRIPTION". the first part (="NAME") gets (printed and) saved to the "pkg" variable.
local pkg
pkg=$(package-query -Sl -f "%n %v - %d" | sort | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to install. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ' | awk '{print $1}' )
# only run the command inside the if-statement, if $pkg variable is not empty - this happens when fzf is quit with ESC or CTRL+C
if [[ -n $pkg ]]
then
sudo pacman -S $pkg --color always
fi
}
function func_r
{
# $(pacman -Qq | sort | fzf -e -m +s --reverse --prompt='Select packages to remove (use TAB to toggle selection) > ')
# takes a package list from "pacman -Qq", then sorts it alphabetically, then make the resulting list available to fzf.
# fzf lets you search and select the given list in a fast way. the "-m" flags makes it possible to select multiple list items.
local pkg
pkg=$(package-query -Q -f "%n %v - %d" | sort | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to remove. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ' | awk '{print $1}' )
if [[ -n $pkg ]]
then
sudo pacman -Rsn $pkg --color always
fi
}
function func_info
{
# check, whether file /tmp/pacmenu-packages already exists (the ! negates the result)
if [[ ! -e /tmp/pacmenu-packages ]]
then
# write package list of repositories to /tmp/pacmenu-packages. then, download AUR package list, unzip it to /tmp/aur/packages, and add it to the bottom of /tmp/pacmenu-packages.
pacman -Slq > /tmp/pacmenu-packages
wget -P /tmp/aur/ https://aur.archlinux.org/packages.gz >/dev/null 2>&1 && gunzip -f /tmp/aur/packages.gz && cat /tmp/aur/packages >> /tmp/pacmenu-packages
fi
# the following command lets you search through the file "/tmp/pacmenu-packages" with fzf and save your selection in "pkg"
local pkg
pkg=$(sort /tmp/pacmenu-packages | fzf-tmux -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press ENTER to display info. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ')
# only run the command inside the if-statement, if $pkg variable is not empty - this happens when fzf is quit with ESC or CTRL+C
if [[ -n $pkg ]]
then
# next, it is checked, whether "pkg" is part of a list of all installed packages (pacman -Qq).
if ( pacman -Qq $pkg &>/dev/null )
then
yaourt -Qii $pkg # execute this command when "pkg" is already installed on system
else
yaourt -Sii $pkg # execute this command when "pkg" is not installed on system
fi
fi
}
function func_l
{
# use fzf to ask the user to select an installed package. the package name gets save in variable "pkg"
local pkg
pkg=$(pacman -Qq | fzf-tmux -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press ENTER to list files. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ')
if [[ -n $pkg ]]
then
# take the output of command "pacman -Qlq $pkg" and make it searchable with fzf. for all used fzf flags see "man fzf". store all marked lines in file /tmp/pacmenu-list.
pacman -Qlq $pkg --color always | fzf-tmux -m -e +s -i --query="/usr/bin/" --cycle --reverse --margin=4%,1%,1%,1% --inline-info --header="List of files of package \"${pkg}\". Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed directories and files > ' >> /tmp/pacmenu-list
fi
}
function func_t
{
# write package list of Manjaro repositories to /tmp/pacmenu-packages-local. then add all instaled packages to the bottom of /tmp/pacmenu-packages-local.
pacman -Slq > /tmp/pacmenu-packages-local
pacman -Qq >> /tmp/pacmenu-packages-local
local pkg
pkg=$(sort /tmp/pacmenu-packages-local | fzf-tmux -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press ENTER to show tree. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ')
# look in func_info for explanations
if [[ -n $pkg ]]
then
if ( pacman -Qq $pkg &>/dev/null )
then
pactree -c $pkg
else
pactree -c -s $pkg
fi
fi
}
function func_rt
{
local pkg
pkg=$(pacman -Qq | fzf-tmux -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press ENTER to show reverse tree. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ')
pactree -c -r $pkg
}
# =======================
function func_log
{
tail -5000 /var/log/pacman.log | fzf-tmux -m -e +s -i --query="ALPM] " --tac --reverse --margin=4%,1%,1%,1% --inline-info --header="Navigate with PageUp / PageDown Keys. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed logs > ' >> /tmp/pacmenu-log
}
function func_s
{
local pkg
if [[ -n "$input2" ]]
then
# do this if variable "input" is not empty:
pacman -Ql --color always | grep $"$input2"
else
# do this if pacmenu is used with UI or no argument is specified in "pacmenu s" command:
echo "Enter (parts of) the file name to be searched within all installed packages. Then press ENTER."
read -r pkg
pacman -Ql --color always | grep $pkg
fi
}
function func_d
{
pacman -Slq > /tmp/pacmenu-packages-local
pacman -Qq >> /tmp/pacmenu-packages-local
local pkg
pkg=$(sort /tmp/pacmenu-packages-local | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to downgrade. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ' | awk '{print $1}' )
downgrade $pkg
}
function func_b
{
# declare local variables
local {cache,pkg,line,temp}
# get architecture and cache directory and write results to variables:
cache=$(grep CacheDir /etc/pacman.conf | awk '{print $3}')
# 1. get list of last installs/upgrades/removes from pacman log and display result in fzf. in the end, fzf saves all selected package names (including the words "installs/upgrades/removes" to variable "temp".
temp=$( tail -2000 /var/log/pacman.log | grep "\[ALPM\]" | grep "installed\|removed\|upgraded" | sed 's/\[ALPM\] //g' | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --tac --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to roll back. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of recent Pacman changes > ' | sed 's/ ([^)]*)//g' | awk '{print $3 " " $4}' )
#> /tmp/pacmenu-cache-packages
# only run the command inside the if-statement, if variable "temp" is not empty - this happens when fzf is quit with ESC or CTRL+C
if [[ -n $temp ]]
then
# in order to work with the output of fzf, it has to be copied into a file in the /tmp/ directory: /tmp/pacmenu-cache-packages
echo $temp > /tmp/pacmenu-cache-packages
# 2. in case of conflicting packages, packages have to be first removed.
#filter /tmp/pacmenu-cache-packages file for the word "installed" and write all results to variable "pkg"
pkg=$( grep installed /tmp/pacmenu-cache-packages | awk '{print $2}' )
sudo pacman -Rdd $pkg --color always
# 3. in case an "upgraded" package needs a package as dependency, the "removed" packages have to be installed.
#filter /tmp/pacmenu-cache-packages file for the word "removed" and write all results to variable "pkg"
pkg=$( grep removed /tmp/pacmenu-cache-packages | awk '{print $2}' )
sudo pacman -S $pkg --color always
# 4. filter /tmp/pacmenu-cache-packages file for the word "upgraded" and write all results to file /tmp/pacmenu-cache-downgrade
grep upgraded /tmp/pacmenu-cache-packages | awk '{print $2}' > /tmp/pacmenu-cache-downgrade
# this file will later contain a list of file names of (old versions of) packages in cache. it has to be empty in the beginning!
rm /tmp/pacmenu-downgrade
# read line by line from file /tmp/pacmenu-cache-downgrade in while loop and save that line to variable $line
while IFS='' read -r line || [[ -n "$line" ]]
do
# use the following command to find all package versions of $line in cache, sort the resulting list, and choose the second line from the list (= the second latest version of package $line found in the cache), append that to file /tmp/pacmenu-downgrade:
find $cache -name "${line}-[0-9a-zA-Z.-]*.pkg.tar.[gx]z" | sort -r | sed -n '2p' >> /tmp/pacmenu-downgrade
done < /tmp/pacmenu-cache-downgrade
# write file into variable (otherwise, the "sudo pacman -U" command does not work)
pkg=$( cat /tmp/pacmenu-downgrade )
# downgrade packages by manually installing them: (sudo pacman -U --noconfirm --color always )
sudo pacman -U $pkg --color always
fi
}
function func_conf
{
# create file, which will contain a list of strings
touch /tmp/pacmenu-conf
# if file /etc/default/tlp exists, push string "/etc/default/tlp - Configure power management." into /tmp/pacmenu-conf file.
[[ -e /etc/default/tlp ]] && echo "/etc/default/tlp - Configure power management." >> /tmp/pacmenu-conf
[[ -e /etc/profile.d/freetype2.sh ]] && echo "/etc/profile.d/freetype2.sh - Configure TrueType interpreter, including Infinality mode." >> /tmp/pacmenu-conf
[[ -e /etc/pulse/daemon.conf ]] && echo "/etc/pulse/daemon.conf - Configure PulseAudio daemon." >> /tmp/pacmenu-conf
[[ -e /etc/pacman.conf ]] && echo "/etc/pacman.conf - Configure Pacman." >> /tmp/pacmenu-conf
[[ -e /etc/pacman-mirrors.conf ]] && echo "/etc/pacman-mirrors.conf - Configure Manjaro's pacman-mirrors." >> /tmp/pacmenu-conf
[[ -e /etc/pacman.d/mirrorlist ]] && echo "/etc/pacman.d/mirrorlist - Configure mirror list manually. Afterwards, do 'sudo pacman -Syy'." >> /tmp/pacmenu-conf
[[ -e /etc/yaourtrc ]] && echo "/etc/yaourtrc - Configure Yaourt." >> /tmp/pacmenu-conf
[[ -e /etc/makepkg.conf ]] && echo "/etc/makepkg.conf - Configure package compilation." >> /tmp/pacmenu-conf
[[ -e /etc/resolv.conf ]] && echo "/etc/resolv.conf - Configure DNS servers." >> /tmp/pacmenu-conf
[[ -e /etc/hostname ]] && echo "/etc/hostname - Configure your network hostname" >> /tmp/pacmenu-conf
[[ -e /etc/hosts ]] && echo "/etc/hosts - Configure local DNS." >> /tmp/pacmenu-conf
[[ -e /etc/environment ]] && echo "/etc/environment - Configure system-wide environment variables." >> /tmp/pacmenu-conf
[[ -e /etc/slim.conf ]] && echo "/etc/slim.conf - Configure slim display manager." >> /tmp/pacmenu-conf
[[ -e /etc/lightdm.conf ]] && echo "/etc/lightdm.conf - Configure lightdm display manager." >> /tmp/pacmenu-conf
[[ -e /etc/sddm.conf ]] && echo "/etc/sddm.conf - Configure sddm display manager." >> /tmp/pacmenu-conf
[[ -e /etc/mdm/mdm.conf ]] && echo "/etc/mdm/mdm.conf - Configure mdm display manager." >> /tmp/pacmenu-conf
[[ -e /etc/lxdm/lxdm.conf ]] && echo "/etc/lxdm/lxdm.conf - Configure lxdm display manager." >> /tmp/pacmenu-conf
[[ -e /etc/gdm/custom.conf ]] && echo "/etc/gdm/custom.conf - Configure gdm display manager." >> /tmp/pacmenu-conf
[[ -e /etc/entrance/entrance.conf ]] && echo "/etc/entrance/entrance.conf - Configure entrance display manager." >> /tmp/pacmenu-conf
[[ -e /etc/conf.d/xdm ]] && echo "/etc/conf.d/xdm - Configure xdm display manager." >> /tmp/pacmenu-conf
[[ -e $HOME/.bashrc ]] && echo "~/.bashrc - Configure bash shell." >> /tmp/pacmenu-conf
[[ -e $HOME/.zshrc ]] && echo "~/.zshrc - Configure zsh shell." >> /tmp/pacmenu-conf
[[ -e $HOME/.config/fish ]] && echo "~/.config/fish/* - Configure fish shell." >> /tmp/pacmenu-conf
[[ -e $HOME/.xinitrc ]] && echo "~/.xinitrc - Configure X server startup." >> /tmp/pacmenu-conf
[[ -e /etc/fstab ]] && echo "/etc/fstab - Configure file system mount table." >> /tmp/pacmenu-conf
[[ -e /etc/sudoers ]] && echo "/etc/sudoers - Configure sudo." >> /tmp/pacmenu-conf
[[ -e /etc/systemd/logind.conf ]] && echo "/etc/systemd/logind.conf - Configure systemd user logins." >> /tmp/pacmenu-conf
[[ -e /etc/systemd/journald.conf ]] && echo "/etc/systemd/journald.conf - Configure systemd logging." >> /tmp/pacmenu-conf
[[ -e /etc/systemd/system.conf ]] && echo "/etc/systemd/system.conf - Configure systemd system." >> /tmp/pacmenu-conf
[[ -e /usr/lib/systemd/system ]] && echo "/usr/lib/systemd/system/*.timer - Configure all systemd timers." >> /tmp/pacmenu-conf
[[ -e /etc/X11/xorg.conf.d ]] && echo "/etc/X11/xorg.conf.d/* - Configure Xorg display server in multiple files." >> /tmp/pacmenu-conf
[[ -e $HOME/.config/weston.ini ]] && echo "~/.config/weston.ini - Configure Weston compositor." >> /tmp/pacmenu-conf
[[ -e /etc/sysctl.d ]] && echo "/etc/sysctl.d/* - Configure kernel parameters at runtime in multiple files." >> /tmp/pacmenu-conf
[[ -e /etc/mkinitcpio.conf ]] && echo "/etc/mkinitcpio.conf - Configure initial ramdisk environment. Afterwards, do 'sudo mkinitcpio -P && sudo update-grub'." >> /tmp/pacmenu-conf
[[ -e /etc/default/grub ]] && echo "/etc/default/grub - Configure GRUB boot loader. Afterwards, do 'sudo update-grub'." >> /tmp/pacmenu-conf
[[ -e /boot/loader/entries/manjaro.conf ]] && echo "/boot/loader/entries/manjaro.conf - Configure systemd-boot boot loader." >> /tmp/pacmenu-conf
[[ -e /boot/refind_linux.conf ]] && echo "/boot/refind_linux.conf - Configure rEFInd boot loader." >> /tmp/pacmenu-conf
[[ -e /boot/EFI/refind/refind.conf ]] && echo "/boot/EFI/refind/refind.conf - Configure rEFInd boot loader." >> /tmp/pacmenu-conf
[[ -e /boot/EFI/CLOVER/config.plist ]] && echo "/boot/EFI/CLOVER/config.plist - Configure Clover boot loader." >> /tmp/pacmenu-conf
[[ -e /boot/syslinux/syslinux.cfg ]] && echo "/boot/syslinux/syslinux.cfg - Configure syslinux boot loaders." >> /tmp/pacmenu-conf
local file
file=$( cat /tmp/pacmenu-conf | fzf-tmux -e +s -i --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press ENTER to open file. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of files > ' | awk '{print $1}' )
# only run the command inside the if-statement, if $file variable is not empty <-- this happens when fzf is quit with ESC or CTRL+C
if [[ -n $file ]]
then
if [[ $( echo $file | cut -c1 ) == "~" ]]
# if "file"'s first character is a "~" (tilde), the "file" should NOT be opened as root!
then
# if $EDITOR variable does not exist, set it to 'nano'
[[ -z "$EDITOR" ]] && EDITOR='nano'
# open "file" in "EDITOR": (attention: "$file" (including " symbols) does NOT WORK!!!)
$EDITOR $file
elif [[ $file == "/etc/sudoers" ]]
then
# the sudoers file should never be edited directly! if something goes wrong, sudo stops working. instead, visudo should be used. this is much safer.
sudo EDITOR=nano visudo
else
# if $EDITOR variable does not exist, set it to 'nano'
[[ -z "$EDITOR" ]] && EDITOR='nano'
# open "file" in "EDITOR": (attention: "$file" (including " symbols) does NOT WORK!!!)
sudo $EDITOR $file
fi
fi
rm /tmp/pacmenu-conf
}
function func_fix
{
echo "sudo rm -f /var/lib/pacman/db.lck ..." && sudo rm -f /var/lib/pacman/db.lck
echo ""
echo "fixing mirror ..." && sudo pacman-mirrors -g --geoip -t 30 && echo "" && sudo pacman -Syy
echo ""
# check, whether manjaro mirror with the latest packages is reachable
wget --spider http://mirror.netzspielplatz.de/manjaro/
echo ""
# the "wget" command finishes with an exit status/return code. return code 0 means "wget --spider" has finished successfully, i.e. the manjaro mirror can be reached.
if (( "$?" != "0" ))
then
# if the shell return code is not 0, this part of the code runs and the manjaro mirror cannot be reached.
# run the following command in case the internet is working and only the manjaro mirror is down:
sudo pacman -Syyuu --color always --noconfirm
# display error message (ANSI Escape sequences will be explained later):
echo -e "\e[41m Either there is something wrong with your internet connection or http://mirror.netzspielplatz.de/manjaro is down. \e[0m"
echo -e "\e[1;41m Please make sure both are ok and rerun this part of pacmenu, if your Problems persist. \e[0m"
echo ""
else
# the following command sometimes prevents an error connecting to the key server
echo "sudo dirmngr </dev/null ..." && sudo dirmngr </dev/null
echo ""
#declare local variables (needed later)
local {arch,version,url,mybranch}
# store your architecture in "arch" variable (needed later)
arch=$(uname -m)
# extract the name of your used branch from your "/etc/pacman-mirrors.conf" file and store it in "mybranch" variable (needed later)
mybranch=$(awk -F'=' '/^Branch/{gsub(" ","", $2 ); print $2}' /etc/pacman-mirrors.conf)
if [[ $(cat /proc/1/comm) == "systemd" ]] # if init system is systemd
then
# set almost correct time (while ignoring time zone and daylight saving time):
# 1. stop running NTPD service (and ignore output in case NTPD is not installed):
echo "sudo systemctl stop ntpd.service ..." && sudo systemctl stop ntpd.service &>/dev/null
echo ""
# 2. manually download and install networkmanager-dispatcher-ntpd:
echo "installing networkmanager-dispatcher-ntpd ..."
# extract the version number of networkmanager-dispatcher-ntpd in the Manjaro repositories and save it in "version" variable
version="$(lang=C pacman -Si networkmanager-dispatcher-ntpd | awk -F':' ' /^Ver/ {print $2}' | sed 's# #-#' | head -n 1 )"
# save the address of the latest networkmanager-dispatcher-ntpd package on a reliable Manjaro mirror to "url" variable
url="http://mirror.netzspielplatz.de/manjaro/packages/${mybranch}/community/${arch}/networkmanager-dispatcher-ntpd${version}-any.pkg.tar.xz"
wget "${url}" && sudo pacman -U "networkmanager-dispatcher-ntpd${version}-any.pkg.tar.xz" --noconfirm
echo ""
sudo rm "networkmanager-dispatcher-ntpd${version}-any.pkg.tar.xz"
echo ""
# 3. start NTP daemon, set the system clock, and quit
# 4. wait for 20 seconds
# 5. write the time from system clock to hardare clock
sudo ntpd -qg && sleep 20 && sudo hwclock -w
echo ""
fi
# remove gnupg including all keys
echo "sudo rm -r /etc/pacman.d/gnupg &>/dev/null ..." && sudo rm -r /etc/pacman.d/gnupg &>/dev/null
echo ""
# manually download and install gnupg:
echo "installing gnupg ..."
version="$(lang=C pacman -Si gnupg | awk -F':' ' /^Ver/ {print $2}' | sed 's# #-#' | head -n 1 )"
url="http://mirror.netzspielplatz.de/manjaro/packages/${mybranch}/core/${arch}/gnupg${version}-${arch}.pkg.tar.xz"
wget "${url}" && sudo pacman -U "gnupg${version}-${arch}.pkg.tar.xz" --noconfirm && sudo rm "gnupg${version}-${arch}.pkg.tar.xz"
echo ""
# manually download and install archlinux-keyring:
echo "installing archlinux-keyring ..."
version="$(lang=C pacman -Si archlinux-keyring | awk -F':' ' /^Ver/ {print $2}' | sed 's# #-#' | head -n 1 )"
url="http://mirror.netzspielplatz.de/manjaro/packages/${mybranch}/core/${arch}/archlinux-keyring${version}-any.pkg.tar.xz"
wget "${url}" && sudo pacman -U "archlinux-keyring${version}-any.pkg.tar.xz" --noconfirm && sudo rm "archlinux-keyring${version}-any.pkg.tar.xz"
echo ""
# manually download and install manjaro-keyring:
echo "installing manjaro-keyring ..."
version="$(lang=C pacman -Si manjaro-keyring | awk -F':' ' /^Ver/ {print $2}' | sed 's# #-#' | head -n 1 )"
url="http://mirror.netzspielplatz.de/manjaro/packages/${mybranch}/core/${arch}/manjaro-keyring${version}-any.pkg.tar.xz"
wget "${url}" && sudo pacman -U "manjaro-keyring${version}-any.pkg.tar.xz" --noconfirm && sudo rm "manjaro-keyring${version}-any.pkg.tar.xz"
echo ""
echo "sudo pacman-key --init ..." && sudo pacman-key --init && echo "" && echo "sudo pacman-key --populate archlinux manjaro ..." && sudo pacman-key --populate archlinux manjaro
echo ""
echo "sudo pacman -Sc --noconfirm ..." && sudo pacman -Sc --noconfirm
echo ""
if [[ $(cat /proc/1/comm) == "systemd" ]] # if init system is systemd
then
echo "updating systemd ..." && sudo pacman -S --needed --noconfirm libsystemd systemd-sysvcompat systemd && sleep 30
echo ""
fi
sudo pacman -Syyuu --color always --noconfirm
echo ""
sudo pacman -Suu --color always
fi
}
function func_fu
{
sudo pacman -Syu --force --color always
}
function func_e
{
yaourt -Scc
}
function func_fi
{
local pkg
pkg=$(package-query -Sl -f "%n %v - %d" | sort | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to install. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ' | awk '{print $1}' )
if [[ -n $pkg ]]
then
sudo pacman -S --force $pkg --color always
fi
}
function func_fr
{
local pkg
pkg=$(package-query -Q -f "%n %v - %d" | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to remove. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ' | awk '{print $1}' )
if [[ -n $pkg ]]
then
sudo pacman -Rdd $pkg --color always
fi
}
# =======================
function func_ua
{
yaourt -Syua && yaourt -Syua --devel --needed --noconfirm
}
function func_a
{
local pkg
if [[ -n "$input2" ]]
then
# do this if variable "input" is not empty:
yaourt "$input2"
else
# do this if pacmenu is used with UI or no argument is specified in "pacmenu a" command:
echo "Enter (parts of) name and/or description of package to be searched. Then press ENTER."
read -r pkg
yaourt $pkg
fi
}
function func_ia
{
# check, whether file /tmp/pacmenu-packages already exists (the ! negates the result)
if ! [[ -e /tmp/pacmenu-packages ]]
then
# write package list of manjaro repositories to /tmp/pacmenu-packages. then, download AUR package list, unzip it to /tmp/aur/packages, and add it to the bottom of /tmp/pacmenu-packages.
pacman -Slq > /tmp/pacmenu-packages
wget -P /tmp/aur/ https://aur.archlinux.org/packages.gz >/dev/null 2>&1 && gunzip -f /tmp/aur/packages.gz && cat /tmp/aur/packages >> /tmp/pacmenu-packages
fi
local pkg
pkg=$(sort /tmp/pacmenu-packages | fzf-tmux -m -e +s -i -1 --query="$input2" --cycle --reverse --margin=4%,1%,1%,2% --inline-info --header="Press TAB to (un)select. Press ENTER to install. Press ESC or CTRL+C to quit." --prompt='Enter string to filter displayed list of packages > ')
if [[ -n $pkg ]]
then
yaourt -S $pkg
fi
}
function func_la
{
pacman -Qem --color always
}
# =======================
function func_helpD
{
echo
echo -e " pacmenu h - this \e[1mH\e[0melp message - a detailed help can be viewed from the menu"
echo
echo -e " pacmenu - \e[1mpacmenu\e[0m with textual menu, when called without CLI parameters"
echo
echo -e " pacmenu u - \e[1mU\e[0mpdate System"
echo -e " pacmenu c - \e[1mC\e[0mlean System"
echo -e " pacmenu i - \e[1mI\e[0mnstall Packages"
echo -e " pacmenu r - \e[1mR\e[0memove Packages + Deps"
echo -e " pacmenu info - Package \e[1mInfo\e[0mrmation"
echo -e " pacmenu l - \e[1mL\e[0mist Local Package Files"
echo -e " pacmenu t - Dependency \e[1mT\e[0mree"
echo -e " pacmenu rt - \e[1mR\e[0meverse Dependency \e[1mT\e[0mree"
echo
echo -e " pacmenu log - Pacman \e[1mLog\e[0m"
echo -e " pacmenu s - Reverse File \e[1mS\e[0mearch"
echo -e " pacmenu d - \e[1mD\e[0mowngrade Packages"
echo -e " \e[31mpacmenu conf \e[0m- \e[1mConf\e[0migure System"
echo -e " \e[31mpacmenu fix \e[0m- \e[1mFix\e[0m Pacman Errors"
echo -e " \e[31mpacmenu fu \e[0m- \e[1mF\e[0morce \e[1mU\e[0mpdate System"
echo -e " \e[31mpacmenu e \e[0m- \e[1mE\e[0mmpty Package Cache"
echo -e " \e[31mpacmenu fi \e[0m- \e[1mF\e[0morce \e[1mI\e[0mnstall Packages"
echo -e " \e[31mpacmenu fr \e[0m- \e[1mF\e[0morce \e[1mR\e[0memove Packages"
echo
echo -e " pacmenu ua - Force \e[1mU\e[0mpdate \e[1mA\e[0mUR"
echo -e " pacmenu la - \e[1mL\e[0mist Installed from \e[1mA\e[0mUR"
echo -e " pacmenu a - Search + Install from \e[1mA\e[0mUR"
echo -e " pacmenu ia - \e[1mI\e[0mnstall from \e[1mA\e[0mUR"
echo
}
# the help function was put at the end of all functions for convenience
function func_h
{
# the "then" part is displayed when started directly from terminal (the last function adds the "1" parameter). the "else" part gets displayed when started from UI.
if [[ "$1" == "1" ]]
then
echo
echo -e " pacmenu h - this \e[1mH\e[0melp message - a detailed help can be viewed from the menu"
echo
echo -e " pacmenu - \e[1mpacmenu\e[0m with textual menu, when called without CLI parameters"
echo
echo -e " pacmenu u - \e[1mU\e[0mpdate System"
echo -e " pacmenu c - \e[1mC\e[0mlean System"
echo -e " pacmenu i - \e[1mI\e[0mnstall Packages"
echo -e " pacmenu r - \e[1mR\e[0memove Packages + Deps"
echo -e " pacmenu info - Package \e[1mInfo\e[0mrmation"
echo -e " pacmenu l - \e[1mL\e[0mist Local Package Files"
echo -e " pacmenu t - Dependency \e[1mT\e[0mree"
echo -e " pacmenu rt - \e[1mR\e[0meverse Dependency \e[1mT\e[0mree"
echo
echo -e " pacmenu log - Pacman \e[1mLog\e[0m"
echo -e " pacmenu s - Reverse File \e[1mS\e[0mearch"
echo -e " pacmenu d - \e[1mD\e[0mowngrade Packages"
echo -e " \e[31mpacmenu conf \e[0m- \e[1mConf\e[0migure System"
echo -e " \e[31mpacmenu fix \e[0m- \e[1mFix\e[0m Pacman Errors"
echo -e " \e[31mpacmenu fu \e[0m- \e[1mF\e[0morce \e[1mU\e[0mpdate System"
echo -e " \e[31mpacmenu e \e[0m- \e[1mE\e[0mmpty Package Cache"
echo -e " \e[31mpacmenu fi \e[0m- \e[1mF\e[0morce \e[1mI\e[0mnstall Packages"
echo -e " \e[31mpacmenu fr \e[0m- \e[1mF\e[0morce \e[1mR\e[0memove Packages"
echo
echo -e " pacmenu ua - Force \e[1mU\e[0mpdate \e[1mA\e[0mUR"
echo -e " pacmenu la - \e[1mL\e[0mist Installed from \e[1mA\e[0mUR"
echo -e " pacmenu a - Search + Install from \e[1mA\e[0mUR"
echo -e " pacmenu ia - \e[1mI\e[0mnstall from \e[1mA\e[0mUR"
echo
else
## TODO this text format sucks huge time, launch yad or sth.
less -Ri <<-EOF
Welcome to Pacmenu's Help Page.
Pacmenu is an interactive package manager for your command line terminal. It provides an easy user interface and uses Pacman and Yaourt as back ends. Additionally, it uses some Manjaro exclusive commands. pacmenu offers you the most common and useful features for managing your packages.
Navigate this help page with your Arrow Keys, PageUp/PageDown Keys, SpaceBar, or your Mouse Wheel. To search this Help Page, enter /<SEARCH TERM> and press ENTER. For example, enter the following (without quotes " ") in order to search for update: "/update". Search is not case sensitive. To exit this Help Page, press your "q" key.
Most options in pacmenu use fuzzy finder (fzf), which means by starting to type you can search the displayed list. Use your TAB key to select multiple items from the list and your ENTER key to choose your selection. Navigate fzf's list the same way you navigate this help page.
HOME SCREEN
pacmenu's home screen is split into three parts:
1. The first part focuses on updates, maintenance, installations, and removals of packages from Manjaro's repositories. It includes useful tools for these actions, too.
2. The second part includes options for fixing your system. Options, which can break your system, are marked in red.
3. The last part offers Arch User Repository (AUR) management options.
0 - QUIT pacmenu
"clear && exit"
This will clear your terminal an quit pacmenu.
1 - UPDATE SYSTEM
"sudo pacman -Syu"
"yaourt -Syua"
The first command compares a list of all installed packages with package database on your Manjaro repository mirror/server. If an updated package is available from the Manjaro repositories, it will get downloaded and installed on your system.
The second command does the same as the first part, but with one exception: It also downloads, compiles, and installs all packages from the Arch User Repository (AUR), which have an updated PKGBUILD file. The first command is still needed occasionaly, because major Pacman and Yaourt updates require "pacman -Syu" and will fail when started with Yaourt.
ATTENTION: When a new version of an AUR package is available, often the PKGBUILD file is not updated. If you want to install the latest version of a single AUR package, (re-)install it with INSTALL FROM AUR. If you want to install the latest versions of ALL AUR packages FORCE UPDATE AUR.
2 - CLEAN SYSTEM
"sudo pacman-mirrors -g -t 30 && sudo pacman -Syy"
This command tests your connection to all available Manjaro repository mirrors/servers. The mirror with the best connection is automatically chosen for you. Additionally, the latest package database is downloaded from the chosen Manjaro repository mirror.
If you want to speed up this command, it is recommended to only test your connection quality to Manjaro mirrors/servers near you. Example: You have noticed the pings to German and French mirrors are always best for you. Then, you can run: "sudo pacman-mirrors -g -t 30 -c Germany,France && sudo pacman -Syy"
"yaourt -Qdt"
This option lists all orphaned packages on your system. Orphaned packages are old and no longer needed dependencies (packages not explicitly installed by you), which were never removed from your system.
"sudo journalctl --vacuum-size=50M --vacuum-time=30days"
This command limits all log files in journalctl to a combined size of 50 megabytes and a maximum age of 30 days. This leaves plenty of log files behind to analyze systematic and reoccuring errors while preventing excessive amounts of log files.
"paccache -ruvk1"
"paccache -rvk2"
By default Pacman uses this cache directory for downloading packages: /var/cache/pacman/pkg/... . No cached packages get deleted automatically. This enables you to DOWNGRADE PACKAGES, which are broken, without a working internet connection. The package cache of an old and actively used Manjaro installation can become quite large. Clean it to regain space on your root partition.
The first command removes all packages from cache, which are not installed (anymore) on your system, except the latest version.
The second command removes all old packages from your cache except the 2 latest versions: The version you have currently installed on your system and the previous version. Old package versions are kept to enable you to manually DOWNGRADE PACKAGES even without a working internet connection.
"sudo pacman-optimize" (only when Manjaro is installed on a HDD)
This command effectively defragments your Pacman database.
On traditional hard drives (HDD) this command can speed up all actions related to Pacman.
ATTENTION: It is NOT recommended to use this command on modern solid state hard drives (SSDs)!
3 - INSTALL PACKAGES
"sudo pacman -S <PACKAGE NAME>"
This option downloads and installs <PACKAGE NAME> on your system. <PACKAGE NAME> must be a package from the Manjaro repositories. If you want to install a package from the AUR choose INSTALL FROM AUR or SEARCH + INSTALL FROM AUR.
4 - REMOVE PACKAGES + DEPS
"sudo pacman -Rsn <PACKAGE NAME>"
This command removes <PACKAGE NAME> from your system including all dependencies, which are no longer needed by other packages. A copy of <PACKAGE NAME> will be kept in your package cache: Run CLEAN SYSTEM to remove it.
Please note that folders in your home (~) directory and created by the program <PACKAGE NAME> will not get removed from your system. Look for such folders in these places and remove them manually:
~/
~/.config/
~/.local/share/
ATTENTION: If you want to display a list of all your installed packages (including their version number and description) use this pacmenu option. Simply do not select <PACKAGE NAME> to be removed, but quit the list view with ESC or CTRL+C.
5 - PACKAGE INFORMATION
"yaourt -Sii <PACKAGE NAME>" or "yaourt -Qii <PACKAGE NAME>"
This command displays a lot of information about <PACKAGE NAME>. Different pieces of information get displayed depending on package source (Manjaro repository or AUR) and package state (installed or not installed).
6 - LIST LOCAL PACKAGE FILES
"pacman -Qlq <PACKAGE NAME>"
This command lists all files contained in <PACKAGE NAME> including their path. <PACKAGE NAME> must be installed on your system.
Have you ever installed a program and did not know with which command it can be started/executed? Just look for files (and their names) in your /usr/bin/ directory using LIST LOCAL PACKAGE FILES.
By default all files are filtered for files located in /usr/bin/, but you can enter any filter term you want to. Delete the default filter term with BACKSPACE to see a complete list of files of <PACKAGE NAME>. Please note that all selected lines (toggle selection with your TAB key) will get added to file /tmp/pacmenu-list.
7 - DEPENDENCIES TREE
"pactree -s <PACKAGE NAME>" or "pactree <PACKAGE NAME>"
This command will display a complete tree of all dependencies of <PACKAGE NAME>. <PACKAGE NAME> can be an installed package or a package from the Manjaro repositories. Dependencies are packages required by <PACKAGE NAME> in order to function. When you install <PACKAGE NAME>, all its dependencies get installed, too.
The first command gets used when <PACKAGE NAME> is not installed on your local system.
8 - REVERSE DEPENDENCIES TREE
"pactree -r <PACKAGE NAME>"
This command will display a tree of installed packages, which depend on <PACKAGE NAME>. In other words: All displayed packages require <PACKAGE NAME> in order to function (properly).
Use this command when you want to know why you cannot remove <PACKAGE NAME> from your system.
9 - PACMAN LOG
"tail -5000 /var/log/pacman.log"
The Pacman Log contains all updates, installations, and removals (also in the AUR) you have done. Whenever something breaks on your system (e.g. after an udpate), but you do not remember anymore which packages were changed recently (e.g. during the last update), take a look at your Pacman Log and find out. Then, DOWNGRADE PACKAGES, which you think might be broken.
This command displays the last 5000 lines of your Pacman Log and makes it searchable with fzf. Please note that all selected lines (toggle selection with your TAB key) will get added to file /tmp/pacmenu-log.
10 - REVERSE FILE SEARCH
"pacman -Ql | grep <FILE NAME>"
This command searches for <FILE NAME> in all your installed packages. The result is a list of (bold) package names including the installation path of <FILE NAME>.
Every package contains multiple packages, which get installed on your system during package installation. You can LIST LOCAL PACKAGE FILES to see them all (Attention: By default only files in /usr/bin/ are listed).
Sometimes, Pacman cannot find a file, for example a shared library. An error message is shown with <FILE NAME>. Use REVERSE FILE SEARCH to find out, which package has installed <FILE NAME>. In most cases, you can fix the Pacman error by using one of the following options with that package: UPDATE SYSTEM, FORCE REMOVE PACKAGES and INSTALL PACKAGES, FORCE UPDATE SYSTEM, or DOWNGRADE PACKAGES.
11 - DOWNGRADE PACKAGES
"downgrade <PACKAGE NAME>"
Manjaro uses a rolling release development model. This means ALL packages on your system continuously get updated to the latest version. If the latest version of a packages does not work on your system, you can downgrade that package to an earlier, working version.
This command downgrades <PACKAGE NAME> and offers you a list of old <PACKAGE NAME> versions to choose from. This list includes all old <PACKAGE NAME> versions from your local package cache and online sources (if you have a working internet connection).
After a successful downgrade, you can add <PACKAGE NAME> to your Ignore List ( "IgnorePkg" option in /etc/pacman.conf ). This will prevent Pacman from showing any available updates for <PACKAGE NAME>. <PACKAGE NAME> needs to be removed manually from your Ignore List in order to receive automatic updates of <PACKAGE NAME> again.
Alternatively, you can run future updates with the command "sudo pacman -Syu --ignore <PACKAGE NAME>" until a fixed version of <PACKAGE NAME> gets released.
ATTENTION: Be careful when downgrading to <PACKAGE NAME> from online sources, because these are old versions from the Arch Linux repositories and not the Manjaro repositories: In the worst case, this can brake your system! Therefore, it is recommended to limit downgrading to (old versions of) local packages, if possible.
ATTEMTION: Downgrading to a working version of <PACKAGE NAME> can break your system in in rare cases like the following: The latest system update has replaced a dependency of <PACKAGE NAME> with a different package and <PACKAGE NAME> is an important system package. Downgrading <PACKAGE NAME> will NOT reinstall the dependency of <PACKAGE NAME>, because it conflicts with the already installled different package. This can result in a broken system. Please keep these kind of conflicts in mind when using DOWNGRADE PACKAGES.
11 - ROLL BACK SYSTEM
"sudo pacman -Rdd <PACKAGE NAME>" (only for installed packages)
"sudo pacman -S <PACKAGE NAME>" (only for remove packages)
"sudo pacman -U <FILE NAME>" (only for upgraded packages)
Manjaro uses a rolling release development model. This means ALL packages on your system continuously get updated to the latest version. Sometimes, Things go wrong during UPDATE SYSTEM and you should roll back the last update.
This command shows you a list of all recent Pacman action sorted by date. Please select all Pacman actions you want to roll back. Installed packages will be removed from your system, removed packages will be reinstalled, and upgraded packages will be downgraded to the second latest version in your local package cache.
Attention: When you found a package upgrade, which broke a working package, it is recommende to add this package to your Ignore List ( "IgnorePkg" option in /etc/pacman.conf ). This will prevent Pacman from showing any available updates for this package. The package needs to be removed manually from your Ignore List in order to receive automatic updates for it again. Alternatively, you can run future updates with the command "sudo pacman -Syu --ignore <PACKAGE NAME>" until a fixed version of that package gets released.
12 - HELP
Display this help page.
13 - CONFIGURE SYSTEM
"$EDITOR <FILE NAME>"
This command opens <FILE NAME> in your default text editor. You can choose between multiple important system configuration files. Files in the root directory are opened with root privileges.
By default the text editor Nano gets used, except a custom $EDITOR variable has been exported. In the text editor Nano, Press CTRL+O to save your changes, ENTER to choose a directory, and CTRL+X to quit Nano.
ATTENTION: Changing system configuration files can harm or even destroy your system. In some cases, this can happen with a single mistake. Be extremely careful and always double check your changes before saving and rebooting! It is recommended to search the Arch Wiki for the configuration file you want to edit and read about available and recommended settings.
14 - FIX PACMAN ERRORS
Multiple commands attempt to fix the most common issues Manjaro users have with Pacman. Force options (as in FORCE UPDATE SYSTEM) are excluded, even though they are essential in fixing some problems.
A working internet connection is required.
"sudo rm -f /var/lib/pacman/db.lck"
This command removes Pacman's database lock. The database lock prevents multiple Pacman instances from running at the same time and interfering with each other.
ATTENTION: Only run this command when no other Pacman instance (e.g. Pacman, Yaourt, Pamac, Octopi, PacmanXG4, ...) is running.
"sudo pacman-mirrors -g -t 30 --geoip && sudo pacman -Syy"
The first command searches for working and good Manjaro repository mirrors/servers in your country (if available) or all countries (if no mirrors/server is available in your country). It will automatically choose the closest server for you. This might not be the fastest mirror/server to download from, but it is definitely not a bad choice.
The second command forces a redownload of the latest package database from the chosen Manjaro repository mirror server.
"sudo dirmngr </dev/null"
Sometimes during key management the package "dirmngr" outputs error messages, which interrupt key management processes (such as the following commands). This command prevents any output from "dirmngr".
"sudo systemctl stop ntpd.service &>/dev/null"
This command stops (temporarily) the Network Time Protocol daemon service NTPD (if it is installed and running). In case NTPD is not installed, the output is ignored.
This is the first command of a series of commands, which try to set the system and hardware clock on your computer (ignoring time zone and daylight saving time). An (almost) correct system time is needed for checking and importing keys or fingerprints later on in the fixing process!
"sudo pacman -Sy networkmanager-dispatcher-ntpd"
This command (re-)installs the "networkmanager-dispatcher-ntpd" package. pacmenu actually does not use this command but instead downloads and installs this package manually in order to bypass key database and key chain errors.
ATTENTION: pacmenu will fail if you cannot install any packages on your system anymore due to key database and key chain errors AND "networkmanager-dispatcher-ntpd" was not installed on your system before. As long as your system clock is set (almost) correct, you do not have to worry about it. But if your system clock is set completely wrong AND you cannot install any packages on your system anymore AND "networkmanager-dispatcher-ntpd" was not installed on your system before, your have to set your system clock manually before you run pacmenu's "fix" command. You can do this with the following command:
sudo timedatectl set-time "yyyy-MM-dd hh:mm:ss"
( example: sudo timedatectl set-time "2016-05-26 11:13:54" )
"sudo ntpd -qg && sleep 20 && sudo hwclock -w"
The first command starts the just (re-)installed Network Time Protocol daemon (ntpd.service). Next, your system clock is set. Finally, the ntpd.service is quit.
The second command makes your system wait for 20 seconds. This is done as precaution to ensure your system has enough time to connect to an internet or network server and set the system clock.
The third command is only run when the first and second command have been successfully finished. It writes the time from your system clock to your hardware clock.
ATTENTION: The last command is needed in order to prevent another services on your system to set your system clock according to your hardware clock in regular intervals. This may result in a hardware clock, which is not set to UTC anymore and/or a system clock, which shows the wrong time. If you encounter this problem read the Arch Linux Wiki article about time: "https://wiki.archlinux.org/index.php/Time"
"sudo rm -r /etc/pacman.d/gnupg &>/dev/null"
This command deletes your Pacman, Manjaro, and Arch key database. It does not output an error in case the package "gnupg" is not installed on your system.
ATTENTION: This command will remove all keys from your system, including manually installed keys (with "sudo pacman-key --lsign-key <KEY>"). Please remember to reinstall those keys again after FIX PACMAN ERRORS has completed!
"sudo pacman -Sy gnupg archlinux-keyring manjaro-keyring"
This command (re-)installs the "gnupg", "archlinux-keyring", and "manjaro-keyring" packages and keyrings for Arch Linux and Manjaro. pacmenu actually does not use this command but instead downloads and installs this package manually in order to bypass key database and key chain errors.
ATTENTION: If you want to execute this command on a system with key database problems, it will not work for you! In this case, connect manually (via your browser) to your Manjaro repository server, download these packages, and install these packages manually. pacmenu will do all of this automatically for you. If this part of pacmenu fails, please wait a couple of hours until your Manjaro mirror has synchronized with the main Manjaro repository and offers the latest version of these 4 packages: networkmanager-dispatcher-ntpd,gnupg, archlinux-keyring, manjaro-keyring.
"sudo pacman-key --init && sudo pacman-key --populate archlinux manjaro"
These two commands create a fresh key for you and import and (re-)install all keys from Arch Linux and Manjaro. This will solve problems with your local key database and Manjaro's and Arch's key database. Such problems can occur when new new Arch Linux or Manjaro packagers get added, for example.
ATTENTION: This command might take a long time to complete. If your system appears to stop or hang, it searches for entropy in order to generate a new key for you. In this case, it might help to do file operations with a lot of reads and/or writes per minute (such as searching for files, copying large directories, etc.). Alternatively, you can open a browser and do some heavy surfing (with a lot of mouse movements, mouse klicks, and keyboard key presses): This can help to generate entropy much faster.
"sudo pacman -Sc"
After an unseccessful attempt to update your system (which quit with a key error), you might have already downloaded unsigned packages to your pacman cache. These packages cannot be installed anymore.
This command removes all packages from your pacman cache, which are not installed on your system. Afterwards, you need to download all previously downloaded but not installed packages again.
ATTENTION: This command makes it impossible to DOWNGRADE PACKAGES on systems without an active internet connection.
"sudo pacman -S --needed libsystemd systemd-sysvcompat systemd && sleep 30"
The first command updates - if necessary - systemd including important components before all other packages are updated. This is necessary, because sometimes a successful update of systemd causes a short crash on some systems, which prevents a successful update of all other packages.
The second command simply does nothing for 30 seconds before the update of all other packages get started. It is only here as precaution.
"sudo pacman -Syyuu"
This last command forces a redownload of the latest package database from the best Manjaro repository mirror. Then, all your installed packages are checked against this latest package database. If an updated package is available from the Manjaro repositories, it will get downloaded and installed on your system. If an installed package is newer than the same package in the Manjaro repositories, the installed package will get downgraded. This behavior ensures your packages are always in sync with the Manajro repositories, even if you have just switched the Manjaro mirror or switched from unstable to stable branch.
"sudo pacman -Suu"
This command makes sure all downloaded packages get installed and downgraded if necessary. The user has to manually allow downgrades of packages, if downgrades are available.
15 - FORCE UPDATE SYSTEM
"sudo pacman -Syu --force"
This command does the same as UPDATE SYSTEM, but it bypasses file conflict tests and overwrites conflicting files. All files will be overwritten.
16 - EMPTY PACKAGE CACHE
"yaourt -Scc"
This command will empty your entire package cache by deleting ALL packages.
ATTENTION: This will make it impossible to reinstall old (or currently installed) packages or DOWNGRADE PACKAGES without a working internet connection.
17 - FORCE INSTALL PACKAGES
"sudo pacman -S --force <PACKAGE NAME>"
This command does the same as INSTALL PACKAGES, but it forces the installation of <PACKAGE NAME>.
18 - FORCE REMOVE PACKAGES
"pacman -Rdd <PACKAGE NAME>"
This command removes <PACKAGE NAME> without checking the dependencies of <PACKAGE NAME> first. This enables experienced users to remove packages and dependencies of packages. This command only removes <PACKAGE NAME> from your system. All dependencies and orphans are left: run CLEAN SYSTEM afterwards to remove them.
ATTENTION: This command can break pacakges on your system or even your entire system.
19 - FORCE UPDATE AUR
"yaourt -Syua && yaourt -Syua --devel --needed --noconfirm"
The Arch User Repository (AUR) is a repository of (mostly) PKGBUILD files. Everybody can create such a PKGBUILD file and upload it to the AUR. A PKGBUILD file contains simple and human readable instructions like where to download the source code from, what dependencies are needed, where to copy files for installation, etc. Yaourt is a so called AUR Helper: It can interpret PKGBUILD files and download the source code, install dependencies, build files on your system, and copy these files to the right location (a.k.a. installing a program).
By checking a PKGBUILD file (and .INSTALL file) you can make sure the source code is loaded from an official download server, no harmful dependencies get installed, and the installation instructions do not contain harmful code.
A lot of PKGBUILD files contain variables (e.g. program version) in download addresses; this makes them download always the latest source code (e.g. from Github) during installation. Some PKGBUILD files contain no variables: These PKGBUILD files need to be changed manually every time a new program version is released.
The first command of FORCE UPDATE AUR does the same as the second command of UPDATE SYSTEM: Only AUR packages with updated/changed PKGBUILD files will get updated. This gives you the chance to check these updated/changed PKGBUILD files.
The second command of FORCE UPDATE AUR forces a reinstall of ALL your developmental AUR packages (i.e. all git, svn, and cvs-packages). These kinds of AUR packages are usually never updated/reinstalled with a simple "yaourt -Syua". The "--noconfirm" flag is used in a secure way, because no PKGBUILD files have changed since the first command got executed.
ATTENTION: This might take a long time! By default, after every 15min this command will pause and ask again for your password.
20 - LIST INSTALLED FROM AUR
"pacman -Qem"
This command lists all installed packages, which are from the AUR or which were manually installed.
If you want a list of all installed packages use REMOVE PACKAGES + DEPS as described in this Help Page.
21 - SEARCH + INSTALL FROM AUR
"yaourt <PACKAGE NAME>"
This command searches for <PACKAGE NAME> in all Manjaro repositories and the Arch User Repository (AUR). It searches for package names and package descriptions.
Example: You can search for "web browser" and you will find Firefox and other web browsers. One or multiple search results can be installed on your system.
If you want to exit this mode without installing any packages, simply press CTRL+C or ENTER.
22 - INSTALL FROM AUR
"yaourt -S <PACKAGE NAME>"
This command does the same as INSTALL PACKAGES. Additionally, Arch User Repository (AUR) packages can be installed.
ATTENTION: Experienced users can install packages from the AUR without the need to answer questions all the time by using the command "yaourt -S <PACKAGE NAME> --noconfirm". The "--noconfirm" flag is great for quick and dirty installations of AUR packages on non-secure systems. Please keep always in mind that the AUR can contain any sort of package - including malicious and destructive (parts of) packages. Therefore, it is recommended to always check the PKGBUILD and .INSTALL file manually before installing a package from the AUR.
To exit this Help Page, press "q".
EOF
fi
}
# all functions of pacmenu end here.
# =======================
# the following section of code gets executed when this script gets executed directly from a terminal/tty without using the UI:
# write first argument of "pacmenu ..." to "input" variable.
input=$1
# wirte all other arguments of "pacmenu $1 ..." to "input2" variable. all arguments gets combined into one variable with spaces, but no breaks.
#fzf will always display search results for "input2", if it exists (and "input" is a valid function"). if "input2" is not found in fzf's list, NOTHING is displayed.
input2=${*:2}
# if "input" starts with a "-" or "--" symbol, the "-" symbol(s) gets removed from the beginnig of "input" variable
input=${input#-}
input=${input#-}
# convert content of "input" variable to lowercase
input=$(echo "$input" | tr '[:upper:]' '[:lower:]' )
# the following code checks, whether a prefix (func_) + varialbe "input" is a valid function defined above. after the function is done an "exit" command is needed to prevent the UI from loading.
if [[ $(type -t "func_$input") == "function" ]]
then
"func_$input" 1 # pass the parameter "1" with the funciton when it gets called directly from terminal.
unset input
unset input2
exit $? # exit here and return error code if present
elif (( $# > 0 )) # if "func_$input" is no valid function AND if one or more arguments are given.
then
unset input
unset input2
# error, if $input does not refer to a valid function. the UI will be started by default.
# echo -e "Bad console command. Press ENTER to start pacmenu's UI or CTRL+C to abort."
# this is assinine. be helpful to the user and dont bullshit him with crap error messages
func_helpD
read
# now, continue with this script without exiting.
fi
# =======================
# =======================
# =======================
function pacmenu_clean
{
# the traditional "clear" command does not work as expected on all systems. solution: do everything i expect from "clear" manually:
# number of lines of the user's terminal.
lines=$(tput lines)
for (( i=1; i<=lines; i++ ))
do
# insert "lines" number of empty lines:
echo
done
# move cursor to the top left of the terminal
tput cup 0 0
}
# ANSI Escape sequences:
# \e[31m # red text
# \e[41m # red background
# \e[0m # no-colored, non-bold text without background color
# \e[1m # bold text
# Run infinte loop for UI / menu, till the user quits.
while true
do
pacmenu_clean
# draw UI / menu. please note the use of ANSI Escape sequences mentioned above. The text/code can be hard to read...
echo
echo -e " \e[0m pacmenu - pacman helper & Package manager "
echo -e " ┌────────────────────────────────────────────────────────────────────┐"
echo -e " │ 1 \e[1mU\e[0mpdate System 2 \e[1mC\e[0mlean System │"
echo -e " │ 3 \e[1mI\e[0mnstall Packages 4 \e[1mR\e[0memove Packages + Deps │"
echo -e " │--------------------------------------------------------------------│"
echo -e " │ 5 Package \e[1mInfo\e[0mrmation 6 \e[1mL\e[0mist Local Package Files │"
echo -e " │ 7 Dependency \e[1mT\e[0mree 8 \e[1mR\e[0meverse Dependency \e[1mT\e[0mree │"
echo -e " └────────────────────────────────────────────────────────────────────┘"
echo -e " ┌────────────────────────────────────────────────────────────────────┐"
echo -e " │ 9 Pacman \e[1mLog\e[0m 10 Reverse File \e[1mS\e[0mearch │"
echo -e " │ 11 \e[1mD\e[0mowngrade Packages 12 \e[1mH\e[0melp │"
echo -e " │ \e[31m13 \e[1mConf\e[0;31migure System 14 \e[1mFix\e[0;31m Pacman Errors \e[0m │"
echo -e " │ \e[31m 15 \e[1mF\e[0;31morce \e[1mU\e[0;31mpdate System 16 \e[1mE\e[0;31mmpty Package Cache \e[0m │"
echo -e " │ \e[31m 17 \e[1mF\e[0;31morce \e[1mI\e[0;31mnstall Packages 18 \e[1mF\e[0;31morce \e[1mR\e[0;31memove Packages \e[0m │"
echo -e " └────────────────────────────────────────────────────────────────────┘"
echo -e " ┌────────────────────────────────────────────────────────────────────┐"
echo -e " │ 19 Force \e[1mU\e[0mpdate \e[1mA\e[0mUR 20 \e[1mL\e[0mist Installed from \e[1mA\e[0mUR │"
echo -e " │ 21 Search + Install from \e[1mA\e[0mUR 22 \e[1mI\e[0mnstall from \e[1mA\e[0mUR │"
echo -e " └────────────────────────────────────────────────────────────────────┘"
echo
#echo -e " Enter number or marked letter(s) and press [Enter] - 0 \e[1mQ\e[0muit pacmenu "
echo -e " Enter number and press [Enter] - 0 \e[1mQ\e[0muit pacmenu "
# read -s -n1 keypress
# case $keypress in
# $'\e') pacmenu_clean && exit && echo "Escape" ;;
# esac
#### ESC quits immediately -- breaks CLI param
# save entered number in varialbe "choice" and test, whether "chioce" fits any of the following numbers, letters, or words
read -r choice
# choice = keypress + choice
# convert "choice" variable to lowercase:
choice=$(echo "$choice" | tr '[:upper:]' '[:lower:]' )
echo
case $choice in
# this line means: the following commands will get executed if $choice is "1" or "u" or "update" until a ";;" code line is encountered:
1|u|update)
# call function "func_u"
func_u
echo
echo -e " System updated. To return to pacmenu press ENTER "
# wait for input, e.g. by pressing ENTER
read
;;
2|c|clean)
func_c
echo
echo -e " System cleaned. To return to pacmenu press ENTER "
read
;;
3|i|install)
func_i
echo
echo -e " Package installation finished. To return to pacmenu press ENTER "
read
;;
4|r|remove)
func_r
echo
echo -e " Package(s) including all unneeded dependencies removed. To return to pacmenu press ENTER "
read
;;
5|info|information)
func_info
echo
echo -e " Package information displayed. To return to pacmenu press ENTER "
read
;;
6|l|list)
func_l
echo
;;
7|t|tree)
func_t
echo
echo -e " Dependency tree displayed. Navigate with SHIFT+PageUp. To return to pacmenu press ENTER "
read
;;
8|rt|reversetree)
func_rt
echo
echo -e " Reverse dependency tree displayed. Navigate with SHIFT+PageUp. To return to pacmenu press ENTER "
read
;;
9|log)
func_log
echo
;;
10|s|search)
func_s
echo
echo -e " All packages listed. To return to pacmenu press ENTER "
read
;;
11|d|down|downgrade)
func_d
echo
echo -e " Downgrade finished. To return to pacmenu press ENTER "
read
;;
12|00|111|h|help)
func_h
echo
;;
13|conf|config|configure)
func_conf
echo
;;
14|fix)
func_fix
echo
echo -e " Operation finished. To return to pacmenu press ENTER "
read
;;
15|fu|forceupdate)
func_fu
echo
echo -e " System updated in force mode. To return to pacmenu press ENTER "
read
;;
16|e|empty)
func_e
echo
echo -e " Entire package cache emptied. To return to pacmenu press ENTER "
read
;;
17|fi|forceinstall)
func_fi
echo
echo -e " Package installation in force mode finished. To return to pacmenu press ENTER "
read
;;
18|fr|forceremove)
func_fr
echo
echo -e " Package(s) removed in force mode. To return to pacmenu press ENTER "
read
;;
19|ua|fua|forceupdateaur|updateaur)
func_ua
echo
echo -e " All AUR packages updated and reinstalled. To return to pacmenu press ENTER "
read
;;
20|la|listaur)
func_la
echo
echo -e " All locally installed packages listed. To return to pacmenu press ENTER "
read
;;
21|a|aur)
func_a
echo
echo -e " Yaourt finished. To return to pacmenu press ENTER "
read
;;
22|ia|installaur)
func_ia
echo
echo -e " Installation from AUR finished. To return to pacmenu press ENTER "
read
;;
0|Q|q|quit)
pacmenu_clean && exit
;;
$'\e')
pacmenu_clean && exit
;;
# use ESC key throughout whole pacmenu
*)
echo -e " \e[41m unrecognized option \e[0m"
echo -e " oops, sorry ! "
#echo $choice > errchc
sleep 2
;;
esac # close case-loop
done # close while-loop
# TODO :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment