initial commit
This commit is contained in:
commit
2dee14af5f
9 changed files with 598 additions and 0 deletions
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Ignore everything
|
||||
*
|
||||
|
||||
# But not these files...
|
||||
!.gitignore
|
||||
!LICENSE
|
||||
!Makefile
|
||||
!README.md
|
||||
!/common
|
||||
!/common/bash-completion
|
||||
!/common/night-theme-switcher.in
|
||||
!/common/nts.skel
|
||||
!/common/zsh-completion
|
||||
!/doc
|
||||
!/doc/clean-chroot-manager.1
|
||||
12
LICENSE
Normal file
12
LICENSE
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Copyright (C) 2025 by Christian Schendel <doppelhelix@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
46
Makefile
Normal file
46
Makefile
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
VERSION = 0.01
|
||||
PN = night-theme-switcher
|
||||
|
||||
PREFIX ?= /usr
|
||||
BASHCDIR = $(PREFIX)/share/bash-completion/completions
|
||||
BINDIR = $(PREFIX)/bin
|
||||
DOCDIR = $(PREFIX)/share/doc/$(PN)-$(VERSION)
|
||||
MANDIR = $(PREFIX)/share/man/man1
|
||||
SKELDIR = $(PREFIX)/share/$(PN)
|
||||
ZSHCDIR = $(PREFIX)/share/zsh/site-functions
|
||||
RM = rm -f
|
||||
Q = @
|
||||
|
||||
all:
|
||||
$(Q)echo -e '\033[1;32mSetting version\033[0m'
|
||||
$(Q)sed 's/@VERSION@/'$(VERSION)'/' common/$(PN).in > common/$(PN)
|
||||
|
||||
install-bin:
|
||||
$(Q)echo -e '\033[1;32mInstalling main scripts and skel config...\033[0m'
|
||||
install -Dm755 common/$(PN) "$(DESTDIR)$(BINDIR)/$(PN)"
|
||||
ln -s $(PN) "$(DESTDIR)$(BINDIR)/nts"
|
||||
install -Dm644 common/nts.skel "$(DESTDIR)$(SKELDIR)/nts.skel"
|
||||
|
||||
install-man:
|
||||
$(Q)echo -e '\033[1;32mInstalling manpage...\033[0m'
|
||||
install -Dm644 doc/$(PN).1 "$(DESTDIR)$(MANDIR)/$(PN).1"
|
||||
gzip -9 "$(DESTDIR)$(MANDIR)/$(PN).1"
|
||||
ln -s $(PN).1.gz "$(DESTDIR)$(MANDIR)/nts.1.gz"
|
||||
install -Dm644 common/zsh-completion "$(DESTDIR)/$(ZSHCDIR)/_nts"
|
||||
install -Dm644 common/bash-completion "$(DESTDIR)/$(BASHCDIR)/_nts"
|
||||
|
||||
install: install-bin install-man
|
||||
|
||||
uninstall:
|
||||
$(Q)$(RM) "$(DESTDIR)$(BINDIR)/$(PN)"
|
||||
$(Q)$(RM) "$(DESTDIR)$(BINDIR)/nts"
|
||||
$(Q)$(RM) "$(DESTDIR)$(MANDIR)/$(PN).1.gz"
|
||||
$(Q)$(RM) "$(DESTDIR)$(MANDIR)/nts.1.gz"
|
||||
$(Q)$(RM) -r "$(DESTDIR)$(SKELDIR)"
|
||||
$(Q)$(RM) "$(DESTDIR)/$(BASHCDIR)/_nts"
|
||||
$(Q)$(RM) "$(DESTDIR)/$(ZSHCDIR)/_nts"
|
||||
|
||||
clean:
|
||||
$(RM) common/$(PN)
|
||||
|
||||
.PHONY: help install-bin install-man install uninstall clean
|
||||
54
README.md
Normal file
54
README.md
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# night-theme-switcher
|
||||
Wrapper script to switch between dark and light themes under Arch Linux.
|
||||
|
||||
## Why use it?
|
||||
If using a barebone WM like hyprland or sway there is no easy way to change between dark and light themes.
|
||||
|
||||
For example, let's say we have a bunch of application that use KDE/QML/QT and GTK3/4 toolkit. We can now define which themes and icons are used as dark/light themes regardless of the toolkit which these apps are based on.
|
||||
|
||||
Although we can't make the look unified between QT and GTK (notable exeption: KDE `Breeze`), we can at least utilize the dark/light themes of existing QT and GTK themes. This is achieved with the help of `qt6ct` and `gsettings` (which is part of `glib2` on Archlinux).
|
||||
|
||||
For example, let's assume we have `Breeze` for KDE, `adw-gtk3` for GKT3/4 and `Papirus` icon theme installed. We can now apply those themes with one click.
|
||||
|
||||
## Download
|
||||
AUR Package: https://BIGFATPLACEHOLDER
|
||||
|
||||
## Dependencies
|
||||
- `glib2` provides the neccesary `gsettings`.
|
||||
- [`qt6ct-kde`](https://aur.archlinux.org/packages?O=0&K=qt6ct-kde) (a patched version of qt6ct with KDE color schemes support).
|
||||
- Any GTK3 theme with dark/light support.
|
||||
- Any KDE color scheme whith dark/light support.
|
||||
|
||||
## Setup
|
||||
`$XDG_CONFIG_HOME/night-theme-switcher/night-theme-switcher.conf` will be created on the first invocation of nts and contains all user managed settings. Edit this file prior to running nts a second time. The script can be executed either with `/usr/bin/night-theme-switcher` or `/usr/bin/nts`.
|
||||
|
||||
## Options
|
||||
| Command | Description |
|
||||
| :---: | --- |
|
||||
| p | Preview settings. |
|
||||
| r | Restore selected theme (Usefull to run once after login).|
|
||||
| s | Switch between dark and light theme. |
|
||||
|
||||
## Example Usage
|
||||
Switch between dark and light theme as defined in the aforementioned config file:
|
||||
```sh
|
||||
$ nts s
|
||||
```
|
||||
|
||||
Restore the chosen theme after a reboot (use your prefered autostart mechanism):
|
||||
```sh
|
||||
$ nts r
|
||||
```
|
||||
|
||||
Preview the configured settings:
|
||||
```sh
|
||||
$ nts p
|
||||
```
|
||||
|
||||
|
||||
## Tips
|
||||
* Since `nts` requires already installed themes, consider having a look into those directories:
|
||||
- `/usr/share/color-schemes` for KDE color schemes.
|
||||
- `/usr/share/themes` for GTK themes.
|
||||
- `/usr/share/icons` for icon themes.
|
||||
|
||||
12
common/bash-completion
Normal file
12
common/bash-completion
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
_nts_completions()
|
||||
{
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
opts="s r p"
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts[*]}" -- $cur) )
|
||||
return 0
|
||||
}
|
||||
complete -F _nts_completions night-theme-switcher
|
||||
complete -F _nts_completions nts
|
||||
274
common/night-theme-switcher.in
Executable file
274
common/night-theme-switcher.in
Executable file
|
|
@ -0,0 +1,274 @@
|
|||
#!/bin/bash
|
||||
|
||||
# SPDX-FileCopyrightText: Christian Schendel <doppelhelix@gmail.com>
|
||||
# SPDX-License-Identifier: 0BSD
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
## NOTE If KDE Plasma is installed, a patched version of qt6ct is required.
|
||||
## NOTE The benefits are
|
||||
## NOTE KDE color schemes support,KDE QML applications theming support and
|
||||
## NOTE KDE's icon engine support
|
||||
## NOTE See https://aur.archlinux.org/pkgbase/qt6ct-kde/
|
||||
|
||||
|
||||
version='@VERSION@'
|
||||
pkgname='night-theme-switcher'
|
||||
default_config_file="/usr/share/$pkgname/nts.skel"
|
||||
|
||||
user_name=$(getent passwd "$USER")
|
||||
homedir=$(echo "$user_name" | cut -d: -f6)
|
||||
|
||||
# allow user to override from cli thus using multiple files as needed
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$homedir/.config}"
|
||||
user_config_file=${user_config_file:-$XDG_CONFIG_HOME/$pkgname/$pkgname.conf}
|
||||
|
||||
icon_theme_light=
|
||||
icon_theme_dark=
|
||||
kcolorscheme_light=
|
||||
kcolorscheme_dark=
|
||||
gtk_theme_light=
|
||||
gtk_theme_dark=
|
||||
|
||||
### Begin insert of Arch script
|
||||
# Avoid any encoding problems
|
||||
export LANG=C
|
||||
|
||||
# check if messages are to be printed using color
|
||||
unset all_off bold blue green red yellow
|
||||
if [[ -t 2 ]]; then
|
||||
# prefer terminal safe colored and bold text when tput is supported
|
||||
if tput setaf 0 &>/dev/null; then
|
||||
all_off="$(tput sgr0)"
|
||||
bold="$(tput bold)"
|
||||
blue="${bold}$(tput setaf 4)"
|
||||
green="${bold}$(tput setaf 2)"
|
||||
red="${bold}$(tput setaf 1)"
|
||||
yellow="${bold}$(tput setaf 3)"
|
||||
else
|
||||
all_off="\e[1;0m"
|
||||
bold="\e[1;1m"
|
||||
blue="${bold}\e[1;34m"
|
||||
green="${bold}\e[1;32m"
|
||||
red="${bold}\e[1;31m"
|
||||
yellow="${bold}\e[1;33m"
|
||||
fi
|
||||
fi
|
||||
readonly all_off bold blue green red yellow
|
||||
|
||||
### End insert of Arch script
|
||||
|
||||
# dependency checks probably not needed but they do not hurt
|
||||
if ! command -v qt6ct >/dev/null 2>&1; then
|
||||
notify-send \
|
||||
'Missing dependency' \
|
||||
'Please install qt6ct.' \
|
||||
-h string:x-canonical-private-synchronous:sys-notify \
|
||||
-u critical \
|
||||
-i dialog-error
|
||||
mesg="qt6ct is required to use this script."
|
||||
echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v gsettings >/dev/null 2>&1; then
|
||||
notify-send \
|
||||
'Missing dependency' \
|
||||
'gsettings not found.\nPlease install glib2.' \
|
||||
-h string:x-canonical-private-synchronous:sys-notify \
|
||||
-u critical \
|
||||
-i dialog-error
|
||||
mesg="glib2 is required to use this script."
|
||||
echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_config() {
|
||||
if [[ ! -f $default_config_file ]]; then
|
||||
local mesg="$default_config_file is missing. Reinstall this package to continue."
|
||||
echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}"
|
||||
# exit 1
|
||||
fi
|
||||
if [[ ! -f "$user_config_file" ]]; then
|
||||
echo -e "${bold}------------------------------------------------------------${all_off}"
|
||||
echo -e "${bold} No config file found so creating a fresh one in:${all_off}"
|
||||
echo -e "${bold}${blue} $XDG_CONFIG_HOME/$pkgname.conf${all_off}"
|
||||
echo
|
||||
echo -e "${bold} Edit this file before invoking $pkgname again.${all_off}"
|
||||
echo -e "${bold}------------------------------------------------------------${all_off}"
|
||||
#install -Dm644 $default_config_file "$user_config_file"
|
||||
exit 0
|
||||
else
|
||||
# shellcheck source=nts.skel
|
||||
. "$user_config_file"
|
||||
|
||||
# parse config file for correctness
|
||||
if [[ ! -f "$kcolorscheme_light" ]]; then
|
||||
local mesg="Invalid kcolorscheme_light defined in\n ${blue}$user_config_file"
|
||||
echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$kcolorscheme_dark" ]]; then
|
||||
local mesg="Invalid kcolorscheme_dark defined in ${blue}$user_config_file"
|
||||
echo -e "${red}==> ERROR:${all_off}${bold} ${mesg}${all_off}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
_set_theme() {
|
||||
## gtk-theme
|
||||
gsettings set org.gnome.desktop.interface color-scheme "$gtk_color_scheme"
|
||||
gsettings set org.gnome.desktop.interface gtk-theme "$gtk_theme"
|
||||
gsettings set org.gnome.desktop.interface icon-theme "$icon_theme"
|
||||
|
||||
## GTK2
|
||||
if [[ -w "$HOME/.gtkrc-2.0" ]]; then
|
||||
sed -i "s/gtk-theme-name=.*/gtk-theme-name=$gtk_theme/g" \
|
||||
"$HOME/.gtkrc-2.0"
|
||||
sed -i "s/gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/g" \
|
||||
"$HOME/.gtkrc-2.0"
|
||||
fi
|
||||
## GTK3
|
||||
if [[ -w "$HOME/.config/gtk-3.0/settings.ini" ]]; then
|
||||
sed -i "s/gtk-application-prefer-dark-theme=.*/gtk-application-prefer-dark-theme=$gtk_prefer_dark_theme/g" \
|
||||
"$HOME/.config/gtk-3.0/settings.ini"
|
||||
sed -i "s/gtk-theme-name=.*/gtk-theme-name=$gtk_theme/g" \
|
||||
"$HOME/.config/gtk-3.0/settings.ini"
|
||||
sed -i "s/gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/g" \
|
||||
"$HOME/.config/gtk-3.0/settings.ini"
|
||||
fi
|
||||
## GTK4
|
||||
if [[ -w "$HOME/.config/gtk-4.0/settings.ini" ]]; then
|
||||
sed -i "s/gtk-application-prefer-dark-theme=.*/gtk-application-prefer-dark-theme=$gtk_prefer_dark_theme/g" \
|
||||
"$HOME/.config/gtk-4.0/settings.ini"
|
||||
sed -i "s/gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/g" \
|
||||
"$HOME/.config/gtk-4.0/settings.ini"
|
||||
sed -i "s/gtk-theme-name=.*/gtk-theme-name=$gtk_theme/g" \
|
||||
"$HOME/.config/gtk-4.0/settings.ini"
|
||||
fi
|
||||
## QT
|
||||
if [[ -w "$HOME/.config/qt5ct/qt5ct.conf" ]]; then
|
||||
sed -i "s/icon_theme=.*/icon_theme=$icon_theme/g" \
|
||||
"$HOME/.config/qt5ct/qt5ct.conf"
|
||||
sed -i "s,custom_palette=.*,custom_palette=$qt_color_scheme_path,g" \
|
||||
"$HOME/.config/qt5ct/qt5ct.conf"
|
||||
fi
|
||||
if [[ -w "$HOME/.config/qt6ct/qt6ct.conf" ]]; then
|
||||
sed -i "s/icon_theme=.*/icon_theme=$icon_theme/g" \
|
||||
"$HOME/.config/qt6ct/qt6ct.conf"
|
||||
sed -i "s/custom_palette=.*/custom_palette=$qt_custom_palette/g" \
|
||||
"$HOME/.config/qt6ct/qt6ct.conf"
|
||||
sed -i "s,color_scheme_path=.*,color_scheme_path=$qt_color_scheme_path,g" \
|
||||
"$HOME/.config/qt6ct/qt6ct.conf"
|
||||
fi
|
||||
## workaround if plasma-workspace is installed
|
||||
if [ -x "$(command -v /usr/lib/plasma-changeicon)" ]; then
|
||||
/usr/lib/plasma-changeicons "$icon_theme"
|
||||
fi
|
||||
}
|
||||
|
||||
switch-dark-light() {
|
||||
gtk_color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme)
|
||||
|
||||
if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then
|
||||
gtk_color_scheme=prefer-dark
|
||||
gtk_prefer_dark_theme=true
|
||||
gtk_theme=adw-gtk3-dark
|
||||
icon_theme=Papirus-Dark
|
||||
qt_custom_palette=true
|
||||
qt_color_scheme_path=/usr/share/color-schemes/BreezeDark.colors
|
||||
_set_theme
|
||||
else
|
||||
gtk_color_scheme=default
|
||||
gtk_prefer_dark_theme=false
|
||||
gtk_theme=adw-gtk3
|
||||
icon_theme=Papirus
|
||||
qt_custom_palette=true
|
||||
qt_color_scheme_path=/usr/share/color-schemes/BreezeLight.colors
|
||||
_set_theme
|
||||
fi
|
||||
}
|
||||
|
||||
restore-theme-on-login() {
|
||||
find "$HOME/.config//gtk-3.0/" ! -name 'bookmarks' -type f -exec rm -f {} +
|
||||
find "$HOME/.config//gtk-4.0/" ! -name 'bookmarks' -type f -exec rm -f {} +
|
||||
gtk_color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme)
|
||||
|
||||
if [[ ! $gtk_color_scheme == ''\''prefer-dark'\''' ]]; then
|
||||
gtk_color_scheme=default
|
||||
gtk_prefer_dark_theme=false
|
||||
gtk_theme=adw-gtk3
|
||||
icon_theme=Papirus
|
||||
qt_custom_palette=true
|
||||
qt_color_scheme_path=/usr/share/color-schemes/BreezeLight.colors
|
||||
_set_theme
|
||||
else
|
||||
gtk_color_scheme=prefer-dark
|
||||
gtk_prefer_dark_theme=true
|
||||
gtk_theme=adw-gtk3-dark
|
||||
icon_theme=Papirus-Dark
|
||||
qt_custom_palette=true
|
||||
qt_color_scheme_path=/usr/share/color-schemes/BreezeDark.colors
|
||||
_set_theme
|
||||
fi
|
||||
}
|
||||
|
||||
preview() {
|
||||
echo -e "${bold}$pkgname v$version${all_off}"
|
||||
echo
|
||||
echo -e "${bold} KColorScheme"
|
||||
if [[ -f "$kcolorscheme_light" ]]; then
|
||||
echo -en "${bold} Light:"
|
||||
echo -e "$(tput cr)$(tput cuf 10)${blue}$kcolorscheme_light${all_off}${bold}${all_off}"
|
||||
fi
|
||||
if [[ -f "$kcolorscheme_dark" ]]; then
|
||||
echo -en "${bold} Dark:"
|
||||
echo -e "$(tput cr)$(tput cuf 10)${blue}$kcolorscheme_dark${all_off}${bold}${all_off}"
|
||||
fi
|
||||
echo
|
||||
echo -e "${bold} Icon Theme"
|
||||
if [[ -d "/usr/share/icons/$icon_theme_light" ]]; then
|
||||
echo -en "${bold} Light:"
|
||||
echo -e "$(tput cr)$(tput cuf 10)${blue}$icon_theme_light${all_off}${bold}${all_off}"
|
||||
fi
|
||||
if [[ -d "/usr/share/icons/$icon_theme_dark" ]]; then
|
||||
echo -en "${bold} Dark:"
|
||||
echo -e "$(tput cr)$(tput cuf 10)${blue}$icon_theme_dark${all_off}${bold}${all_off}"
|
||||
fi
|
||||
echo
|
||||
echo -e "${bold} GTK Theme"
|
||||
if [[ -d "/usr/share/themes/$gtk_theme_light" ]]; then
|
||||
echo -en "${bold} Light:"
|
||||
echo -e "$(tput cr)$(tput cuf 10)${blue}$gtk_theme_light${all_off}${bold}${all_off}"
|
||||
fi
|
||||
if [[ -d "/usr/share/themes/$gtk_theme_dark" ]]; then
|
||||
echo -en "${bold} Dark:"
|
||||
echo -e "$(tput cr)$(tput cuf 10)${blue}$gtk_theme_dark${all_off}${bold}${all_off}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
s)
|
||||
check_config && switch-dark-light
|
||||
;;
|
||||
r)
|
||||
check_config && restore-theme-on-login
|
||||
;;
|
||||
p)
|
||||
check_config && preview
|
||||
;;
|
||||
*)
|
||||
echo -e "${bold}$pkgname v$version${all_off}"
|
||||
echo
|
||||
echo -e "${bold} Usage: ${red}$0${all_off}${bold} ${all_off}${blue}[option]${all_off}"
|
||||
echo
|
||||
echo -e "${bold} s) swith between dark and light theme${all_off}"
|
||||
echo -e "${bold} r) restore theme (usefull only once after login)${all_off}"
|
||||
echo -e "${bold} p) Preview settings${all_off}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# vim: set ts=4 sw=4 et:
|
||||
17
common/nts.skel
Normal file
17
common/nts.skel
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Fully qualified path for light KColorScheme.
|
||||
kcolorscheme_light="/usr/share/color-schemes/BreezeLight.colors"
|
||||
|
||||
# Fully qualified path for dark KColorScheme.
|
||||
kcolorscheme_dark="/usr/share/color-schemes/BreezeDark.colors"
|
||||
|
||||
# Name of the light icon theme
|
||||
icon_theme_light=Papirus
|
||||
|
||||
# Name of the dark icon theme
|
||||
icon_theme_dark=Papirus-Dark
|
||||
|
||||
# Name of the light gtk theme
|
||||
gtk_theme_light=adw-gtk3
|
||||
|
||||
# Name of the dark gtk theme
|
||||
gtk_theme_dark=adw-gtk3-dark
|
||||
13
common/zsh-completion
Normal file
13
common/zsh-completion
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#compdef night-theme-switcher night-theme-switcher nts
|
||||
|
||||
_nts() {
|
||||
local -a options
|
||||
|
||||
options=('s:Swith between dark and light theme'
|
||||
'r:Restore theme after login. only usefull on autostart'
|
||||
'n:Preview settings')
|
||||
|
||||
_describe 'options' options
|
||||
}
|
||||
|
||||
_nts
|
||||
155
doc/clean-chroot-manager.1
Normal file
155
doc/clean-chroot-manager.1
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
.\" Text automatically generated by txt2man
|
||||
.TH clean-chroot-manager 1 "19 June 2025" "" ""
|
||||
.SH NAME
|
||||
\fBClean-chroot-manager \fP- Wrapper script to manage chroots when building packages under Arch Linux.
|
||||
\fB
|
||||
.SH DESCRIPTION
|
||||
ccm provides a "one-click" solution for building packages in a clean chroot. Two key points that differentiate using ccm from the using the arch-build-scripts alone:
|
||||
.IP \(bu 3
|
||||
ccm automatically manages a local "staging" repo, so anything you build (dependencies from the AUR or more current versions of repo packages, etc.) are transparently pulled from that local repo.
|
||||
.IP \(bu 3
|
||||
ccm can optionally build with distcc and ccache.
|
||||
.PP
|
||||
To expand on point 1: let's say that we want to build a package called "bar" from the AUR but bar has a build dependency of another AUR package called "foo." Rather than first building foo, then installing foo, then building bar, and finally removing foo, the local repo will save a copy of the foo package which is indexed automatically therein. Pacman within the chroot is aware of the foo package thanks to the local repo. When we try to build bar, pacman silently grabs the foo package from the local repo as it would any other dependency.
|
||||
.PP
|
||||
To expand on point 2: distcc allows one to distribute compilation tasks to other PCs on the network to build packages faster. So long as distcc is properly setup, ccm can build using it, and again, this will be a "one-click" operation from the user's prospective. For more on distcc and how to setup using it under Arch, see the wiki page: https://wiki.archlinux.org/index.php/Distcc
|
||||
.SH SETUP
|
||||
$XDG_CONFIG_HOME/clean-chroot-manager.conf (referred to as "the config file" hereafter) will be created on the first invocation of ccm and contains all user managed settings. Edit this file prior to running ccm a second time. Make sure the user running ccm has sudo rights to execute /usr/bin/clean-chroot-manager or /usr/bin/ccm.
|
||||
.SH USAGE
|
||||
sudo ccm [option]
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B
|
||||
a
|
||||
Add any packages in the current directory to the local repo without building them. Useful if you already built something and simply want to copy it in the local repo.
|
||||
.TP
|
||||
.B
|
||||
c
|
||||
Create the chroot.
|
||||
.TP
|
||||
.B
|
||||
cd
|
||||
Create the chroot with distcc enabled. This is a shortcut/override for defining USE_DISTCC in the config file.
|
||||
.TP
|
||||
.B
|
||||
d
|
||||
Delete selected packages in the local repo.
|
||||
.TP
|
||||
.B
|
||||
l
|
||||
List the contents of the local repo (i.e. the packages built to date) should any exist.
|
||||
.TP
|
||||
.B
|
||||
N
|
||||
Nuke the chroot and external repo (if defined).
|
||||
.TP
|
||||
.B
|
||||
n
|
||||
Nuke the chroot (delete it and everything under it).
|
||||
.TP
|
||||
.B
|
||||
p
|
||||
Preview settings. Show some bits about the chroot itself.
|
||||
.TP
|
||||
.B
|
||||
pc
|
||||
Purge cache. Delete all files in the CCACHE_DIR (optional if building with ccache).
|
||||
.TP
|
||||
.B
|
||||
S
|
||||
Run makepkg but do not clean. Useful if building a series of packages with highly similar deps.
|
||||
.TP
|
||||
.B
|
||||
s
|
||||
Run makepkg. The equivalent of `makepkg \fB-s\fP` in the chroot.
|
||||
.TP
|
||||
.B
|
||||
R
|
||||
Repackage the current package if built. The equivalent of `makepkg \fB-sR\fP` in the chroot.
|
||||
.TP
|
||||
.B
|
||||
t
|
||||
Toggle [*\fB-testing\fP] on/off in the chroot. This function will enable or disable the testing repos in the chroot and also take care of upgrading/downgrading any affected packages.
|
||||
.TP
|
||||
.B
|
||||
u
|
||||
Update the packages within the chroot. The equivalent of `pacman \fB-Syu\fP` in the chroot.
|
||||
.SH TIPS
|
||||
.IP \(bu 3
|
||||
Since ccm requires sudo rights, consider making an alias in ~/.bashrc or the like. For example: alias ccm='sudo ccm'
|
||||
.IP \(bu 3
|
||||
If you have multiple PCs on your LAN, consider having them help you compile via distcc which is supported within ccm. See $XDG_CONFIG_HOME/clean-chroot-manager.conf for setup instructions.
|
||||
.IP \(bu 3
|
||||
If your machine has lots of memory (>16G is probably the minimum), consider locating the chroot to a tmpfs partition to minimize access times and avoid disk usage. Know that all data will be lost upon a reboot and that some builds require lots of space so take care when considering it.
|
||||
.PP
|
||||
One way is to simply define a directory to mount as tmpfs like so in /etc/fstab:
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
tmpfs /scratch tmpfs nodev,size=20G 0 0
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
In order to have the expected CHROOTPATH directories created, we can use a systemd tmpfile like so:
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
/etc/tmpfiles.d/ccm_dirs.conf
|
||||
d /scratch/.chroot 0750 foo users -
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
.SH USAGE EXAMPLES
|
||||
Create a chroot:
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
$ sudo ccm c
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
Attempt to build the package in the clean chroot. If successful, the package will be added to a local repo so that it will be available for use as a dependency for building other packages:
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
$ cd /path/to/PKGBUILD
|
||||
$ sudo ccm s
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
List out the contents of the local repo assuming something has been built:
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
$ sudo ccm l
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
Deletes everything under the top level of the chroot effectively removing it from the system:
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
$ sudo ccm n
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
.SH NOTE ABOUT SIGNED PACKAGES
|
||||
When GPGKEY= is defined in the config file, the system's pacman keyring will need to have the corresponding public key imported and signed.
|
||||
.PP
|
||||
.nf
|
||||
.fam C
|
||||
$ gpg --armor --export 1234ABCD > new.key
|
||||
# pacman-key --import new.key
|
||||
# pacman-key --lsign-key 1234ABCD
|
||||
|
||||
.fam T
|
||||
.fi
|
||||
.SH BUGS
|
||||
.IP \(bu 3
|
||||
Not really a bug, but know that if you modify your config file after you created a chroot, the changes will not be effective until you nuke and rebuild the chroot.
|
||||
.PP
|
||||
Discover a bug? Please open an issue on the project page linked below.
|
||||
.SH ONLINE
|
||||
Project page: https://github.com/graysky2/clean-chroot-manager
|
||||
.SH AUTHOR
|
||||
graysky (therealgraysky AT proton DOT me).
|
||||
Loading…
Add table
Add a link
Reference in a new issue