#!/bin/bash

# prepsovix are Copyright (C) 2006, 2007, 2008 David Englund. This program is distributed under the terms of the GNU General Public License, Version 3 or any later version. See /usr/share/common-licenses/GPL for the full text of that license.

echo -e "
4.1 Copyright Papers (http://www.gnu.org/prep/maintain/maintain.html#Copyright-Papers)

Before incorporating significant changes, make sure that the person who wrote the changes has signed copyright papers and that the Free Software Foundation has received and signed them. We may also need an employer's disclaimer from the person's employer.

To check whether papers have been received, look in /gd/gnuorg/copyright.list at fencepost.gnu.org.

send one of the templates that are found in the directory /gd/gnuorg/Copyright/ at fencepost.gnu.org. Please don't use any of the templates except for those listed here, and please don't change the wording. Before you do this, make sure to get the current version of the template you will use! We change these templates occasionally—don't keep using an old version.

For large changes, ask the contributor for an assignment. Send per a copy of the file request-assign.changes. (Like all the ‘request-’ files, it is in /gd/gnuorg/Copyright and in gnulib.)

For medium to small changes, request a personal disclaimer by sending per the file request-disclaim.changes. 

If the contributor is likely to keep making changes, person might want to sign an assignment for all per future changes to the program. So it is useful to offer per that alternative. If person wants to do it that way, send per the request-assign.future.

When you send a request- file, you don't need to fill in anything before sending it. Just send the file verbatim to the contributor. The file gives per instructions for how to ask the FSF to mail per the papers to sign. The request- file also raises the issue of getting an employer's disclaimer from the contributor's employer.

When the contributor emails the form to the FSF, the FSF sends per papers to sign. If person signs them right away, the whole process takes about two weeks–mostly waiting for letters to go back and forth. 


You do not need to ask for separate papers for a manual that is distributed only in the software package it describes. But if we sometimes distribute the manual separately (for instance, if we publish it as a book), then we need separate legal papers for changes in the manual. For smaller changes, use disclaim.changes.manual; for larger ones, use assign.changes.manual. To cover both past and future changes to a manual, you can use assign.future.manual. For a translation of a manual, use assign.translation.manual.


Please do not try changing the wording of a template yourself. If you think a change is needed, please talk with assign@gnu.org, and we will work with a lawyer to decide what to do.


4.2 Legally Significant Changes (http://www.gnu.org/prep/maintain/maintain.html#Legally-Significant)

If a person contributes more than around 15 lines of code and/or text that is legally significant for copyright purposes, we need copyright papers for that contribution, as described above. 




* Is Sovix valid HTML 4.01 Strict at http://localhost/sovix/Special/VALIDATE.php?task=?, sovix/Sovix.php, sovix/Standards.php and index pages?
* Is sovix/Templates ready to use?
* Is it usable for different versions of web browsers listed at sovix/Sovix#Supported_web_browsers?
* Have you checked for broken links with linkchecker?
* Is the page source indented correctly?
* Is it semantic HTML?
* Is the theme changed to the next sorted by color to indicate that this version is new?
* Is sovix/Sovix.php updated?
* Is INSTALL, Sovix.php, Tutorial proofreaded?
* Make sure no proprietary extension like Microsofts Conditional Comments is used without our knowledge.
* Was safe_mode = On in php.ini? We use this to make sure that commands like shell_exec is not used by the base of sovix since safe mode does not allow it.
";

while [[ $valid != [yn] ]]; do read -p "Shall I generate a distribution?: " valid; done;
if [ $valid == n ]; then
exit
fi

[ "$1" = "" ] && echo "$0 need a version number to maintain Sovix, type:
$0 VERSION_NUMBER.

# The current version number is $(cat /var/www/sovix/NEWS | grep "Installation Changes in Sovix" | sed -i "s|* Installation Changes in ||")" && exit 1

tmpdir=`mktemp -td $sovix.XXXXXX` && {

cp -a /var/www/sovix/ $tmpdir/
cd $tmpdir/sovix/
find . -name "*~" | xargs rm -v

echo "Remove carrige return so they can't get copied by misstake _if_ they exist.";
for i in $(find . -type f -a -name "*.php"); do tr -d '\r' < $i > $tmpdir/newfile && mv $tmpdir/newfile $i; done

echo "GNU Sovix $1" > src/VERSION

# Clear log. User authentical information can be stored in this file by misstake.
echo "" > dotsovix/private/log.inc.php
echo "" > dotsovix/private/hits.inc.php
echo "" > dotsovix/private/hits_unique.inc.php

for i in $(find . -type f); do perl -pli -e "
s|0.0.1.6|$1|;
s|2008-09-26|$(date +'%Y-%m-%d')|;
" $i; done

echo "Set ownership on files. We must do this before we copy them to the sandbox";
for i in $(find . -type f); do chmod 644 $i; done && for i in $(find . -type d); do chmod 755 $i; done

chmod 666 \
dotsovix/private/hits_unique.inc.php \
dotsovix/private/hits.inc.php \
dotsovix/private/log.inc.php

chmod 755 aclocal.m4 configure configure.ac install-sh Makefile.am Makefile.in missing dev/prepsovix
chmod -R 755 autom4te.cache/
chown -R www-data:www-data .
chown www-data:www-data install-sh missing


echo "Prepare sandbox";
rm -r Sandbox/include/dotsovix/
cp -a dotsovix Sandbox/include/
cp -a Templates/Default/include/dotsovix/personal.inc Sandbox/include/dotsovix/

while [[ $copy_news != [yn] ]]; do read -p "Do you want to copy /var/www/sovix/dev/NEWS-empty to /var/www/sovix/NEWS (y/n)?: " copy_news; done;
if [ $copy_news == y ]; then
cp -a /var/www/sovix/dev/NEWS-empty /var/www/sovix/NEWS
fi


cd $tmpdir
mv sovix/ sovix-$1
tar chzf sovix-$1.tar.gz sovix-$1/
gpg -b --use-agent sovix-$1.tar.gz # gnupload can do this as well but we might want to upload to savannah and not gnu.org
chown www-data:www-data sovix-*
chmod 644 sovix-*
mv sovix-$1.* /var/backups/

rm -r $tmpdir
}
