Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

#!/usr/bin/perl
########################################################################
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
#
# Module name   : update_jats.pl
# Module type   : Makefile system
# Compiler(s)   : Perl
# Environment(s): None
#
# Description   :
#
# Task to be run by CRON enery night
# to update JATS version iff a new one has been marked to be processed
#
# Mark done by:
#   Creating a link to jats2_new
#
#......................................................................#

require 5.008_002;
use strict;
use warnings;

my $DPKG_ARCHIVE = '/export/devl/dpkg_archive';
my $TDIR;
my $markfile;
my $currentLink;
my $target;

$markfile = "$DPKG_ARCHIVE/core_devl/jats2_new";
if ( -l $markfile )
{
    $TDIR = readlink $markfile;
#    print "Link: $markfile,$TDIR\n";
    die ("update_jats: Marklink is empty\n") unless( $TDIR ) ;
    die ("update_jats: Markfile contains a '/' character\n") if ( $TDIR =~ m~/~ );

    $target = "$DPKG_ARCHIVE/core_devl/$TDIR";
    $currentLink = "$DPKG_ARCHIVE/core_devl/jats2_current";

    if ( -d $target )
    {
        unlink ( $currentLink ) if ( -l $currentLink );
        die ("update_jats: Cannot unlink $currentLink\n" ) if -e $currentLink;
        symlink ($TDIR, $currentLink) or die ("update_jats: Cannot create symlink $TDIR $currentLink\n");
        unlink $markfile;
        print "update_jats: JATS Symlink updated to $TDIR\n";
    }
    else
    {
        die "update_jats: Bad link: $target\n";
    }
}