Skip to content
Snippets Groups Projects
Commit 613d1da8 authored by Jan Mach's avatar Jan Mach
Browse files

DEPRECATION OF OLD PERL CODE, RESTRUCTURALIZATION OF REPOSITORY CONTENTS.

This commit deprecates old Perl library for handling IDEA messages, which will not be supported anymore. It also features restructuralization of the whole repository, because typedcols and ipranges libraries were moved into separate git repositories. Another reason for restructuralization is support of our automated build system.
parent e341f9e8
No related branches found
No related tags found
No related merge requests found
Showing with 0 additions and 634 deletions
module.exports = function(grunt) {
function cbk_dir_size(err, stdout, stderr, cb) {
grunt.config.set('template.deb-control.options.data.package_size', stdout.trim());
cb();
}
function version() {
return '<%= meta.version_major %>.<%= meta.version_minor %>';
}
function package_filename_deb(lang) {
return '<%= meta.name %>-' + lang + '_' + version() + '_<%= meta.architecture %>.deb';
}
function package_filename_tar(lang, nover) {
var vs = '';
if (nover) { vs = 'latest'; } else { vs = version(); }
return '<%= meta.name %>-' + lang + '_' + vs + '_stable.tar.gz';
}
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: grunt.file.readJSON('meta.json'),
// Python project paths to important directories
project_paths_python: {
'deploy_dir': 'lib_python/deploy/',
'package_dir': 'lib_python/deploy/package/',
'control_dir': 'lib_python/deploy/ctrl/',
'archive_dir': 'lib_python/deploy/archive/'
},
// Perl project paths to important directories
project_paths_perl: {
'deploy_dir': 'lib_perl/deploy/',
'package_dir': 'lib_perl/deploy/package/',
'control_dir': 'lib_perl/deploy/ctrl/',
'archive_dir': 'lib_perl/deploy/archive/'
},
// Paths related to Python DEB packages
paths_deb_python: {
'bin_dir': 'usr/local/bin/',
'etc_dir': 'usr/share/idea/',
'lib_dir': 'usr/lib/python3/dist-packages/',
'doc_dir': 'usr/share/doc/idea/',
'man_dir': 'usr/share/man/'
},
// Paths related to Perl DEB packages
paths_deb_perl: {
'bin_dir': 'usr/local/bin/',
'etc_dir': 'usr/share/idea/',
'lib_dir': 'usr/local/lib/site_perl/',
'doc_dir': 'usr/share/doc/idea/',
'man_dir': 'usr/share/man/'
},
// Paths related to Python TAR packages
paths_tar_python: {
'bin_dir': 'opt/idea/bin/',
'etc_dir': 'opt/idea/etc/',
'lib_dir': 'opt/idea/lib_python/',
'doc_dir': 'opt/idea/doc/',
'man_dir': 'opt/idea/man/'
},
// Paths related to Perl TAR packages
paths_tar_perl: {
'bin_dir': 'opt/idea/bin/',
'etc_dir': 'opt/idea/etc/',
'lib_dir': 'opt/idea/lib_perl/',
'doc_dir': 'opt/idea/doc/',
'man_dir': 'opt/idea/man/'
},
// ---------------------------------------------------------------------
// Cleanup various destinations
clean: {
// Cleanup package directory
build_python: {
src: [
"<%= project_paths_python.package_dir %>"
]
},
// Cleanup package directory
build_perl: {
src: [
"<%= project_paths_perl.package_dir %>"
]
}
},
// ---------------------------------------------------------------------
// Running shel commands
shell: {
// Update NodeJS packages (Grunt, grunt plugins...)
npm: {
command: 'npm update'
},
// Calculate directory size
dir_size_python: {
command: '/usr/bin/du -k -s <%= project_paths_python.package_dir %> | /usr/bin/cut -f 1',
options: {
callback: cbk_dir_size
}
},
// Calculate directory size
dir_size_perl: {
command: '/usr/bin/du -k -s <%= project_paths_perl.package_dir %> | /usr/bin/cut -f 1',
options: {
callback: cbk_dir_size
}
},
// Archive Python DEB packages
archive_deb_python: {
command: 'mv <%= project_paths_python.deploy_dir %>*.deb <%= project_paths_python.archive_dir %>'
},
// Archive Perl DEB packages
archive_deb_perl: {
command: 'mv <%= project_paths_perl.deploy_dir %>*.deb <%= project_paths_perl.archive_dir %>'
},
// Archive Python TAR packages
archive_tar_python: {
command: 'mv <%= project_paths_python.deploy_dir %>*.tar.gz <%= project_paths_python.archive_dir %>'
},
// Archive Perl TAR packages
archive_tar_perl: {
command: 'mv <%= project_paths_perl.deploy_dir %>*.tar.gz <%= project_paths_perl.archive_dir %>'
},
// Build Python DEB package
build_deb_python: {
command: '/usr/bin/fakeroot /usr/bin/dpkg-deb --build <%= project_paths_python.package_dir %> <%= project_paths_python.deploy_dir %>' + package_filename_deb('python')
},
// Build Perl DEB package
build_deb_perl: {
command: '/usr/bin/fakeroot /usr/bin/dpkg-deb --build <%= project_paths_perl.package_dir %> <%= project_paths_perl.deploy_dir %>' + package_filename_deb('perl')
},
// Build Python TAR package
build_tar_python: {
command: '/usr/bin/fakeroot /bin/tar -czf <%= project_paths_python.deploy_dir %>' + package_filename_tar('python', false) + ' -C <%= project_paths_python.package_dir %> .'
},
// Build Perl TAR package
build_tar_perl: {
command: '/usr/bin/fakeroot /bin/tar -czf <%= project_paths_perl.deploy_dir %>' + package_filename_tar('perl', false) + ' -C <%= project_paths_perl.package_dir %> .'
},
// FTP deployment
//ftp_deploy: {
// command: 'lftp -f .lftp'
//},
// SCP Python DEB deployment
scp_upload_deb_python: {
command: '/usr/bin/scp <%= project_paths_python.deploy_dir %>' + package_filename_deb('python') + ' <%= meta.server %>:<%= meta.server_dir_deb %>'
},
// SCP Perl DEB deployment
scp_upload_deb_perl: {
command: '/usr/bin/scp <%= project_paths_perl.deploy_dir %>' + package_filename_deb('perl') + ' <%= meta.server %>:<%= meta.server_dir_deb %>'
},
// SCP Python TAR deployment
scp_upload_tar_python: {
command: '/usr/bin/scp <%= project_paths_python.deploy_dir %>' + package_filename_tar('python', false) + ' <%= meta.server %>:<%= meta.server_dir_tar %>'
},
scp_upload_tar_python_l: {
command: '/usr/bin/scp <%= project_paths_python.deploy_dir %>' + package_filename_tar('python', true) + ' <%= meta.server %>:<%= meta.server_dir_tar %>'
},
// SCP Perl TAR deployment
scp_upload_tar_perl: {
command: '/usr/bin/scp <%= project_paths_perl.deploy_dir %>' + package_filename_tar('perl', false) + ' <%= meta.server %>:<%= meta.server_dir_tar %>'
},
scp_upload_tar_perl_l: {
command: '/usr/bin/scp <%= project_paths_perl.deploy_dir %>' + package_filename_tar('perl', true) + ' <%= meta.server %>:<%= meta.server_dir_tar %>'
},
// SSH install
ssh_install_python: {
command: '/usr/bin/ssh <%= meta.server %> /usr/bin/dpkg -i <%= meta.server_dir_deb %>' + package_filename_deb('python')
},
// SSH install
ssh_install_perl: {
command: '/usr/bin/ssh <%= meta.server %> /usr/bin/dpkg -i <%= meta.server_dir_deb %>' + package_filename_deb('perl')
},
// SSH DEB repository update
ssh_aptrepo_update: {
command: '/usr/bin/ssh mach@<%= meta.server %> apt-update mentat'
}
},
// ---------------------------------------------------------------------
// Fill in certain template files
template: {
control_deb_python: {
'options': {
'data': {
'package_name': '<%= meta.name %>-python',
'package_version': version(),
'package_size': '0',
'architecture': '<%= meta.architecture %>'
}
},
'files': {
'<%= project_paths_python.package_dir %>DEBIAN/control': ['<%= project_paths_python.control_dir %>control.tmpl']
}
},
control_deb_perl: {
'options': {
'data': {
'package_name': '<%= meta.name %>-perl',
'package_version': version(),
'package_size': '0',
'architecture': '<%= meta.architecture %>'
}
},
'files': {
'<%= project_paths_perl.package_dir %>DEBIAN/control': ['<%= project_paths_perl.control_dir %>control.tmpl']
}
},
version_deb_perl: {
'options': {
'data': {
'package_version': version()
}
},
'files': {
'<%= project_paths_perl.package_dir %><%= paths_deb_perl.doc_dir %>version': ['<%= project_paths_perl.control_dir %>version.tmpl']
}
},
version_tar_perl: {
'options': {
'data': {
'package_version': version()
}
},
'files': {
'<%= project_paths_perl.package_dir %><%= paths_tar_perl.doc_dir %>version': ['<%= project_paths_perl.control_dir %>version.tmpl']
}
}
},
// ---------------------------------------------------------------------
// Copy certain files to appropriate locations
copy: {
// Copy components for DEB package
deb_python: {
files: [
// ----- Move binaries to package location
{
expand: true,
cwd: 'lib_python/bin/',
src: './*',
dest: '<%= project_paths_python.package_dir %><%= paths_deb_python.bin_dir %>'
},
// ----- Move libraries to package location
{
expand: true,
cwd: 'lib_python/lib/',
src: './**',
dest: '<%= project_paths_python.package_dir %><%= paths_deb_python.lib_dir %>'
},
// ----- Move etc files to package location
{
expand: true,
cwd: 'schema/',
src: './**',
dest: '<%= project_paths_python.package_dir %><%= paths_deb_python.etc_dir %>'
}
]
},
// Copy components for DEB package
deb_perl: {
files: [
// ----- Move binaries to package location
{
expand: true,
cwd: 'lib_perl/bin/',
src: './*',
dest: '<%= project_paths_perl.package_dir %><%= paths_deb_perl.bin_dir %>'
},
// ----- Move libraries to package location
{
expand: true,
cwd: 'lib_perl/lib/',
src: './**',
dest: '<%= project_paths_perl.package_dir %><%= paths_deb_perl.lib_dir %>'
},
// ----- Move etc files to package location
{
expand: true,
cwd: 'schema/',
src: './**',
dest: '<%= project_paths_perl.package_dir %><%= paths_deb_perl.etc_dir %>'
}
]
},
// Copy components for DEB package
tar_perl: {
files: [
// ----- Move binaries to package location
{
expand: true,
cwd: 'lib_perl/bin/',
src: './*',
dest: '<%= project_paths_perl.package_dir %><%= paths_tar_perl.bin_dir %>'
},
// ----- Move libraries to package location
{
expand: true,
cwd: 'lib_perl/lib/',
src: './**',
dest: '<%= project_paths_perl.package_dir %><%= paths_tar_perl.lib_dir %>'
},
// ----- Move config to package location
{
expand: true,
cwd: 'schema/',
src: './**',
dest: '<%= project_paths_perl.package_dir %><%= paths_tar_perl.etc_dir %>'
}
]
},
latest_tar_perl: {
files: [
{
src: '<%= project_paths_perl.deploy_dir %>' + package_filename_tar('perl', false),
dest: '<%= project_paths_perl.deploy_dir %>' + package_filename_tar('perl', true),
}
]
}
},
// ---------------------------------------------------------------------
// Make sure all files have necessary file permissions
chmod: {
options: {
mode: '755'
},
deb_bin_python: {
src: ['<%= project_paths_python.package_dir %><%= paths_deb_python.bin_dir %>/*']
},
deb_bin_perl: {
src: ['<%= project_paths_perl.package_dir %><%= paths_deb_perl.bin_dir %>/*']
},
tar_bin_python: {
src: ['<%= project_paths_python.package_dir %><%= paths_tar_python.bin_dir %>/*']
},
tar_bin_perl: {
src: ['<%= project_paths_perl.package_dir %><%= paths_tar_perl.bin_dir %>/*']
}
}
});
// ---------------------------------------------------------------------
// Load grunt modules
require('load-grunt-tasks')(grunt, { scope: 'devDependencies' });
require('time-grunt')(grunt);
grunt.registerTask('inc-version', function() {
v = grunt.config.get('meta.version_minor');
grunt.config.set('meta.version_minor', v + 1);
console.log("Incremented version to: " + grunt.template.process(version()));
grunt.config.set('template.deb-control.options.data.package_version', grunt.template.process(version()));
});
grunt.registerTask('save-meta', function() {
try {
obj = JSON.parse(JSON.stringify(grunt.config.get('meta')));
} catch (e){
grunt.log.error(e);
grunt.fail.warn("Error parsing the JSON data.", 3);
}
grunt.file.write('meta.json', JSON.stringify(obj, null, 4));
});
// ---------------------------------------------------------------------
// Setup custom task(s).
grunt.registerTask('next-version', ['inc-version', 'save-meta']);
grunt.registerTask('build-deb-perl', ['clean:build_perl', 'shell:archive_deb_perl', 'copy:deb_perl', 'chmod:deb_bin_perl', 'shell:dir_size_perl', 'template:control_deb_perl', 'template:version_deb_perl', 'shell:build_deb_perl', 'clean:build_perl']);
grunt.registerTask('build-tar-perl', ['clean:build_perl', 'shell:archive_tar_perl', 'copy:tar_perl', 'chmod:tar_bin_perl', 'template:version_tar_perl', 'shell:build_tar_perl', 'clean:build_perl', 'copy:latest_tar_perl']);
grunt.registerTask('build-perl', ['build-deb-perl', 'build-tar-perl']);
grunt.registerTask('deploy-deb-perl', ['build-deb-perl', 'shell:scp_upload_deb_perl', 'shell:ssh_aptrepo_update']);
grunt.registerTask('deploy-tar-perl', ['build-tar-perl', 'shell:scp_upload_tar_perl', 'shell:scp_upload_tar_perl_l']);
grunt.registerTask('deploy-perl', ['deploy-deb-perl', 'shell:ssh_aptrepo_update', 'deploy-tar-perl']);
//grunt.registerTask('ftp-deploy', ['shell:ftp_deploy']);
grunt.registerTask('update', ['shell:npm']);
grunt.registerTask('default', ['update']);
};
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
#!/usr/bin/perl -T
use strict;
use warnings;
#*******************************************************************************
# DOCUMENTATION SECTION
#*******************************************************************************
=head1 NAME
idea-validator - Simple IDEA message validator
=head1 SYNOPSIS
# Either use the anonymous pipe
cat message.idea | idea-validator
# Or pass the message file as the first argument
idea-validator message.idea
=head1 OPTIONS AND ARGUMENTS
=over
=item B<--help>
Display short application help
=item B<--man>
Display full man page
=item B<--strict>
Turn on the strict mode
=item B<--schema-file PATH>
Select different JSON schema file
=back
=head1 DESCRIPTION
The purpose of this program is to validate the IDEA message stored in a given text file,
or passed on standard input. It is intended to be used as a simple tool to test generated
IDEA messages.
=head1 AUTHOR
Jan Mach
jan.mach@cesnet.cz
Cesnet, z.s.p.o
http://www.cesnet.cz
=head1 COPYRIGHT
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=head1 SEE ALSO
perl(1), Mentat::Message::Validator::IDEA(3).
=cut
#*******************************************************************************
# LIBRARY LOADING SECTION
#*******************************************************************************
#-- Perl core modules ---------------------------------------------------------#
use Getopt::Long;
use Pod::Usage;
use Data::Dumper; #--- DEVELOPMENT ONLY ---#
#use Smart::Comments; #--- DEVELOPMENT ONLY ---#
#-- Perl CPAN modules ---------------------------------------------------------#
#-- Custom application modules ------------------------------------------------#
# Location of the schema file
my $SCHEMA_FILE;
# We must add the custom library location to the INC path, if we are in development
# process, or if the package was installed from tarball
use Cwd qw(abs_path);
use FindBin;
unless ($FindBin::Bin =~ m|^/usr/local/bin|) {
# Tarball installation
if ($FindBin::Bin =~ m|^/opt/mentat/bin|) {
use lib "/opt/libcesnet-toolkit-perl/lib";
use lib "/opt/idea/lib_perl";
use lib "/opt/mentat/lib";
$SCHEMA_FILE = '/opt/mentat/etc/schema-idea.conf';
}
# Development environment
elsif (not $FindBin::Bin =~ m|tests/unit/bin|) {
use lib (abs_path("$FindBin::Bin/../lib") =~ m{^(/.*)$})[0];
$SCHEMA_FILE = '../etc/schema-idea.conf';
}
# Unit test environment
else {
use lib (abs_path("$FindBin::Bin/../lib") =~ m{^(/.*)$})[0];
use lib (abs_path("$FindBin::Bin/../../../lib") =~ m{^(/.*)$})[0];
$SCHEMA_FILE = '../conf/schema-idea.conf';
}
}
else {
$SCHEMA_FILE = '/etc/mentat/schema-idea.json';
}
use Mentat::Message::Factory;
use Mentat::Message::Validator::IDEA;
#*******************************************************************************
# CONSTANTS AND GLOBAL VARIABLES DEFINITION SECTION
#*******************************************************************************
#-- Constants -----------------------------------------------------------------#
#-- Static public class variables (our) ---------------------------------------#
#-- Static protected class variables (my) -------------------------------------#
# Configurations for the environment
my $FLAG_HELP = 0;
my $FLAG_MAN = 0;
my $FLAG_STRICT = 0;
#*******************************************************************************
# INITIALIZATION AND CLEANUP SECTION
#*******************************************************************************
#-- Module initializations ----------------------------------------------------#
BEGIN {
use vars qw($VERSION);
$VERSION = '0.1';
$ENV{PATH} = '/bin:/usr/bin';
$ENV{ENV} = undef;
}
#-- Module clean-up code (global destructor) ----------------------------------#
END {
}
#*******************************************************************************
# IMPLEMENTATION SECTION
#*******************************************************************************
# Parse application options
my $result = GetOptions ('help' => \$FLAG_HELP, 'man' => \$FLAG_MAN, 'strict' => \$FLAG_STRICT, 'schema-file=s' => \$SCHEMA_FILE);
pod2usage(-verbose => 0, -exitval => 1) unless $result;
pod2usage(-verbose => 1, -exitval => 0) if $FLAG_HELP;
pod2usage(-verbose => 2, -exitval => 0) if $FLAG_MAN;
die "Invalid schema file '$SCHEMA_FILE'\n" unless -f $SCHEMA_FILE;
# Prepare the validator
my $validator = Mentat::Message::Validator::IDEA->new($SCHEMA_FILE);
# Load IDEA message to one string from standard input, or given file
my $idea = '';
while (my $line = <>) { $idea .= $line; }
# Check if we have read something
pod2usage(-message => "This simple validator program is expecting one IDEA message either on standard input, or in a file given as first argument...", -verbose => 0, -exitval => 1) unless ($idea);
# Parse given IDEA message
my $message_idea;
eval {
$message_idea = Mentat::Message::Factory->from_string($idea, 'idea');
};
if ($@) {
print "Parser error: $@\n";
exit(1);
}
# Validate given string or file
my $error = $validator->validate_s($message_idea, $FLAG_STRICT);
unless ($error) {
print "SUCCESSFULLY PARSED AND VALIDATED GIVEN IDEA MESSAGE:\n\n". $message_idea->to_string(1) . "\n";
exit(0);
}
else {
print "Validation error: $error\n";
exit(1);
}
Package: <%- package_name %>
Version: <%- package_version %>
Section: perl
Installed-Size: <%- package_size %>
Priority: optional
Architecture: <%- architecture %>
Depends: perl
Maintainer: Jan Mach <jan.mach@cesnet.cz>
Description: libidea
Perl library for handling IDEA messages
Charon
Copyright 2011-2012 Cesnet, z.s.p.o. (http://www.ces.net)
Authors: Jan Mach <jan.mach@cesnet.cz>
2011-12-31
The entire code base may be distributed under the terms of the GNU General
Public License (GPL), which appears immediately below. Alternatively, all
of the source code as any code derived from that code may instead be
distributed under the GNU Lesser General Public License (LGPL), at the
choice of the distributor. The complete text of the LGPL appears at the
bottom of this file.
See /usr/share/common-licenses/(GPL|LGPL)
#!/usr/bin/perl
use strict;
use warnings;
print "postinst script launched with args: '@ARGV'\n";
# Create repository storage structure
`/bin/mkdir -p /var/reps/apt`;
`/bin/mkdir -p /var/reps/rpm`;
`/bin/mkdir -p /var/reps/git`;
`/bin/mkdir -p /var/reps/svn`;
`/bin/mkdir -p /etc/rpm`;
`/bin/mkdir -p /etc/vsftpd`;
`/bin/mkdir -p /var/run/vsftpd/chroot`;
`/bin/mkdir -p /var/ftproot/apt`;
`/bin/mkdir -p /var/ftproot/rpm`;
`/bin/mkdir -p /var/ftproot/tar`;
`/bin/mkdir -p /etc/apache2/repositories.d/`;
# Change permissions of custom scripts to executable
`/bin/chmod 755 /opt/charon/scripts/*`;
# Add the init script for incoming queue processing daemon to appropriate runlevels
`/usr/sbin/update-rc.d inc-processing defaults`;
`/usr/sbin/update-rc.d repositories defaults`;
exit(0);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment