saving uncommitted changes in /etc prior to emerge run

This commit is contained in:
2015-09-07 21:38:53 +02:00
committed by Hans Wurst
parent 336373edd3
commit 8dd7f2ae90
15 changed files with 268 additions and 155 deletions

View File

@@ -0,0 +1,70 @@
#!/bin/bash
#
# Paludis hook script to apply patch (w/o modifying corresponding ebuild file).
#
# Copyright (c), 2010-2012 by Alex Turbov <i.zaufi@gmail.com>
#
# Version: @PH_VERSION@
#
source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
declare -r CONFIG_FILE="/etc/paludis/hooks/configs/auto_patch.conf"
PATCH_DIR="/var/db/paludis/autopatches"
# Configuration override
[[ -f ${CONFIG_FILE} ]] && source ${CONFIG_FILE}
PATCH_DIR_FULL="${PATCH_DIR}/${HOOK}/${CATEGORY}/${PF}"
_ap_rememberfile="${T}/.autopatch_was_here_${PALUDIS_PID}"
issue_a_warning()
{
local -r tobe="$1"
ewarn "WARNING: ${CATEGORY}/${PF} package $tobe installed with additional patches applied by auto-patch hook."
ewarn "WARNING: Before filing a bug, remove all patches, reinstall, and try again..."
}
try_to_apply_patches()
{
if [[ -n ${PALUDIS_HOOK_DEBUG} ]]; then
einfo "Check ${PATCH_DIR_FULL}"
fi
if [[ -d ${PATCH_DIR_FULL} ]] ; then
cd "${S}" || die "Failed to cd into ${S}!"
for i in "${PATCH_DIR_FULL}"/*.patch ; do
if declare -f epatch >/dev/null ; then
epatch ${i}
else
# sane default if no epatch is there
einfo "Applying ${i} ..."
patch -p1 -i "${i}" || die "Failed to apply ${i}!"
fi
touch "${_ap_rememberfile}" || die "Failed to touch ${_ap_rememberfile}!"
done
if [[ -e ${_ap_rememberfile} ]]; then
issue_a_warning "will be"
else
einfo "No patches in for this package."
fi
fi
}
case "${HOOK}" in
# ATTENTION This script must be symlinked to the following hook dirs:
ebuild_compile_post | \
ebuild_compile_pre | \
ebuild_configure_post | \
ebuild_configure_pre | \
ebuild_install_pre | \
ebuild_unpack_post )
try_to_apply_patches
;;
install_all_post)
if [[ -e ${_ap_rememberfile} ]] ; then
issue_a_warning "was"
fi
;;
esac
# kate: hl bash;

View File

@@ -0,0 +1,11 @@
#
# auto-patch.conf
#
# REMINDER: autopatch hook applies patches AFTER ebuild has done all
# unpacking and patching.
# Home directory for the patches.
# Put the patches in ${PATCH_DIR}/cat/pkg-ver/ subdirectory
# NOTE Uncomment the following line to override default location
# PATCH_DIR="@PH_LOCALSTATEDIR@/paludis/autopatches"

View File

@@ -0,0 +1 @@
/etc/paludis/hooks/auto_patch.bash

View File

@@ -0,0 +1 @@
/etc/paludis/hooks/auto_patch.bash

View File

@@ -0,0 +1,66 @@
#!/bin/bash
#
# Helper functions to use from /etc/paludis/bashrc and
# package environment control files.
#
# Copyright 2014 by Alex Turbov <i.zaufi@gmail.com>
#
source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
#
# Add options to the end of a given var
# $1 - variable to modify
# $2..$n - options to add
#
add-options()
{
local var=$1
shift
local stmt="$var=\"\$${var} $*\""
eval "$stmt"
}
#
# Remove options from a given var
# $1 - variable to modify
# $2..$n - options to remove
#
remove-options()
{
local -r _ro_var="$1"
shift
local -a _ro_new_value
local _ro_opt
local _ro_del_value
# Iterate over options in a variable
for _ro_opt in ${!_ro_var}; do
# Iterate over options to remove passed as function parameters
for _ro_del_value in "$@"; do
[[ ${_ro_opt} == ${_ro_del_value} ]] && continue 2
done
_ro_new_value+=( "${_ro_opt}" )
done
eval "${_ro_var}=\"${_ro_new_value[@]}\""
}
setup_pkg_env()
{
local conf
[[ ! -f /etc/paludis/package_env.conf ]] && return
# Select configured environments
local envs=$(for i in `egrep "^${CATEGORY}/(${PN}|\*)(:[^\s]+)?\s" /etc/paludis/package_env.conf | sed 's,[^ ]\+\s,,'`; do echo "${i}"; done | sort -u)
for conf in $envs; do
if [[ -f /etc/paludis/env.conf.d/${conf}.conf ]]; then
source /etc/paludis/env.conf.d/${conf}.conf
else
ewarn "Ignore undefined environment configuration: ${conf}"
fi
done
}
# Do it!
setup_pkg_env
# kate: hl bash;