]> Frank Brehm's Git Trees - config/berta/etc.git/commitdiff
saving uncommitted changes in /etc prior to emerge run
authorFrank Brehm <frank@brehm-online.com>
Mon, 8 Jan 2018 15:22:28 +0000 (16:22 +0100)
committerFrank Brehm <frank@brehm-online.com>
Mon, 8 Jan 2018 15:22:28 +0000 (16:22 +0100)
.etckeeper
cron.daily/etckeeper
etckeeper/commit.d/20store-metadata [new symlink]
etckeeper/commit.d/50vcs-commit
etckeeper/daily [new file with mode: 0755]
etckeeper/etckeeper.conf
etckeeper/list-installed.d/50list-installed
etckeeper/pre-commit.d/20warn-problem-files
etckeeper/pre-commit.d/30store-metadata
etckeeper/update-ignore.d/01update-ignore

index 8d3ef0de9b4279330fc703d4d30821a94d8bf2a8..2688d8b63eea85fb40b4d6abd92269bf58962dba 100755 (executable)
@@ -308,6 +308,7 @@ maybe chmod 0755 'etckeeper/commit.d/30hg-addremove'
 maybe chmod 0755 'etckeeper/commit.d/50vcs-commit'
 maybe chmod 0755 'etckeeper/commit.d/99push'
 maybe chmod 0644 'etckeeper/commit.d/README'
+maybe chmod 0755 'etckeeper/daily'
 maybe chmod 0644 'etckeeper/etckeeper.conf'
 maybe chmod 0755 'etckeeper/init.d'
 maybe chmod 0755 'etckeeper/init.d/10restore-metadata'
index 5255691bc3d1717545b0f8e501a50b2f337d3902..eb74401a546ab260c9da88d207c005fc0e51880a 100755 (executable)
@@ -1,19 +1,8 @@
 #!/bin/sh
 set -e
