#!/bin/bash
#
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
# 
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
# 
# ROCK Linux: rock-src/scripts/Puzzle
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
# 
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
# 
# --- ROCK-COPYRIGHT-NOTE-END ---
#
# The following files get created:
#
# Documentation/FAQ
# Documentation/LSM 
# download/INDEX
#

eval "`grep -A 10 '\[BEGIN\]' scripts/parse-config | grep -B 10 '\[END\]'`"
rockver="`echo $rockver | sed 's,-DEV,,'`"

echo "Creating Documentation/FAQ ..."
#
find architecture/. misc/. package/. target/. -name '*.faq[0-9][0-9]' | \
sed 's,^.*\(..\)$,\1 &,' | sort | cut -f2 -d' ' | xargs cat > Documentation/FAQ

echo "Creating Documentation/LSM ..."
#
cat > Documentation/LSM << EOF
Begin3
Title:          ROCK Linux
Version:        $rockver
Entered-date:   `date`
Description:    ROCK Linux is a Linux distribution designed for highly skilled
                Linux Users and Administrators. There is no configuration
                utility - the prefered way of system administration in ROCK
                Linux is to edit the config files directly. ROCK Linux is
                built by some shell scripts. These scripts can download all
                the source from the internet, (cross-)compile them, build the
                package files and create a CD-ROM image.
                ROCK Linux is a small Linux Distribution, but is't not a "mini
                distribution". It comes with over 200 packages including X11
                and the GNOME Desktop.
                The ROCK Linux Homepage is http://www.rocklinux.org/.
Keywords:       Distribution Linux Admin
Author:         god@clifford.at (Clifford Wolf)
Primary-site:   gd.tuwien.ac.at opsys/linux/ROCK/
Platforms:      ix86 PCs, Alpha, PPC
Copying-policy: GPL
End
EOF

echo "Creating download/INDEX ..."
mkdir -p download/
{ echo "# This directory contains the package sources. They don't come"
  echo "# with the rock-linux source distribution - so you need to download"
  echo "# them. Type './scripts/Help Download' for details." ; echo "#"

  {	grep -H '^\[D\] ' package/*/*/*.desc | tr '\t' ' ' | tr -s ' ' |
                sed -e 's,^package/,download/,;'
	grep -H '^[X0-9]' target/*/download.txt | tr '\t' ' ' | tr -s ' ' |
                sed -e 's,^target/,download/,; s,:,:[D] ,;'
	grep -H '^[X0-9]' scripts/miscdown.txt | tr '\t' ' ' | tr -s ' ' |
                sed 's,^scripts/,download/misc/,; s,:,:[D] ,;'
  } | sed 's,^\(.*/\)[^/:]*:[^ ]* \([X0-9]*\) ,\2 \1,;' |
  tr ' ' '\t' | tr -s '\t' | sort -k2 |
  awk '$1 !~ /^XX*$/ { printf("%010.0f %-50s %s\n", $1, $2, $3); }
       $1  ~ /^XX*$/ { printf("XXXXXXXXXX %-50s %s\n",  $2, $3); }'
} > download/INDEX

