Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
#!/bin/sh

# Preserve new files
install_file() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

preserve_perms() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  if [ -e $OLD ]; then
    cp -a $OLD ${NEW}.incoming
    cat $NEW > ${NEW}.incoming
    touch -r $NEW ${NEW}.incoming
    mv ${NEW}.incoming $NEW
  fi
  install_file $NEW
}


# arg 1:  the new package version
pre_install() {
  /bin/true
}

# arg 1:  the new package version
post_install() {
  # Make sure that the postfix user (UID 91, GID 91),
  # and the postdrop group (GID 92) exist on this system:
  if ! grep -q "^postfix:" etc/passwd ; then
    echo "postfix:x:91:91:User for Postfix MTA:/dev/null:/bin/false" >> etc/passwd
  fi
  if ! grep -q "^postfix:" etc/group ; then
    echo "postfix:x:91:" >> etc/group
  fi
  if ! grep -q "^postdrop:" etc/group ; then
    echo "postdrop:x:92:" >> etc/group
  fi

  find etc/postfix -type f -name '*.new' | while read new ; do
    install_file $new
  done

  preserve_perms etc/rc.d/rc.postfix.new
  install_file etc/aliases.new

  ( cd etc/postfix ; ln -s ../aliases aliases )

  # Don't keep aliases.new. If it exists, the user already defined aliases.
  rm -f etc/aliases.new

  # This is for backward compatibility with the old Sendmail package;
  # some software might still expect to find the /usr/lib/sendmail link.
  if [ ! -d usr/lib ]; then
    mkdir -p usr/lib
    ( cd usr/lib ; rm -f sendmail )
    ( cd usr/lib ; ln -s ../sbin/sendmail sendmail)
  fi

  # We have to check that we are not in the installer mode on the target system
  # ("/etc/system-installer"), and we have to be sure that we are on the working system
  # on the target hardware ("proc/sys/kernel/osrelease" - relative path).
  if [ -r proc/sys/kernel/osrelease -a ! -r /etc/system-installer ]; then
    # No reason to keep these: upgrade-configuration will take care
    # of merging changes needed to the existing files
    rm -f /etc/postfix/main.cf.new /etc/postfix/master.cf.new
  fi

  # The upgrade-configuration command will add any necessary new settings to
  # existing config files (/etc/postfix/{main,master}.cf).  It won't hurt
  # anything on a new install.
  #
  # Also we have to check that we are not in the installer mode on the target system
  # ("/etc/system-installer"), and we have to be sure that we are on the working system
  # on the target hardware ("proc/sys/kernel/osrelease" - relative path).
  if [ -r proc/sys/kernel/osrelease -a ! -r /etc/system-installer -a -x /usr/sbin/postfix ]; then
    /usr/sbin/postfix upgrade-configuration 1> /dev/null 2> /dev/null
  fi

  # Process /etc/aliases into a database:
  #
  # Also we have to check that we are not in the installer mode on the target system
  # ("/etc/system-installer"), and we have to be sure that we are on the working system
  # on the target hardware ("proc/sys/kernel/osrelease" - relative path).
  if [ -r proc/sys/kernel/osrelease -a ! -r /etc/system-installer -a -x /usr/bin/newaliases ]; then
    /usr/bin/newaliases 1> /dev/null 2> /dev/null
  fi
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_update() {
  /bin/true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_update() {
  post_install
}

# arg 1:  the old package version
pre_remove() {
  /bin/true
}

# arg 1:  the old package version
post_remove() {
  /bin/true
}


operation=$1
shift

$operation $*