# The high-level package manager that's being used.
# (apt, pacman-g2, yum etc)
# For gentoo this is emerge
-#HIGHLEVEL_PACKAGE_MANAGER=apt
HIGHLEVEL_PACKAGE_MANAGER=emerge
# The low-level package manager that's being used.
# (dpkg, rpm, pacman-g2, etc)
-# For gentoo this is equery
-#LOWLEVEL_PACKAGE_MANAGER=dpkg
-LOWLEVEL_PACKAGE_MANAGER=equery
+# For gentoo this is qlist
+LOWLEVEL_PACKAGE_MANAGER=qlist
#!/bin/sh
set -e
-etckeeper update-ignore || true
+etckeeper update-ignore -a || true
egrep '(ok installed|ok config-files)' | cut -f2,3
elif [ "$LOWLEVEL_PACKAGE_MANAGER" = rpm ]; then
rpm -qa --qf "%|epoch?{%{epoch}}:{0}|:%{name}-%{version}-%{release}.%{arch}\n" | sort
-fi
-
-if [ "$LOWLEVEL_PACKAGE_MANAGER" = equery ]; then
- equery list '*' | cut -f1
-fi
-if [ "$LOWLEVEL_PACKAGE_MANAGER" = portage ]; then
- cd /var/db/pkg && ls -d */* | grep -v '/-MERGING-'
+elif [ "$LOWLEVEL_PACKAGE_MANAGER" = qlist ]; then
+ qlist -ICv
fi
shellquote() {
# Single quotes text, escaping existing single quotes.
- sed -e "s/'/'\"'\"'/" -e "s/^/'/" -e "s/$/'/"
+ sed -e "s/'/'\"'\"'/g" -e "s/^/'/" -e "s/$/'/"
}
generate_metadata() {
set -e
if [ "$VCS" = git ]; then
- [ -d .git ] && [ -n "`git ls-files --modified --deleted --others --exclude-standard`" ]
+ [ -d .git ] && [ -n "`git status --porcelain`" ]
elif [ "$VCS" = hg ]; then
[ -d .hg ] && ! hg status 2>&1 | wc -l | grep -q "^0$"
elif [ "$VCS" = bzr ]; then
- [ -d .bzr ] && ! bzr status 2>/dev/null | wc -l | grep -q "^0$"
+ [ -d .bzr ] && ! bzr version-info --custom --template="{clean}\n" | grep -q "^1$"
elif [ "$VCS" = darcs ]; then
[ -d _darcs ] && darcs whatsnew -l >/dev/null
fi
if [ "$1" != "-f" ]; then
echo "** Warning: This will DESTROY all recorded history for $ETCKEEPER_DIR,"
- echo "** including the $VCS repository and ignore file."
+ echo "** including the $VCS repository."
echo ""
printf "Are you sure you want to do this? [yN] "
read answer
managed_by_etckeeper="managed by etckeeper"
if ! grep -q "$managed_by_etckeeper" "$file"; then
- echo "etckeeper: "$file" does not contain \"$managed_by_etckeeper\" comment; not removing"
+ exit 0
else
- rm -f $file
+ realfile="$file"
+ if [ -n "`type -p tempfile`" ]; then
+ tempfile="tempfile"
+ elif [ -n "`type -p mktemp`" ]; then
+ tempfile="mktemp"
+ else
+ echo "etckeeper warning: can't find tempfile or mktemp" >&2
+ exit 1
+ fi
+ file=$($tempfile)
+ otherentries=
+ skipping=
+ while read line; do
+ if echo "$line" | grep -q "$managed_by_etckeeper"; then
+ if [ ! "$skipping" ]; then
+ skipping=1
+ else
+ skipping=
+ fi
+ elif [ ! "$skipping" ]; then
+ echo "$line" >> "$file"
+ otherentries=1
+ fi
+ done <"$realfile"
+
+ if [ "$otherentries" ]; then
+ mv -f "$file" "$realfile"
+ else
+ rm -f "$file"
+ rm -f "$realfile"
+ fi
fi
ignore "*.pacorig"
ignore "*.pacsave"
nl
- elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "equery" ]; then
+ elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "qlist" ]; then
comment "new and old versions of conffiles, stored by emerge"
- ignore "*.ebuild*"
+ ignore "*.cfg_*"
nl
fi
ignore "*.pyo"
ignore "init.d/.depend.*"
ignore "openvpn/openvpn-status.log"
+ ignore "cups/subscriptions.conf"
+ ignore "cups/subscriptions.conf.O"
nl
comment "editor temp files"
if [ -e "$file" ]; then
if ! grep -q "$managed_by_etckeeper" "$file"; then
- echo "etckeeper: "$file" does not contain \"$managed_by_etckeeper\" comment; not updating"
- exit 1
+ if [ "$1" != "-a" ]; then
+ echo "etckeeper: "$file" does not contain \"$managed_by_etckeeper\" comment; not updating"
+ exit 1
+ else
+ echo "etckeeper: "$file" exists but does not contain \"$managed_by_etckeeper\" comment; updating"
+ writefile
+ exit 0
+ fi
fi
realfile="$file"
if [ -n "`type -p tempfile`" ]; then