synfig-core/trunk/src/tool/synfig
synfig-core/trunk/synfig.pc.in
+synfig-core/trunk/autorevision.h
synfig-core/trunk/m4/codeset.m4
synfig-core/trunk/m4/gettext.m4
synfig-core/trunk/m4/glibc2.m4
SUBDIRS = \
libltdl \
+ build_tools \
src \
examples \
po
--- /dev/null
+dist_noinst_SCRIPTS = autorevision.sh
+
+all-local:
+ sh $(srcdir)/autorevision.sh "$(top_srcdir)" "$(top_builddir)"
+
+clean-local:
+ -rm -f $(top_builddir)/autorevision.h
+
--- /dev/null
+#!/bin/sh
+
+# Copyright 2008 Paul Wise
+# Copyright 2009 Konstantin Dmitriev
+#
+# This package 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.
+#
+# This package is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+get_git_id(){
+ export SCM=git
+ export REVISION_ID=`cd "$1"; git log --no-color -1 | head -n 1 | cut -f 2 -d ' '`
+ export BRANCH="`cd "$1"; git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
+ if ( echo $BRANCH | egrep origin/master > /dev/null ); then
+ #give a priority to master branch
+ BRANCH='master'
+ else
+ BRANCH=`echo $BRANCH | cut -d ' ' -f 1`
+ BRANCH=${BRANCH##*/}
+ fi
+ export REVISION=`git show --pretty=format:%ci HEAD | head -c 10 | tr -d '-'`
+ export COMPARE=`git rev-parse --git-dir`
+ # The extra * at the end is for Modified
+ #REVISION="$REVISION"`cd "$1"; [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"`
+}
+
+get_git_svn_id(){
+ export SCM=git-svn
+ export REVISION=`cd "$1"; git svn find-rev HEAD`
+ export COMPARE="$1/.git/"
+ if [ x = "x$REVISION" ] ; then
+ # The extra M at the end is for Modified
+ export REVISION=`cd "$1"; git svn find-rev \`git rev-list --max-count=1 --grep='git-svn-id: ' HEAD\``M
+ else
+ export REVISION="$REVISION"`cd "$1"; git diff --quiet HEAD || echo M`
+ fi
+}
+
+get_svn_id(){
+ export SCM=svn
+ export REVISION=`cd "$1"; svnversion || svn info | sed -n 's/^Revision: \(.*\)/\1/p'`
+}
+
+
+HEADER="$2/autorevision.h"
+SCM=none
+
+
+if [ ! -f "$HEADER" ] ; then
+ touch -t 197001010101 "$HEADER"
+fi
+
+
+# Extract the revision from SVN/git/etc
+if git rev-parse --git-dir > /dev/null 2>&1 ; then
+ get_git_id "."
+elif [ -d "$1/.git/svn" ] ; then
+ get_git_svn_id "$1"
+elif [ -d "$1/../.git/svn" ] ; then
+ get_git_svn_id "$1/.."
+elif [ -d "$1/../../.git/svn" ] ; then
+ get_git_svn_id "$1/../.."
+elif [ -d "$1/.svn" ] ; then
+ COMPARE="$1/.svn"
+ get_svn_id "$1"
+elif [ -d "$1/_svn" ] ; then
+ COMPARE="$1/_svn"
+ get_svn_id "$1"
+fi
+
+
+# Allow overriding both REVISION and DEVEL_VERSION
+if [ -f "$2/autorevision.conf" ] ; then
+ SCM=manual
+ . "$2/autorevision.conf"
+fi
+
+
+# Abort if the header is newer
+if [ "$COMPARE" -ot "$HEADER" ] ; then exit; fi
+
+# Set the development version string
+if [ x = "x$DEVEL_VERSION" ] ; then
+ if [ x != "x$REVISION" ] ; then
+ if [ $SCM = svn ] ; then
+ DEVEL_VERSION="SVN r$REVISION"
+ elif [ $SCM = git-svn ] ; then
+ DEVEL_VERSION="SVN r$REVISION (via git)"
+ elif [ $SCM = git ] ; then
+ DEVEL_VERSION="Revision: ${REVISION}\\\\nBranch: ${BRANCH}\\\\nRevision ID: ${REVISION_ID}"
+ elif [ $SCM = manual ] ; then
+ DEVEL_VERSION="$REVISION (manually configured)"
+ fi
+ fi
+fi
+
+
+# Output the header
+if [ x != "x$DEVEL_VERSION" ] ; then
+ printf "#define DEVEL_VERSION \"$DEVEL_VERSION\"\n" > "$HEADER"
+fi
AC_SUBST(synfigincludedir)
AC_CONFIG_FILES([synfig-config
+build_tools/Makefile
synfig.pc
doxygen.cfg
Makefile
#include <synfig/paramdesc.h>
#include <synfig/main.h>
#include <synfig/guid.h>
+#include <autorevision.h>
#endif
using namespace std;
if(*iter == "--info")
{
cout<<PACKAGE"-"VERSION<<endl;
+ #ifdef DEVEL_VERSION
+ cout<<endl<<DEVEL_VERSION<<endl<<endl;
+ #endif
cout<<"Compiled on "__DATE__ /* " at "__TIME__ */;
#ifdef __GNUC__
cout<<" with GCC "<<__VERSION__;
#ifdef __TCPLUSPLUS__
cout<<" with Borland Turbo C++ "<<(__TCPLUSPLUS__>>8)<<'.'<<((__TCPLUSPLUS__&255)>>4)<<'.'<<(__TCPLUSPLUS__&15);
#endif
-
cout<<endl<<SYNFIG_COPYRIGHT<<endl;
cout<<endl;
return SYNFIGTOOL_HELP;
#!/bin/sh
# Copyright 2008 Paul Wise
+# Copyright 2009 Konstantin Dmitriev
#
# This package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
+get_git_id(){
+ export SCM=git
+ export REVISION_ID=`cd "$1"; git log --no-color -1 | head -n 1 | cut -f 2 -d ' '`
+ export BRANCH="`cd "$1"; git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`"
+ if ( echo $BRANCH | egrep origin/master > /dev/null ); then
+ #give a priority to master branch
+ BRANCH='master'
+ else
+ BRANCH=`echo $BRANCH | cut -d ' ' -f 1`
+ BRANCH=${BRANCH##*/}
+ fi
+ export REVISION=`git show --pretty=format:%ci HEAD | head -c 10 | tr -d '-'`
+ export COMPARE=`git rev-parse --git-dir`
+ # The extra * at the end is for Modified
+ #REVISION="$REVISION"`cd "$1"; [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"`
+}
get_git_svn_id(){
export SCM=git-svn
# Extract the revision from SVN/git/etc
-if [ -d "$1/.git/svn" ] ; then
+if git rev-parse --git-dir > /dev/null 2>&1 ; then
+ get_git_id "."
+elif [ -d "$1/.git/svn" ] ; then
get_git_svn_id "$1"
elif [ -d "$1/../.git/svn" ] ; then
get_git_svn_id "$1/.."
# Abort if the header is newer
if [ "$COMPARE" -ot "$HEADER" ] ; then exit; fi
-
# Set the development version string
if [ x = "x$DEVEL_VERSION" ] ; then
if [ x != "x$REVISION" ] ; then
DEVEL_VERSION="SVN r$REVISION"
elif [ $SCM = git-svn ] ; then
DEVEL_VERSION="SVN r$REVISION (via git)"
+ elif [ $SCM = git ] ; then
+ DEVEL_VERSION="Revision: ${REVISION}\\\\nBranch: ${BRANCH}\\\\nRevision ID: ${REVISION_ID}"
elif [ $SCM = manual ] ; then
DEVEL_VERSION="$REVISION (manually configured)"
fi
# Output the header
if [ x != "x$DEVEL_VERSION" ] ; then
- echo "#define SHOW_EXTRA_INFO" > "$HEADER"
- echo "#define DEVEL_VERSION \"$DEVEL_VERSION\"" >> "$HEADER"
+ printf "#define SHOW_EXTRA_INFO\n" > "$HEADER"
+ printf "#define DEVEL_VERSION \"$DEVEL_VERSION\"\n" >> "$HEADER"
fi
--- /dev/null
+#!/bin/bash
+
+# Synfig Crash Monitor script
+# Copyright (c) 2009 Konstantin Dmitriev
+# This package 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.
+#
+# This package is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+set -e
+trap writelog INT
+
+init()
+{
+echo "SynfigStudio Crash Monitor is a tool to collect statistics about synfig crashes."
+echo "All information is collected locally in ~/.synfig/cph directory."
+echo
+STARTED=0
+RUNTIME=0
+VERSION=''
+RELEASE=''
+BRANCH=''
+REVISION_ID=''
+CRASH=0
+[ ! -d ~/.synfig/cph ] && mkdir -p ~/.synfig/cph || true
+
+# Detect if crash monitor is already started
+PDIR=${0%`basename $0`}
+LCK_FILE=~/.synfig/cph/`basename $0`.lck
+if [ -f "${LCK_FILE}" ]; then
+ MYPID=`head -n 1 "${LCK_FILE}"`
+ if ! ( ps -p ${MYPID} | grep ${MYPID} >/dev/null ); then
+ # The process is not running
+ # Echo current PID into lock file
+ echo $$ > "${LCK_FILE}"
+ else
+ echo "`basename $0` is already running [${MYPID}]. Aborting."
+ sleep 5
+ exit 0
+ fi
+else
+ # The process is not running
+ # Echo current PID into lock file
+ echo $$ > "${LCK_FILE}"
+fi
+echo `date +%H:%M` "Synfig Crash Monitor started."
+}
+
+writelog()
+{
+ if [[ $STARTED != 0 ]]; then
+ if [[ $CRASH == 0 ]]; then
+ echo `date +%H:%M` "Synfig exited normally. Session time: $RUNTIME."
+ else
+ echo `date +%H:%M` "Crash detected. Version $VERSION.$RELEASE.$BRANCH, session time: $RUNTIME."
+ fi
+ if [ -e ~/.synfig/cph/log ]; then
+ #check if dump needed
+ CURRENTDATE=`date +%Y-%m-%d`
+ LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
+ LOGMODDATE=${LOGMODDATE%% *}
+ if [[ $LOGMODDATE != $CURRENTDATE ]]; then
+ dumpstats
+ fi
+ fi
+ #write log
+ echo $VERSION/$BRANCH/$RELEASE/$REVISION_ID $RUNTIME $CRASH >> ~/.synfig/cph/log
+ CRASH=0
+ RUNTIME=0
+ else
+ echo
+ fi
+}
+
+dumpstats()
+{
+ echo `date +%H:%M` 'Dumping stats for previous session...'
+ LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
+ LOGMODDATE=${LOGMODDATE%% *}
+ #get versions
+ VERSIONS=''
+ while read LINE; do
+ FOUND=0
+ for VER in $VERSIONS; do
+ if [[ $VER == ${LINE%% *} ]]; then
+ FOUND=1
+ break
+ fi
+ done
+ [[ $FOUND == 0 ]] && VERSIONS="$VERSIONS ${LINE%% *}"
+ done < ~/.synfig/cph/log
+ echo " Logged versions: ${VERSIONS}"
+ for VER in $VERSIONS; do
+ #generating random record ID
+ ID=$( echo `date` `ps` | md5sum | md5sum )
+ ID="${ID:2:16}"
+ #summarizing time and counting crashes
+ CRASHCOUNT=0
+ TIMECOUNT=0
+ while read LINE; do
+ if [[ ${LINE%% *} == $VER ]]; then
+ TIMECOUNT=`expr $TIMECOUNT + $(echo $LINE| cut -f 2 -d ' ')` || true
+ CRASHCOUNT=`expr $CRASHCOUNT + $(echo $LINE| cut -f 3 -d ' ')` || true
+ fi
+ done < ~/.synfig/cph/log
+ echo " $LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT"
+ echo "$LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT" >> ~/.synfig/cph/stats
+ done
+ rm -f ~/.synfig/cph/log
+ echo ' Done.'
+}
+
+mainloop()
+{
+ while true; do
+ if ( ps --no-headers -f -Csynfigstudio |egrep "^`whoami`" > /dev/null ) ; then
+ #synfigstudio process exist
+ if [[ $STARTED == 0 ]]; then
+ STARTED=1
+ RUNTIME=0
+ #get version
+ P=$(ps --no-headers -f -Csynfigstudio |egrep "^`whoami`" | tr -s ' '| cut -d ' ' -f 8)
+ echo
+ if [ ! -e $P ]; then
+ P=`which $P`
+ fi
+ P=`dirname $P`
+ VERSION=`$P/synfig --info|head -n 1|cut -d '-' -f 2`
+ RELEASE=`$P/synfig --info|egrep "Revision:"|cut -d ' ' -f 2`
+ BRANCH=`$P/synfig --info|egrep "Branch:"|cut -d ' ' -f 2-3`
+ REVISION_ID=`$P/synfig --info|egrep "Revision ID:"|cut -d ' ' -f 3`
+ if [[ $BRANCH == '(no branch)' ]]; then
+ BRANCH=$REVISION_ID
+ fi
+ echo `date +%H:%M` "Synfig $VERSION.$RELEASE.$BRANCH.$REVISION_ID started."
+ echo `date +%H:%M` "Assuming Synfig installed in $P."
+ else
+ let RUNTIME=$RUNTIME+1
+ fi
+ else
+ #no synfigstudio process exist
+ if [[ $STARTED == 1 ]]; then
+ #detect crash
+ if [ -e ~/.synfig/fifo ]; then
+ CRASH=1
+ fi
+ writelog
+ CRASH=0
+ STARTED=0
+ fi
+ fi
+ sleep 1
+ done
+}
+
+
+init
+mainloop