-if [ -x /usr/bin/etckeeper ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
+if [ -e /etc/etckeeper/daily ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
        . /etc/etckeeper/etckeeper.conf
        if [ "$AVOID_DAILY_AUTOCOMMITS" != "1" ]; then
-               # avoid autocommit if an install run is in progress
-               lockfile=/var/cache/etckeeper/packagelist.pre-install
-               if [ -e "$lockfile" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
-                       rm -f "$lockfile" # stale
-               fi
-               if [ ! -e "$lockfile" ]; then
-                       AVOID_SPECIAL_FILE_WARNING=1
-                       export AVOID_SPECIAL_FILE_WARNING
-                       if etckeeper unclean; then
-                               etckeeper commit "daily autocommit" >/dev/null
-                       fi
-               fi
+               /etc/etckeeper/daily
        fi
 fi
diff --git a/etckeeper/commit.d/20store-metadata b/etckeeper/commit.d/20store-metadata
new file mode 120000 (symlink)
index 0000000..5698d64
--- /dev/null
@@ -0,0 +1 @@
+../pre-commit.d/30store-metadata
\ No newline at end of file
index 7c6173f1ab89b15fa9d65366265f6a695cd6a101..55f0db2440abcd6a7756e0d93d98b71af2324758 100755 (executable)
@@ -28,6 +28,7 @@ if [ -n "$dnsdomainname" ]; then
        hostname="$hostname.$dnsdomainname"
 fi
 
+ORIG_USER=$USER
 USER=
 if [ -n "$SUDO_USER" ]; then
        USER="$SUDO_USER"
@@ -43,7 +44,7 @@ if [ "$VCS" = git ] && [ -d .git ]; then
        if [ -n "$USER" ]; then
                # Use user.name and user.email from the gitconfig belonging
                # to the user who became root.
-               USER_HOME="$(perl -e 'print ((getpwnam(shift()))[7])' "$USER")"
+               USER_HOME="$(getent passwd "$USER" | cut -d: -f6)"
                if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.gitconfig" ]; then
                        if [ -z "$GIT_AUTHOR_NAME" ]; then
                                GIT_AUTHOR_NAME="$(git config -f "$USER_HOME/.gitconfig" user.name)" || true
@@ -54,11 +55,23 @@ if [ "$VCS" = git ] && [ -d .git ]; then
                                export GIT_AUTHOR_EMAIL
                        fi
                fi
-               if [ -z "$GIT_COMMITTER_EMAIL" ]; then
-                       GIT_COMMITER_EMAIL="$(git config --global user.email)" || true
-                       export GIT_COMMITER_EMAIL
+               if [ -z "$GIT_AUTHOR_NAME" ] || [ -z "$GIT_AUTHOR_EMAIL" ]; then
+                       if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.config/git/config" ]; then
+                               if [ -z "$GIT_AUTHOR_NAME" ]; then
+                                       GIT_AUTHOR_NAME="$(git config -f "$USER_HOME/.config/git/config" user.name)" || true
+                                       export GIT_AUTHOR_NAME
+                               fi
+                               if [ -z "$GIT_AUTHOR_EMAIL" ]; then
+                                       GIT_AUTHOR_EMAIL="$(git config -f "$USER_HOME/.config/git/config" user.email)" || true
+                                       export GIT_AUTHOR_EMAIL
+                               fi
+                       fi
                fi
 
+               if [ -z "$GIT_COMMITTER_EMAIL" ]; then
+                       GIT_COMMITTER_EMAIL="$(git config --global user.email)" || true
+                       export GIT_COMMITTER_EMAIL
+               fi
                if [ -z "$GIT_AUTHOR_NAME" ]; then
                        GIT_AUTHOR_NAME="$USER"
                        export GIT_AUTHOR_NAME
@@ -95,6 +108,8 @@ elif [ "$VCS" = bzr ] && [ -d .bzr ]; then
        if [ -z "$EMAIL" ] && [ -n "$USER" ]; then
                EMAIL="$USER <$USER@$hostname>"
                export EMAIL
+       else
+               bzr whoami >/dev/null 2>&1 || export EMAIL="$ORIG_USER <$ORIG_USER@$hostname>"
        fi
        if [ -n "$logfile" ]; then
                bzr commit $BZR_COMMIT_OPTIONS -F "$logfile"
diff --git a/etckeeper/daily b/etckeeper/daily
new file mode 100755 (executable)
index 0000000..f98c6ad
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Script that can be run daily to autocommit /etc changes.
+set -e
+if [ -x /usr/bin/etckeeper ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
+       # avoid autocommit if an install run is in progress
+       lockfile=/var/cache/etckeeper/packagelist.pre-install
+       if [ -e "$lockfile" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
+               rm -f "$lockfile" # stale
+       fi
+       if [ ! -e "$lockfile" ]; then
+               AVOID_SPECIAL_FILE_WARNING=1
+               export AVOID_SPECIAL_FILE_WARNING
+               if etckeeper unclean; then
+                       etckeeper commit "daily autocommit" >/dev/null
+               fi
+       fi
+fi
index 0a9c88ba7936b9b0f5673003759221eb3e860187..eddfa04aaac34b97bd2f1bf2836a36097fb3f09e 100644 (file)
@@ -16,12 +16,14 @@ BZR_COMMIT_OPTIONS=""
 # Options passed to darcs record when run by etckeeper.
 DARCS_COMMIT_OPTIONS="-a"
 
-# Uncomment to avoid etckeeper committing existing changes
-# to /etc automatically once per day.
+# Etckeeper includes both a cron job and a systemd timer, which each
+# can commit exiting changes to /etc automatically once per day.
+# To enable the systemd timer, run: systemctl enable etckeeper.timer
+# The cron job is enabled by default; to disable it, uncomment this next line.
 #AVOID_DAILY_AUTOCOMMITS=1
 
 # Uncomment the following to avoid special file warning
-# (the option is enabled automatically by cronjob regardless).
+# (the option is enabled automatically for daily autocommits regardless).
 #AVOID_SPECIAL_FILE_WARNING=1
 
 # Uncomment to avoid etckeeper committing existing changes to 
@@ -30,16 +32,16 @@ DARCS_COMMIT_OPTIONS="-a"
 #AVOID_COMMIT_BEFORE_INSTALL=1
 
 # The high-level package manager that's being used.
-# (apt, pacman-g2, yum, dnf, zypper etc)
+# (apt, pacman, pacman-g2, yum, dnf, zypper, apk etc)
 #HIGHLEVEL_PACKAGE_MANAGER=apt
 
-# Gentoo specific:
+# Gentoo specific:                                                                                                                                                                                                                                
 # For portage this is emerge
 # For paludis this is cave
 HIGHLEVEL_PACKAGE_MANAGER=emerge
 
 # The low-level package manager that's being used.
-# (dpkg, rpm, pacman, pacman-g2, etc)
+# (dpkg, rpm, pacman, pacmatic, pacman-g2, apk etc)
 #LOWLEVEL_PACKAGE_MANAGER=dpkg
 
 # Gentoo specific:
index 91718d4b98cac67a37dd2fc9d79988f7239633b9..2db838dc3372b2cda8e23c7bd9896731fb85452d 100755 (executable)
@@ -17,6 +17,12 @@ else
                rpm -qa --qf "%|epoch?{%{epoch}}:{0}|:%{name}-%{version}-%{release}.%{arch}\n" | sort
        elif [ "$LOWLEVEL_PACKAGE_MANAGER" = pacman ]; then
                pacman -Q
+       elif [ "$LOWLEVEL_PACKAGE_MANAGER" = pacmatic ]; then
+               pacmatic -Q
+       elif [ "$LOWLEVEL_PACKAGE_MANAGER" = pkgng ]; then
+               pkg info -E "*"
+       elif [ "$LOWLEVEL_PACKAGE_MANAGER" = apk ]; then
+               apk info -v | sort
        elif [ "$LOWLEVEL_PACKAGE_MANAGER" = qlist ]; then
                qlist -ICv
        elif [ "$LOWLEVEL_PACKAGE_MANAGER" = cave ]; then
index f28d5ac6139a1e7a9c6278ebc988932115d133ee..6bd5c2bc4e006d764f44abcb219eda694c8e4090 100755 (executable)
@@ -2,7 +2,7 @@
 set -e
 
 exclude_internal () {
-       egrep -v '(^|/)(.git|.hg|.bzr|_darcs)/'
+       egrep -v '(^|/)(\.git|\.hg|\.bzr|_darcs)/'
 }
 
 if [ "$VCS" = bzr ] || [ "$VCS" = darcs ]; then
@@ -12,8 +12,8 @@ elif [ "$VCS" = hg ]; then
        special=$(find . ! -type d ! -type f ! -type l | exclude_internal) || true
        hardlinks=$(find . -type f ! -links 1 -exec hg status {} \; | exclude_internal ) || true
 elif [ "$VCS" = git ]; then
-       special=$(find . ! -type d ! -type f ! -type l -exec git ls-files --exclude-standard --cached --others {} \; | exclude_internal) || true
-       hardlinks=$(find . -type f ! -links 1 -exec git ls-files --exclude-standard --cached --others {} \; | exclude_internal) || true
+       special=$(find . ! -type d ! -type f ! -type l -exec git ls-files --exclude-standard --cached --others {} + | exclude_internal) || true
+       hardlinks=$(find . -type f ! -links 1 -exec git ls-files --exclude-standard --cached --others {} + | exclude_internal) || true
 else
        special=""
 fi
index edec06b688726c8498397114a1d767ebc0b63690..6d7d4b1bbde5419860cfee1c7093f520fe1bcb64 100755 (executable)
@@ -1,18 +1,9 @@
 #!/bin/sh
 set -e
 
-# Filters out UNKNOWN users and groups, prints a warning on stderr.
-filter_unknown() {
-       CMD=$1
-       while read line; do
-               # if the first n chars of $line equal "$CMD UNKNOWN "...
-               if [ "$(printf %.$((9+${#CMD}))s "$line")" = "$CMD UNKNOWN " ]; then
-                       echo Bad "$2" for "$line" >&2
-               else
-                       echo "$line"
-               fi
-       done
-}
+# Make sure sort always sorts in same order.
+LANG=C
+export LANG
 
 filter_ignore() {
        case "$VCS" in
index 88243eadcb69eee080d2d157209e85ed59f8d613..53afbde788ba5f4e895c3953dafdc6e8e2957fdc 100755 (executable)
@@ -93,12 +93,16 @@ writefile () {
                comment "new and old versions of conffiles, stored by apt/rpm"
                ignore "*.rpm*"
                nl
-       elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "pacman-g2" -o "$LOWLEVEL_PACKAGE_MANAGER" = "pacman" ]; then
+       elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "pacman-g2" -o "$LOWLEVEL_PACKAGE_MANAGER" = "pacman" -o "$LOWLEVEL_PACKAGE_MANAGER" = "pacmatic" ]; then
                comment "new and old versions of conffiles, stored by pacman"
                ignore "*.pacnew"
                ignore "*.pacorig"
                ignore "*.pacsave"
                nl
+       elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "apk" ]; then
+               comment "new versions of conffiles, stored by apk"
+               ignore "*.apk-new"
+               nl
        elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "qlist" -o "$LOWLEVEL_PACKAGE_MANAGER" = "cave" ]; then
                comment "new and old versions of conffiles, stored by emerge"
                ignore "._cfg*"