From 7060f88321352ad65b3aa7d491e882072e03afbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Sat, 30 Mar 2024 14:09:59 +0100 Subject: [PATCH] ci: pages, signing --- .github/workflows/pages.yml | 66 ++----- common/hypa/build.sh | 6 + common/hypa/sign.sh | 17 ++ srcpkgs/xbps-triggers/files/appstream-cache | 65 +++++++ srcpkgs/xbps-triggers/files/binfmts | 61 ++++++ srcpkgs/xbps-triggers/files/dkms | 151 +++++++++++++++ srcpkgs/xbps-triggers/files/gconf-schemas | 104 ++++++++++ .../xbps-triggers/files/gdk-pixbuf-loaders | 49 +++++ srcpkgs/xbps-triggers/files/gio-modules | 39 ++++ srcpkgs/xbps-triggers/files/gsettings-schemas | 58 ++++++ srcpkgs/xbps-triggers/files/gtk-icon-cache | 56 ++++++ srcpkgs/xbps-triggers/files/gtk-immodules | 50 +++++ .../xbps-triggers/files/gtk-pixbuf-loaders | 6 + srcpkgs/xbps-triggers/files/gtk3-immodules | 50 +++++ srcpkgs/xbps-triggers/files/hwdb.d-dir | 36 ++++ srcpkgs/xbps-triggers/files/info-files | 63 +++++++ .../xbps-triggers/files/initramfs-regenerate | 57 ++++++ srcpkgs/xbps-triggers/files/kernel-hooks | 53 ++++++ srcpkgs/xbps-triggers/files/mimedb | 40 ++++ srcpkgs/xbps-triggers/files/mkdirs | 59 ++++++ srcpkgs/xbps-triggers/files/pango-modules | 43 +++++ srcpkgs/xbps-triggers/files/pycompile | 116 ++++++++++++ srcpkgs/xbps-triggers/files/register-shell | 66 +++++++ srcpkgs/xbps-triggers/files/system-accounts | 178 ++++++++++++++++++ srcpkgs/xbps-triggers/files/texmf-dist | 48 +++++ srcpkgs/xbps-triggers/files/update-desktopdb | 49 +++++ srcpkgs/xbps-triggers/files/x11-fonts | 57 ++++++ srcpkgs/xbps-triggers/files/xml-catalog | 96 ++++++++++ srcpkgs/xbps-triggers/template | 24 +++ 29 files changed, 1711 insertions(+), 52 deletions(-) create mode 100644 common/hypa/sign.sh create mode 100755 srcpkgs/xbps-triggers/files/appstream-cache create mode 100755 srcpkgs/xbps-triggers/files/binfmts create mode 100755 srcpkgs/xbps-triggers/files/dkms create mode 100755 srcpkgs/xbps-triggers/files/gconf-schemas create mode 100755 srcpkgs/xbps-triggers/files/gdk-pixbuf-loaders create mode 100755 srcpkgs/xbps-triggers/files/gio-modules create mode 100755 srcpkgs/xbps-triggers/files/gsettings-schemas create mode 100755 srcpkgs/xbps-triggers/files/gtk-icon-cache create mode 100755 srcpkgs/xbps-triggers/files/gtk-immodules create mode 100755 srcpkgs/xbps-triggers/files/gtk-pixbuf-loaders create mode 100755 srcpkgs/xbps-triggers/files/gtk3-immodules create mode 100755 srcpkgs/xbps-triggers/files/hwdb.d-dir create mode 100755 srcpkgs/xbps-triggers/files/info-files create mode 100755 srcpkgs/xbps-triggers/files/initramfs-regenerate create mode 100755 srcpkgs/xbps-triggers/files/kernel-hooks create mode 100755 srcpkgs/xbps-triggers/files/mimedb create mode 100755 srcpkgs/xbps-triggers/files/mkdirs create mode 100755 srcpkgs/xbps-triggers/files/pango-modules create mode 100755 srcpkgs/xbps-triggers/files/pycompile create mode 100755 srcpkgs/xbps-triggers/files/register-shell create mode 100755 srcpkgs/xbps-triggers/files/system-accounts create mode 100755 srcpkgs/xbps-triggers/files/texmf-dist create mode 100755 srcpkgs/xbps-triggers/files/update-desktopdb create mode 100755 srcpkgs/xbps-triggers/files/x11-fonts create mode 100755 srcpkgs/xbps-triggers/files/xml-catalog create mode 100644 srcpkgs/xbps-triggers/template diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index de0ae1f..2e6e303 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,16 +1,8 @@ name: Pages on: - pull_request: - paths: - - 'srcpkgs/**' - push: workflow_dispatch: -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: # Lint changed templates. xlint: @@ -61,7 +53,7 @@ jobs: image: ghcr.io/void-linux/void-buildroot-${{ matrix.config.libc }}:20231230R1 options: --platform ${{ matrix.config.platform }} env: - PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' + PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' ARCH: '${{ matrix.config.arch }}' BOOTSTRAP: '${{ matrix.config.host }}' TEST: '${{ matrix.config.test }}' @@ -89,10 +81,14 @@ jobs: xbps-install -Syu || xbps-install -yu xbps # Upgrade again (in case there was a xbps update) xbps-install -yu - xbps-install -y cmake python3 tar + xbps-install -y cmake python3 tar git - name: Clone and checkout - uses: classabbyamp/treeless-checkout-action@v1 + uses: actions/checkout@v4 + with: + submodules: true + filter: tree:0 + fetch-depth: 0 - name: Create hostrepo and prepare masterdir run: | @@ -102,20 +98,17 @@ jobs: common/travis/fetch-xtools.sh - run: common/travis/changed_templates.sh - - name: Build and check packages + - name: Build packages + run: ./common/hypa/build.sh + + - name: Sign packages run: | - rm srcpkgs/google-chrome -rf - ./common/hypa/build.sh - echo "Listen here okay?:" - ls -R - echo "NO RECURSIVE:" - ls hostdir/binpkgs - echo "sources" - ls hostdir/sources + echo -n "${{ secrets.SIGN_PRIVATE_KEY }}" > private.pem + + ./common/hypa/sign.sh hostdir/binpkgs ${{ secrets.SIGN_USERNAME }} ${{ secrets.SIGN_EMAIL }} - name: Build apindex run: | - git clone https://github.com/libthinkpad/apindex.git cd apindex mkdir build cd build @@ -130,37 +123,6 @@ jobs: with: path: hostdir/binpkgs - - name: Show files - run: | - ( - here="$(pwd)" - cd / - "$here/common/travis/show_files.sh" "$BOOTSTRAP" "$ARCH" - ) - - - name: Compare to previous - run: | - ( - here="$(pwd)" - cd / - "$here/common/travis/xpkgdiff.sh" "$BOOTSTRAP" "$ARCH" - ) - - - name: Check file conflicts - if: matrix.config.arch == 'x86_64' # the arch indexed in xlocate - run: | - if [ -s /tmp/templates ]; then - xlocate -S && - common/scripts/lint-conflicts $HOME/hostdir/binpkgs - fi - - - name: Verify repository state - run: | - ( - here="$(pwd)" - cd / - "$here/common/travis/check-install.sh" "$BOOTSTRAP" "$ARCH" - ) deploy: needs: build runs-on: ubuntu-latest diff --git a/common/hypa/build.sh b/common/hypa/build.sh index c0d1b51..b08c21d 100755 --- a/common/hypa/build.sh +++ b/common/hypa/build.sh @@ -1,3 +1,9 @@ +#!/bin/bash + for xbps_pkg in $(ls -1 ./srcpkgs); do + if [[ "$xbps_pkg" == "xbps-triggers" ]]; then + continue + fi + ./xbps-src pkg -Q ${xbps_pkg} || exit 1 done diff --git a/common/hypa/sign.sh b/common/hypa/sign.sh new file mode 100644 index 0000000..1fcbd6e --- /dev/null +++ b/common/hypa/sign.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +REPOSITORY_DIR=$1 +USERNAME=$2 +EMAIL=$3 + +PRIVATE_KEY="private.pem" + +xbps-rindex -a ${REPOSITORY_DIR}/*.xbps +xbps-rindex --sign \ + --signedby "${USERNAME} <${EMAIL}>" \ + --privkey ${PRIVATE_KEY} \ + ${REPOSITORY_DIR} + +for pkg in $(ls -d -1 ${REPOSITORY_DIR}/*.xbps); do + xbps-rindex --privkey ${PRIVATE_KEY} --sign-pkg ${pkg} +done diff --git a/srcpkgs/xbps-triggers/files/appstream-cache b/srcpkgs/xbps-triggers/files/appstream-cache new file mode 100755 index 0000000..8494d1e --- /dev/null +++ b/srcpkgs/xbps-triggers/files/appstream-cache @@ -0,0 +1,65 @@ +#!/bin/sh +# +# Updates the appstream AppData cache during installation of packages and +# deletes it when AppStream is removed +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +# The appstreamcli binary program. +APPSTREAMCLI="usr/bin/appstreamcli" + +# Paths that hold appstream metadata files +# the first one is the traditional one where most package reside but it is +# considered deprecated by upstream +# the other 3 are the ones used by upstream as noted in as-pool.c#L93-95 +APPDATA_DATAPATHS="usr/share/appdata usr/share/app-info var/lib/app-info var/cache/app-info" + +# Location where the cache files go when they are generated they are most +# of the time compressed with gvz extension +APPSTREAM_CACHE="var/cache/app-info/gv" + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + case "$TARGET" in + post-install|post-remove) + if [ $PKGNAME = "AppStream" -a $TARGET = "post-remove" ]; then + for f in ${APPSTREAM_CACHE}/*; do + rm -f ${f} + done + echo "Removing AppStream cache..." + rmdir ${APPSTREAM_CACHE} + exit 0 + fi + + if [ ! -x "$APPSTREAMCLI" ]; then + exit 0 + fi + + for path in ${APPDATA_DATAPATHS}; do + APPSTREAM_PATHS="${APPSTREAM_PATHS} --datapath ${path}" + done + + echo "Updating AppStream cache..." + ${APPSTREAMCLI} refresh-cache --force ${APPSTREAM_PATHS} --cachepath ${APPSTREAM_CACHE} + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts new file mode 100755 index 0000000..1691983 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/binfmts @@ -0,0 +1,61 @@ +#!/bin/sh +# +# binfmts trigger. +# +# Binaries can be specified like: +# binfmts=" [ ...]" +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="usr/bin:usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin" + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ -x /usr/bin/update-binfmts ] || exit 0 + [ -z "${binfmts}" ] && exit 0 + + case "$TARGET" in + post-install) + echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do + line=$(echo $line | tr '&' '\' 2> /dev/null) + set -- ${line} + _bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})" + update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args} + done + ;; + pre-remove) + echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do + line=$(echo $line | tr '&' '\' 2> /dev/null) + set -- ${line} + _bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})" + if [ -f /var/lib/binfmts/${_bname} ]; then + update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin} + fi + done + ;; + *) + exit 1 + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 +# end +# end diff --git a/srcpkgs/xbps-triggers/files/dkms b/srcpkgs/xbps-triggers/files/dkms new file mode 100755 index 0000000..4c5aeb4 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/dkms @@ -0,0 +1,151 @@ +#!/bin/sh +# +# DKMS trigger. Used to add/build/install or remove the specified modules +# from all kernels. +# +# Modules can be specified like: +# dkms_modules=" ..." +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="usr/bin:usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin" + +remove_modules() { + # Remove the specified modules from all kernels. + set -- ${dkms_modules} + while [ $# -gt 0 ]; do + $DKMS status -m "$1" | while read -r line; do + IFS=" ,:/" read -r modname modver kver arch status _ <<-EOF + $line + EOF + if [ "${line#*: }" = added ]; then + # The module wasn't built successfully for any kernel version + printf %s "Cleaning up DKMS module '$modname-$modver'... " + $DKMS remove -m "$modname" -v "$modver" >/dev/null 2>&1 + elif [ "$status" = installed ] || [ "$status" = built ]; then + printf %s "Removing DKMS module '$modname-$modver' for kernel-$kver... " + $DKMS remove -m "$modname" -v "$modver" -k "$kver" >/dev/null 2>&1 + else + # Invalid output + continue + fi + if [ $? -eq 0 ]; then + echo "done." + else + echo "FAILED!" + fi + done + shift 2 + done +} + +add_modules() { + local rval= + + [ -r /etc/default/dkms ] && . /etc/default/dkms + : "${DKMS_JOBS:=$(nproc)}" + + # Add/build and install the specified modules for all kernels. + set -- ${dkms_modules} + while [ $# -gt 0 ]; do + $DKMS add -m "$1" -v "$2" >/dev/null 2>&1 + rval=$? + if [ $rval -eq 0 ]; then + echo "Added DKMS module '$1-$2'." + elif [ $rval -eq 3 ]; then + echo "DKMS module '$1-$2' already added, skipping." + else + echo "Failed to add DKMS module: '$1-$2'..." + err=1 + fi + shift 2 + done + [ -n "$err" ] && exit $err + + for f in $(echo lib/modules/*); do + _kver=$(basename $f) + if [ ! -e "${f}/build/include" ]; then + echo "Skipping kernel-${_kver}. kernel-headers package not installed..." + continue + fi + if [ ! -f ${f}/build/scripts/basic/fixdep ] || [ ! -f ${f}/build/scripts/mod/modpost ] ; then + echo -n "Prepare to build modules for kernel-${_kver}... " + yes "" | make -j "$DKMS_JOBS" -C ${f}/build prepare0 > ${f}/build/make.log 2>&1 + if [ $? -eq 0 ]; then + echo "done." + else + echo "FAILED!" + echo "Kernel scripts failed to build, please check /${f}/build/make.log" + echo "for errors in the log file." + fi + fi + set -- ${dkms_modules} + while [ $# -gt 0 ]; do + echo -n "Building DKMS module '$1-$2' for kernel-${_kver}... " + $DKMS build -j "${DKMS_JOBS}" -q -m "$1" -v "$2" -k "${_kver}" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "done." + else + echo "FAILED!" + echo "DKMS module '$1-$2' failed to build, please check /var/lib/dkms" + echo "for errors in the log file." + shift 2; continue + fi + echo -n "Installing DKMS module '$1-$2' for kernel-${_kver}... " + $DKMS install --force -j "${DKMS_JOBS}" -q -m "$1" -v "$2" -k "${_kver}" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "done." + else + echo "FAILED!" + echo "DKMS module '$1-$2' failed to install, please do this manually" + echo "and check for errors in the log file." + fi + shift 2 + done + done +} + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + if [ -x /usr/bin/dkms ]; then + DKMS=/usr/bin/dkms + elif [ -x /usr/sbin/dkms ]; then + DKMS=/usr/sbin/dkms + else + exit 0 + fi + + [ ! -x $DKMS -o -z "$dkms_modules" ] && exit 0 + + case "$TARGET" in + post-install) + export IGNORE_CC_MISMATCH=1 + add_modules + ;; + pre-remove) + remove_modules + ;; + *) + exit 1 + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gconf-schemas b/srcpkgs/xbps-triggers/files/gconf-schemas new file mode 100755 index 0000000..776b801 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gconf-schemas @@ -0,0 +1,104 @@ +#!/bin/sh +# +# (Un)registers GConf schemas/entries into the schemas database directory. +# +# The following variables can be defined by a package to register .entries +# and .schemas files: +# +# gconf_entries - A list of .entries files to register. When using this +# variable, packages need to be fixed to not register +# them and to install those files to GCONF_SCHEMAS_DIR. +# gconf_schemas - A list of .schemas files to register. When using this +# variable, packages need to be fixed to not register +# them and to install those files to GCONF_SCHEMAS_DIR. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +# The gconftool-2 binary program. +GCONFTOOL2="usr/bin/gconftool-2" + +# Default configuration source (database). +GCONF_CONFIG_SOURCE="xml::/etc/gconf/gconf.xml.defaults" + +# Where .schemas files go. +GCONF_SCHEMAS_DIR="usr/share/gconf/schemas" + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + if [ ! -x "$GCONFTOOL2" ]; then + exit 0 + fi + if [ -z "$gconf_entries" -a -z "$gconf_schemas" ]; then + return 0 + fi + + case "$TARGET" in + post-install) + for f in ${gconf_schemas}; do + if [ ! -f "${GCONF_SCHEMAS_DIR}/${f}" ]; then + continue + fi + GCONF_CONFIG_SOURCE="$GCONF_CONFIG_SOURCE" \ + ${GCONFTOOL2} --makefile-install-rule \ + ${GCONF_SCHEMAS_DIR}/${f} >/dev/null + if [ $? -eq 0 ]; then + echo "Registered GConf schema: ${f}." + fi + done + for f in ${gconf_entries}; do + if [ ! -f "${GCONF_SCHEMAS_DIR}/${f}" ]; then + continue + fi + ${GCONFTOOL2} --config-source=${GCONF_CONFIG_SOURCE} \ + --direct --load ${GCONF_SCHEMAS_DIR}/${f} \ + >/dev/null + if [ $? -eq 0 ]; then + echo "Registered GConf entry: ${f}." + fi + done + ;; + pre-remove) + for f in ${gconf_entries}; do + if [ ! -f "${GCONF_SCHEMAS_DIR}/${f}" ]; then + continue + fi + ${GCONFTOOL2} --config-source=${GCONF_CONFIG_SOURCE} \ + --direct --unload ${GCONF_SCHEMAS_DIR}/${f} \ + >/dev/null + if [ $? -eq 0 ]; then + echo "Unregistered GConf entry: ${f}." + fi + done + for f in ${gconf_schemas}; do + if [ ! -f "${GCONF_SCHEMAS_DIR}/${f}" ]; then + continue + fi + GCONF_CONFIG_SOURCE="${GCONF_CONFIG_SOURCE}" \ + ${GCONFTOOL2} --makefile-uninstall-rule \ + ${GCONF_SCHEMAS_DIR}/${f} >/dev/null + if [ $? -eq 0 ]; then + echo "Unregistered GConf schema: ${f}." + fi + done + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gdk-pixbuf-loaders b/srcpkgs/xbps-triggers/files/gdk-pixbuf-loaders new file mode 100755 index 0000000..26a7eee --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gdk-pixbuf-loaders @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Updates's GDK Pixbuf loaders cache with gdk-pixbuf-query-loaders(1). +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +pixbuf_bin=usr/bin/gdk-pixbuf-query-loaders +pixbuf_cache=usr/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache + +case "$ACTION" in +targets) + echo "post-install pre-remove post-remove" + ;; +run) + [ ! -x ${pixbuf_bin} ] && exit 0 + + if [ "$TARGET" = "pre-remove" -a "${PKGNAME}" = "gdk-pixbuf" ]; then + [ -f ${pixbuf_cache} ] && rm -f ${pixbuf_cache} + break + fi + case "$TARGET" in + post-*) + if [ -f etc/gtk-2.0/gdk-pixbuf.loaders ]; then + echo " Removing obsolete conf file: etc/gtk-2.0/gdk-pixbuf.loaders" + rm -f etc/gtk-2.0/gdk-pixbuf.loaders + fi + if [ -x ${pixbuf_bin} ]; then + echo "Updating GDK Pixbuf loaders cache..." + ${pixbuf_bin} --update-cache + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gio-modules b/srcpkgs/xbps-triggers/files/gio-modules new file mode 100755 index 0000000..0425459 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gio-modules @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Updates GLib GIO module cache with gio-querymodules. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +gioquery=usr/bin/gio-querymodules +giocachedir=usr/lib/gio/modules + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + case "$TARGET" in + post-*) + if [ -x ${gioquery} -a -d ${giocachedir} ]; then + echo "Updating GLib GIO modules cache..." + ${gioquery} ${giocachedir} + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gsettings-schemas b/srcpkgs/xbps-triggers/files/gsettings-schemas new file mode 100755 index 0000000..854126d --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gsettings-schemas @@ -0,0 +1,58 @@ +#!/bin/sh +# +# GLib's GSettings XML schema files. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +# The glib-compile-schemas binary program. +GSCHEMASCOMP="usr/bin/glib-compile-schemas" + +# Where .schemas files go. +GLIB_SCHEMAS_DIR="usr/share/glib-2.0/schemas" + +case "$ACTION" in +targets) + echo "post-install post-remove pre-remove" + ;; +run) + if [ ! -x "$GSCHEMASCOMP" ]; then + exit 0 + fi + + case "$TARGET" in + post-*) + [ ! -d ${GLIB_SCHEMAS_DIR} ] && exit 0 + # Compile all GSettings schema files. + echo -n "Refreshing GSettings database from " + echo -n "${GLIB_SCHEMAS_DIR}... " + ${GSCHEMASCOMP} ${GLIB_SCHEMAS_DIR} + if [ $? -eq 0 ]; then + echo "done." + else + echo "failed!" + fi + ;; + pre-remove) + if [ "${PKGNAME}" = "glib" ]; then + rm -f ${GLIB_SCHEMAS_DIR}/*.compiled + echo "Removed GSettings database file." + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gtk-icon-cache b/srcpkgs/xbps-triggers/files/gtk-icon-cache new file mode 100755 index 0000000..abff328 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gtk-icon-cache @@ -0,0 +1,56 @@ +#!/bin/sh +# +# Updates GTK+ icon cache file with gtk-update-icon-cache(1). +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +iconcache_bin=usr/bin/gtk-update-icon-cache + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + if [ "$TARGET" = "post-remove" -a "${PKGNAME}" = "gtk+" ]; then + for dir in ${gtk_iconcache_dirs}; do + if [ -f .${dir}/icon-theme.cache ]; then + rm -f .${dir}/icon-theme.cache + echo -n "Removed GTK+ icon theme " + echo "cache for ${dir}." + fi + done + exit 0 + fi + + if [ ! -x $iconcache_bin ]; then + exit 0 + fi + + case "$TARGET" in + post-*) + for dir in ${gtk_iconcache_dirs}; do + if [ -d ".${dir}" ]; then + echo -n "Updating GTK+ icon cache for " + echo "${dir}..." + ${iconcache_bin} -q -f -t .${dir} + fi + done + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gtk-immodules b/srcpkgs/xbps-triggers/files/gtk-immodules new file mode 100755 index 0000000..46e3a6b --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gtk-immodules @@ -0,0 +1,50 @@ +#!/bin/sh +# +# Updates GTK+ IM modules file with gtk-query-immodules-2.0(1). +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +immodules_bin=usr/bin/gtk-query-immodules-2.0 +immodules_cache=usr/lib/gtk-2.0/2.10.0/immodules.cache + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + if [ "$TARGET" = "post-remove" -a "${PKGNAME}" = "gtk+" ]; then + [ -f ${immodules_cache} ] && rm -f ${immodules_cache} + exit 0 + fi + case "$TARGET" in + post-*) + if [ -f etc/gtk-2.0/gtk.immodules ]; then + echo "Removing obsolete conf file: etc/gtk-2.0/gtk.immodules" + rm -f etc/gtk-2.0/gtk.immodules + fi + + if [ ! -x $immodules_bin ]; then + exit 0 + fi + + echo "Updating GTK+ immodules cache..." + $immodules_bin --update-cache + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/gtk-pixbuf-loaders b/srcpkgs/xbps-triggers/files/gtk-pixbuf-loaders new file mode 100755 index 0000000..802b489 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gtk-pixbuf-loaders @@ -0,0 +1,6 @@ +#!/bin/sh +# +# This trigger retains the old name of the current 'gdk-pixbuf-loaders' trigger +# and redirects all args there +# +exec usr/libexec/xbps-triggers/gdk-pixbuf-loaders "$@" diff --git a/srcpkgs/xbps-triggers/files/gtk3-immodules b/srcpkgs/xbps-triggers/files/gtk3-immodules new file mode 100755 index 0000000..12042fc --- /dev/null +++ b/srcpkgs/xbps-triggers/files/gtk3-immodules @@ -0,0 +1,50 @@ +#!/bin/sh +# +# Updates GTK+3 IM modules file with gtk-query-immodules-3.0(1). +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +immodules_bin=usr/bin/gtk-query-immodules-3.0 +immodules_cache=usr/lib/gtk-3.0/3.0.0/immodules.cache + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + if [ "$TARGET" = "post-remove" -a "${PKGNAME}" = "gtk+3" ]; then + [ -f ${immodules_cache} ] && rm -f ${immodules_cache} + exit 0 + fi + case "$TARGET" in + post-*) + if [ -f etc/gtk-3.0/gtk.immodules ]; then + echo "Removing obsolete conf file: etc/gtk-3.0/gtk.immodules" + rm -f etc/gtk-3.0/gtk.immodules + fi + + if [ ! -x $immodules_bin ]; then + exit 0 + fi + + echo "Updating GTK+3 immodules cache..." + $immodules_bin --update-cache + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/hwdb.d-dir b/srcpkgs/xbps-triggers/files/hwdb.d-dir new file mode 100755 index 0000000..c651f00 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/hwdb.d-dir @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Updates hardware database +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +udevadm=usr/bin/udevadm + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + if [ ! -x $udevadm ]; then + exit 0 + fi + + echo "Updating udev hardware database ..." + $udevadm hwdb --root=. --update + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/info-files b/srcpkgs/xbps-triggers/files/info-files new file mode 100755 index 0000000..7ad012b --- /dev/null +++ b/srcpkgs/xbps-triggers/files/info-files @@ -0,0 +1,63 @@ +#!/bin/sh +# +# Registers or unregisters info files for a package. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +installinfo=usr/bin/install-info +infodir=usr/share/info + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ ! -x "$installinfo" ] && exit 0 + + if [ -z "$info_files" ]; then + echo "Trigger info-files: empty info_files." + exit 1 + fi + + for f in ${info_files}; do + if [ "$f" = "/usr/share/info/dir" ]; then + continue + elif [ ! -f ".$f" ]; then + echo "WARNING: $f does not exist! skipping..." + continue + fi + + case "$TARGET" in + post-install) + echo -n "Registering info file: $f... " + ;; + pre-remove) + echo -n "Unregistering info file: $f... " + infoargs="--delete" + ;; + esac + + $installinfo $infoargs ./$f $infodir/dir 2>/dev/null + if [ $? -eq 0 ]; then + echo "done." + else + echo "failed!" + fi + done + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/initramfs-regenerate b/srcpkgs/xbps-triggers/files/initramfs-regenerate new file mode 100755 index 0000000..20fd998 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/initramfs-regenerate @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Trigger to regenerate an initramfs for every kernel with a module directory +# in lib/modules on package post-install. +# +# To change the initramfs generator, edit or create the file +# etc/default/initramfs-regenerate and add or change the line +# +# INITRAMFS_GENERATOR= +# +# where is one of "dracut", "mkinitcpio" or "none". By default, a +# value of "dracut" is assumed. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] + +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="usr/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +case "$ACTION" in + targets) + echo "post-install post-remove" + exit 0 + ;; + run) + ;; + *) + exit 1 + ;; +esac + +# Prefer the new alternatives-based initramfs hooks +HOOK="etc/kernel.d/post-install/20-initramfs" +if [ ! -x "${HOOK}" ]; then + # Otherwise, use legacy trigger behavior to find a preferred hook + [ -f etc/default/initramfs-regenerate ] && . etc/default/initramfs-regenerate + HOOK="etc/kernel.d/post-install/20-${INITRAMFS_GENERATOR:-dracut}" + [ -x "${HOOK}" ] || exit 0 +fi + +echo "Regenerating initramfs images using kernel hook ${HOOK##*/}" + +# Regenerate images for every kernel version with modules +for kdir in usr/lib/modules/*; do + [ -d "${kdir}/kernel" ] || continue + kver="${kdir##*/}" + "${HOOK}" "${PKGNAME}" "${kver}" +done +exit 0 diff --git a/srcpkgs/xbps-triggers/files/kernel-hooks b/srcpkgs/xbps-triggers/files/kernel-hooks new file mode 100755 index 0000000..61574e9 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/kernel-hooks @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Run scripts found in /etc/kernel.d/ directories. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +RUN_TARGETS="pre-install post-install pre-remove post-remove" + +case "$ACTION" in +targets) + echo "${RUN_TARGETS}" + ;; +run) + # Ignore pre-remove when updating a package. + if [ "${TARGET}" = "pre-remove" ]; then + [ "${UPDATE}" = "yes" ] && exit 0 + fi + + # Create required dirs when necessary. + for _dir_ in ${RUN_TARGETS}; do + [ ! -d etc/kernel.d/${_dir_} ] && mkdir -p etc/kernel.d/${_dir_} + done + + # Execute kernel hooks for the specified target. + for _file_ in etc/kernel.d/${TARGET}/*; do + [ ! -x "${_file_}" ] && continue + echo "Executing ${TARGET} kernel hook: $(basename ${_file_}) ..." + + # A package may export "kernel_hooks_version" as a hint + # to pass this version to the hooks. + if [ -n "${kernel_hooks_version}" ]; then + env ROOTDIR="." ${_file_} ${PKGNAME} ${kernel_hooks_version} + else + env ROOTDIR="." ${_file_} ${PKGNAME} ${VERSION} + fi + done + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/mimedb b/srcpkgs/xbps-triggers/files/mimedb new file mode 100755 index 0000000..e5535f2 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/mimedb @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Updates the shared-mime-info db file with update-mime-database(1). +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +mimedb_bin=usr/bin/update-mime-database + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + case "$TARGET" in + post-*) + if [ ! -x ${mimedb_bin} ]; then + exit 0 + fi + + echo "Updating shared-mime-info database..." + PKGSYSTEM_ENABLE_FSYNC=0 ${mimedb_bin} -n usr/share/mime > /dev/null + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/mkdirs b/srcpkgs/xbps-triggers/files/mkdirs new file mode 100755 index 0000000..089beca --- /dev/null +++ b/srcpkgs/xbps-triggers/files/mkdirs @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Creates or removes directories as specified by the make_dirs +# environment variable, as follows (relative to rootdir): +# +# dir mode uid gid +# blah 0755 0 0 +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + [ -z "$make_dirs" ] && return 0 + + if [ "$TARGET" = "post-install" ]; then + # create directories + set -- ${make_dirs} + while [ $# -gt 0 ]; do + _dir="$1"; _mode="$2"; _uid="$3"; _gid="$4" + if [ ! -d ".${_dir}" ]; then + mkdir -p ".${_dir}" || \ + echo "Failed to create .${_dir}!" + fi + chown "${_uid}:${_gid}" ".${_dir}" && \ + chmod ${_mode} ".${_dir}" || \ + echo "Failed to set perms ${_mode} ${_uid}:${_gid} to .${_dir}!" + shift; shift; shift; shift + done + else + # remove directories + set -- ${make_dirs} + while [ $# -gt 0 ]; do + _dir="$1" + if [ -d ".${_dir}" ]; then + rmdir ".${_dir}" >/dev/null 2>&1 + fi + shift; shift; shift; shift + done + fi + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/pango-modules b/srcpkgs/xbps-triggers/files/pango-modules new file mode 100755 index 0000000..9c95d54 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/pango-modules @@ -0,0 +1,43 @@ +#!/bin/sh +# +# This is a reduced version for the pango-modules trigger which is now +# obsolete upstream. +# The pango-modulesquery binary was removed from upstream and isn't provided +# anymore by our 'pango' package +# +# This reduced version just removes the pango.modules file if it exists during +# the removal of the 'pango' package +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +pango_modules=etc/pango/pango.modules + +case "$ACTION" in +targets) + echo "post-remove" + ;; +run) + if [ "$TARGET" = "post-remove" -a "${PKGNAME}" = "pango" ]; then + if [ -f ${pango_modules} ]; then + echo "Removing pango modules file..." + rm -f ${pango_modules} + fi + break + fi + ;; +*) + exit 0 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/pycompile b/srcpkgs/xbps-triggers/files/pycompile new file mode 100755 index 0000000..fb55a20 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/pycompile @@ -0,0 +1,116 @@ +#!/bin/sh +# +# Trigger to compile python code into native bytecode and remove +# generated bytecode files. +# +# Packages need to set the variable pycompile_dirs with a list +# of directories (absolute path) separated by spaces, and WITHOUT +# the first slash, e.g: +# +# pycompile_dirs="usr/blah/foo usr/zoo/d00d" +# +# or if the code resides in standard site-packages directory, +# need to set the pycompile_module variable: +# +# pycompile_module="blah foo" +# +# Or if a module is stored in top-level site-packages directory: +# +# pycompile_module="foo.py" +# +# Additionally another var can be used to specify the target python version: +# +# pycompile_version="3.4" +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="usr/bin:/usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin" + +update_ldcache() { + if [ -x sbin/ldconfig -o -x bin/ldconfig ]; then + echo "Updating ldconfig(8) cache..." + ldconfig -X || : + fi +} + +compile() +{ + for f in ${pycompile_dirs}; do + echo "Byte-compiling python code in ${f}..." + python${pycompile_version} -m compileall -f -q ./${f} && \ + python${pycompile_version} -O -m compileall -f -q ./${f} + done + for f in ${pycompile_module}; do + echo "Byte-compiling python${pycompile_version} code for module ${f}..." + if [ -d "usr/lib/python${pycompile_version}/site-packages/${f}" ]; then + python${pycompile_version} -m compileall -f -q \ + usr/lib/python${pycompile_version}/site-packages/${f} && \ + python${pycompile_version} -O -m compileall -f -q \ + usr/lib/python${pycompile_version}/site-packages/${f} + else + python${pycompile_version} -m compileall -f -q \ + usr/lib/python${pycompile_version}/site-packages/${f} && \ + python${pycompile_version} -O -m compileall -f -q \ + usr/lib/python${pycompile_version}/site-packages/${f} + fi + done + update_ldcache +} + +remove() +{ + for f in ${pycompile_dirs}; do + echo "Removing byte-compiled python${pycompile_version} files in ${f}..." + find ./${f} -type f -name \*.py[co] -delete 2>&1 >/dev/null + find ./${f} -type d -name __pycache__ -delete 2>&1 >/dev/null + done + for f in ${pycompile_module}; do + echo "Removing byte-compiled python${pycompile_version} code for module ${f}..." + if [ -d usr/lib/python${pycompile_version}/site-packages/${f} ]; then + find usr/lib/python${pycompile_version}/site-packages/${f} \ + -type f -name \*.py[co] -delete 2>&1 >/dev/null + find usr/lib/python${pycompile_version}/site-packages/${f} \ + -type d -name __pycache__ -delete 2>&1 >/dev/null + else + rm -f usr/lib/python${pycompile_version}/site-packages/${f%.py}.py[co] + fi + done + update_ldcache +} + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ ! -x usr/bin/python${pycompile_version} ] && exit 0 + [ -z "${pycompile_dirs}" -a -z "${pycompile_module}" ] && exit 0 + + case "$TARGET" in + post-install) + compile + ;; + pre-remove) + remove + ;; + *) + exit 1 + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/register-shell b/srcpkgs/xbps-triggers/files/register-shell new file mode 100755 index 0000000..316d112 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/register-shell @@ -0,0 +1,66 @@ +#!/bin/sh +# +# Registers or unregisters a shell in /etc/shells. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + [ "$TARGET" != "post-install" -a "$TARGET" != "post-remove" ] && exit 1 + + if [ -z "$register_shell" ]; then + echo "Trigger register-shell: empty \$register_shell!" + exit 1 + fi + + case "$TARGET" in + post-install) + if [ ! -f etc/shells ]; then + for f in ${register_shell}; do + echo $f >> etc/shells + echo "Registered $f into /etc/shells." + done + chmod 644 etc/shells + else + for f in ${register_shell}; do + if ! grep -qFx "$f" etc/shells; then + echo "$f" >> etc/shells + echo -n "Registered $f into " + echo "/etc/shells." + fi + done + fi + ;; + post-remove) + if [ -f etc/shells ]; then + for f in ${register_shell}; do + if grep -q $f etc/shells; then + shell=$(echo $f|sed "s|\\/|\\\/|g") + sed -i -e "/$shell/d" etc/shells + echo -n "Unregistered $f from " + echo "/etc/shells." + fi + done + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/system-accounts b/srcpkgs/xbps-triggers/files/system-accounts new file mode 100755 index 0000000..f502848 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/system-accounts @@ -0,0 +1,178 @@ +#!/bin/sh +# +# (Un)registers systems accounts (users/groups). +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="usr/sbin:usr/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# Determine whether useradd/groupadd/usermod need a prefix argument +if [ "$(readlink -f . 2>/dev/null || echo .)" != "/" ]; then + prefix="-P ." +else + prefix= +fi + +# show_acct_details [groups] +show_acct_details() { + echo " Account: $1" + echo " Description: '$2'" + echo " Homedir: '$3'" + echo " Shell: '$4'" + [ -n "$5" ] && echo " Additional groups: '$5'" +} + +group_add() { + local _pretty_grname _grname _gid _prefix + + if ! command -v groupadd >/dev/null 2>&1; then + echo "WARNING: cannot create $1 system group (missing groupadd)" + echo "The following group must be created manually: $1" + return + fi + + _grname="${1%:*}" + _gid="${1##*:}" + + [ "${_grname}" = "${_gid}" ] && _gid= + + _pretty_grname="${_grname}${_gid:+ (gid: ${_gid})}" + + groupadd ${prefix} -r ${_grname} ${_gid:+-g ${_gid}} >/dev/null 2>&1 + + case $? in + 0) echo "Created ${_pretty_grname} system group." ;; + 9) ;; + *) echo "ERROR: failed to create system group ${_pretty_grname}!"; exit 1;; + esac +} + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ -z "$system_accounts" -a -z "$system_groups" ] && exit 0 + + if command -v useradd >/dev/null 2>&1; then + USERADD="useradd ${prefix}" + fi + + if command -v usermod >/dev/null 2>&1; then + USERMOD="usermod ${prefix}" + fi + + case "$TARGET" in + post-install) + # System groups required by a package. + for grp in ${system_groups}; do + group_add $grp + done + + # System user/group required by a package. + for acct in ${system_accounts}; do + _uname="${acct%:*}" + _uid="${acct##*:}" + + [ "${_uname}" = "${_uid}" ] && _uid= + + eval homedir="\$${_uname}_homedir" + eval shell="\$${_uname}_shell" + eval descr="\$${_uname}_descr" + eval groups="\$${_uname}_groups" + eval pgroup="\$${_uname}_pgroup" + + [ -z "$homedir" ] && homedir="/var/empty" + [ -z "$shell" ] && shell="/sbin/nologin" + [ -z "$descr" ] && descr="${_uname} unprivileged user" + [ -n "$groups" ] && user_groups="-G $groups" + + if [ -n "${_uid}" ]; then + use_id="-u ${_uid} -g ${pgroup:-${_uid}}" + _pretty_uname="${_uname} (uid: ${_uid})" + else + use_id="-g ${pgroup:-${_uname}}" + _pretty_uname="${_uname}" + fi + + if [ -z "$USERADD" -o -z "$USERMOD" ]; then + echo "WARNING: cannot create ${_uname} system account (missing useradd or usermod)" + echo "The following system account must be created:" + show_acct_details "${_pretty_uname}" "${descr}" "${homedir}" "${shell}" "${groups}" + continue + fi + + group_add ${pgroup:-${acct}} + + ${USERADD} -c "${descr}" -d "${homedir}" \ + ${use_id} ${pgroup:+-N} -s "${shell}" \ + ${user_groups} -r ${_uname} >/dev/null 2>&1 + + case $? in + 0) + echo "Created ${_pretty_uname} system user." + ${USERMOD} -L ${_uname} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "WARNING: unable to lock password for ${_uname} system account" + fi + ;; + 9) + ${USERMOD} -c "${descr}" -d "${homedir}" \ + -s "${shell}" -g "${pgroup:-${_uname}}" \ + ${user_groups} ${_uname} >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "Updated ${_uname} system user." + else + echo "WARNING: unable to modify ${_uname} system account" + echo "Please verify that account is compatible with these settings:" + show_acct_details "${_pretty_uname}" \ + "${descr}" "${homedir}" "${shell}" "${groups}" + continue + fi + ;; + *) + echo "ERROR: failed to create system user ${_pretty_uname}!" + exit 1 + ;; + esac + done + ;; + pre-remove) + if [ "$UPDATE" = "no" ]; then + for acct in ${system_accounts}; do + _uname="${acct%:*}" + + comment="$( (getent passwd "${_uname}" | cut -d: -f5 | head -n1) 2>/dev/null )" + comment="${comment:-unprivileged user} - for uninstalled package ${PKGNAME}" + + if [ -z "$USERMOD" ]; then + echo "WARNING: cannot disable ${_uname} system user (missing usermod)" + continue + fi + + ${USERMOD} -L -d /var/empty -s /bin/false \ + -c "${comment}" ${_uname} >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "Disabled ${_uname} system user." + fi + done + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/texmf-dist b/srcpkgs/xbps-triggers/files/texmf-dist new file mode 100755 index 0000000..94a8194 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/texmf-dist @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Updates texmf-dist hashes and format library. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +texhash=usr/bin/texhash +fmtutil=usr/bin/fmtutil-sys +updmap=usr/bin/updmap-sys +optional_engines="luahbtex,luajithbtex,luajittex,luatex,xetex" + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + if [ -x ${texhash} ]; then + echo "Updating texmf-dist hashes..." + ${texhash} 2>&1 >/dev/null || true # silence strange errors + fi + if [ -x ${fmtutil} ]; then + echo "Updating texmf-dist formats..." + ${fmtutil} --no-error-if-no-engine="${optional_engines}" \ + --quiet --all >/dev/null || true + fi + if [ -x ${updmap} ]; then + echo "Syncing font map files..." + yes y | ${updmap} --quiet --syncwithtrees >/dev/null + echo "Updating font map files..." + ${updmap} --quiet >/dev/null + fi + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/update-desktopdb b/srcpkgs/xbps-triggers/files/update-desktopdb new file mode 100755 index 0000000..bc447ec --- /dev/null +++ b/srcpkgs/xbps-triggers/files/update-desktopdb @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Updates the MIME database that connects with applications, through +# the update-desktop-database(1) utility. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +desktopdb_bin=usr/bin/update-desktop-database +desktopdb_dir=usr/share/applications +desktopdb_cache=${desktopdb_dir}/mimeinfo.cache + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + if [ "$TARGET" = "post-remove" -a "${PKGNAME}" = "desktop-file-utils" ]; then + [ -f ${desktopdb_cache} ] && rm -f ${desktopdb_cache} + exit 0 + fi + case "$TARGET" in + post-*) + if [ ! -x $desktopdb_bin ]; then + exit 0 + fi + + if [ -d $desktopdb_dir ]; then + echo "Updating MIME database..." + ${desktopdb_bin} ${desktopdb_dir} + fi + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/x11-fonts b/srcpkgs/xbps-triggers/files/x11-fonts new file mode 100755 index 0000000..c5d74cd --- /dev/null +++ b/srcpkgs/xbps-triggers/files/x11-fonts @@ -0,0 +1,57 @@ +#!/bin/sh +# +# This trigger rebuilds the fonts.dir and fonts.scale files +# for packages that install X11 fonts, and update fontconfig's +# cache for those fonts. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +mkfontdir=usr/bin/mkfontdir +mkfontscale=usr/bin/mkfontscale +fccache=usr/bin/fc-cache + +case "$ACTION" in +targets) + echo "post-install post-remove" + ;; +run) + if [ ! -x $mkfontdir ]; then + exit 0 + fi + + if [ ! -x $mkfontscale ]; then + exit 0 + fi + + [ -z "${font_dirs}" ] && exit 0 + + case "$TARGET" in + post-install|post-remove) + for dir in ${font_dirs}; do + echo "Building ${dir}/fonts.dir..." + ${mkfontdir} .${dir} + echo "Building ${dir}/fonts.scale..." + ${mkfontscale} .${dir} + echo "Updating fontconfig's cache..." + ${fccache} -f .${dir} + done + ;; + esac + + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/files/xml-catalog b/srcpkgs/xbps-triggers/files/xml-catalog new file mode 100755 index 0000000..6671695 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/xml-catalog @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Registers or unregisters SGML/XML catalog entries, through +# the xmlcatmgr application. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +sgml_catalog=usr/share/sgml/catalog +xml_catalog=usr/share/xml/catalog + +xmlcatmgr=usr/bin/xmlcatmgr + +register_entries() +{ + if [ -n "${sgml_entries}" ]; then + echo -n "Registering SGML catalog entries... " + set -- ${sgml_entries} + while [ $# -gt 0 ]; do + $xmlcatmgr -sc ${sgml_catalog} add "$1" "$2" "$3" + shift; shift; shift; + done + echo "done." + fi + + if [ -n "${xml_entries}" ]; then + echo -n "Registering XML catalog entries... " + set -- ${xml_entries} + while [ $# -gt 0 ]; do + $xmlcatmgr -c ${xml_catalog} add "$1" "$2" "$3" + shift; shift; shift; + done + echo "done." + fi +} + +unregister_entries() +{ + if [ -n "${sgml_entries}" ]; then + echo -n "Unregistering SGML catalog entries... " + set -- ${sgml_entries} + while [ $# -gt 0 ]; do + $xmlcatmgr -sc ${sgml_catalog} remove "$1" "$2" \ + 2>/dev/null + shift; shift; shift + done + echo "done." + fi + if [ -n "${xml_entries}" ]; then + echo -n "Unregistering XML catalog entries... " + set -- ${xml_entries} + while [ $# -gt 0 ]; do + $xmlcatmgr -c ${xml_catalog} remove "$1" "$2" \ + 2>/dev/null + shift; shift; shift + done + echo "done." + fi +} + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ ! -x $xmlcatmgr ] && exit 0 + [ -n "${sgml_entries}" -a ! -f "${sgml_catalog}" ] && exit 0 + [ -n "${xml_entries}" -a ! -f "${xml_catalog}" ] && exit 0 + + case "$TARGET" in + post-install) + register_entries + ;; + pre-remove) + unregister_entries + ;; + *) + exit 1 + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template new file mode 100644 index 0000000..dba2bbf --- /dev/null +++ b/srcpkgs/xbps-triggers/template @@ -0,0 +1,24 @@ +# From https://github.com/void-linux/void-packages/tree/master/srcpkgs/xbps-triggers + +# Template file for 'xbps-triggers' +pkgname=xbps-triggers +version=0.127 +revision=1 +bootstrap=yes +short_desc="XBPS triggers for Void Linux" +maintainer="Enno Boland " +license="Public Domain" +homepage="https://voidlinux.org" + +do_install() { + _triggersdir=usr/libexec/${pkgname} + + for f in ${FILESDIR}/*; do + _trigger=$(basename $f) + vinstall ${FILESDIR}/${_trigger} 754 ${_triggersdir} + echo "# end" >> ${DESTDIR}/${_triggersdir}/${_trigger} + done + vmkdir var/db/xbps + cd ${DESTDIR}/var/db/xbps + ln -sf ../../../${_triggersdir} triggers +}