# Take the Slackware x86 ChangeLog entries and produce a build script for 
# ARM, and figure out whether the package is just part of the "x" series or
# is part of the X.org/x11 package set.
#
# Stuart Winter <mozes@slackware.com>
# 2-Feb-2011

source /usr/share/slackdev/buildkit.sh
export CWD=$SLACKSOURCE/x

rm -f /tmp/x*-new

# Process:
# 
#   Copy the entries from Slackware x86's ChangeLog.txt into /tmp/l on your
#    build box and run this script.
#

# Return a package name that has been stripped of the dirname portion
# and any of the valid extensions (only):
pkgbase() {
  # basename + strip extensions .tbz, .tgz, .tlz and .txz
  echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
}

# Strip version, architecture and build from the end of the name
package_name() {
  pkgbase $1 | sed 's?-[^-]*-[^-]*-[^-]*$??'
}

( cat /tmp/l | cut -d/ -f2 | awk -F: '{print $1}' | while read line ; do 
    pkg=$( package_name $line )
    # Check if it's in the Slackware x86 master tree's "slackware/x/" directory:
    if [ -d $CWD/$pkg ]; then
       # It's in Slackware's X series but not part of X.org:
       echo $pkg >> /tmp/x-new 
      else
       # It's part of X.org - one of the modular packages.
       echo "$pkg \\" >> /tmp/x11-new
    fi
  done ) 

cat << EOF
Slackware X series packages (not x11/X.org)
-------------------------------------------

$( cat /tmp/x-new )

Slackware X series packages (not x11/X.org)
-------------------------------------------

$( grep -v xorg-server- /tmp/x11-new  )
EOF
# The "xorg-server" package build will build all of the other xorg-server-* packages.

rm -f /tmp/x*-new
