Skip to content
base-seblu.install 1.35 KiB
Newer Older
# vim:set ts=2 sw=2 et:

Seblu's avatar
Seblu committed
# $1: the string to be
# $2: the file to update
check_file() {
  if [[ ! -e "$2" ]] || ! diff "$2" <(printf "%s" "$1") >/dev/null; then
    printf "%s" "$1" > "$2"
    echo "** file $2 updated"
  fi
}

# $1: the link target
# $2: the link himself
check_link() {
  _ct="$(readlink "$2")"
  if (( $? != 0 )) || [[ "$_ct" != "$1" ]]; then
    ln -vsnf "$1" "$2"
  fi

# arg 1:  the new package version
post_install() {
Seblu's avatar
Seblu committed
  # motd
  check_file "" /etc/motd

  # issue
  rm -f /etc/issue.net
  check_file "\n (\s \r) on \l"$'\n' /etc/issue

  # vconsole
  check_file 'KEYMAP=fr'$'\n' /etc/vconsole.conf

  # localtime
  check_link '/usr/share/zoneinfo/Europe/Paris' /etc/localtime

  # locale.conf
  check_file 'LANG=fr_FR.UTF-8'$'\n''LC_MESSAGES=en_US.UTF8'$'\n' /etc/locale.conf

  # locales
  _md5="$(md5sum /etc/locale.gen)"
  sed -ri 's/#(en_US|fr_FR)/\1/' /etc/locale.gen
  [[ "$_md5" != "$(md5sum /etc/locale.gen)" ]] && locale-gen

  # check full hostname
  grep -q \. /etc/hostname || echo '!! /etc/hostname without FQDN'

  # sbin must be a symlink
  [[ -L /usr/local/sbin ]] || echo '!! /usr/local/sbin is not a symlink'

  # display depency info
  echo '-- Unused dependencies:'; pacman -Qdt
  echo '-- Local-only packages'; pacman -Qm
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  post_install "$1"
}