summaryrefslogtreecommitdiff
path: root/contrib/fpm2pass.pl
blob: 09aeb5a4483de8f765c87b9ed58e216ad0bfebba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl

use warnings;
use strict;
use XML::Simple;
use Getopt::Long;
use Pod::Usage;

my ($help, $man);
my @args = ('help'         => \$help,
            'man'          => \$man,);
GetOptions (@args) or pod2usage(2);
pod2usage(1) if ($help);
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
pod2usage(
 -msg  => "Syntax error: must specify a file to read.",
 -exitval => 2,
 -verbose => 1
)
 if (@ARGV != 1);

# Grab the XML to a perl structure
my $xs = XML::Simple->new();
my $doc = $xs->XMLin(shift);

for (@{$doc->{PasswordList}{PasswordItem}}) {
  my $name;
  if (ref($_->{category}) eq 'HASH') {
    $name = escape($_->{title});
  }
  else {
    $name = escape($_->{category})."/".escape($_->{title});
  }
  my $contents = '';
  $contents .= "$_->{password}\n" unless (ref($_->{password}) eq 'HASH');
  $contents .= "user $_->{user}\n" unless (ref($_->{user}) eq 'HASH');
  $contents .= "url $_->{url}\n" unless (ref($_->{url}) eq 'HASH');
  unless (ref($_->{notes}) eq 'HASH') {
    $_->{notes} =~ s/\n/\n /g;
    $contents .= "notes:\n $_->{notes}\n";
  }
  my $cmd = "pass insert -f -m $name";
  my $pid = open(my $fh, "| $cmd") or die "Couldn't fork: $!\n";
  print $fh $contents;
  close $fh;
}

# escape inverted commas, spaces, ampersands and brackets
sub escape {
  my ($s) = @_;
  $s =~ s/\//-/g;
  $s =~ s/(['\(\) &])/\\$1/g;
  return $s;
}

=head1 NAME

 fpm2pass.pl - imports an .xml exported by fpm2 into pass

=head1 SYNOPSIS

=head1 USAGE

 fpm2pass.pl [--help] [--man] <xml>

The following options are available:

=over

=item --help

=item --man

=back

=cut
='logmsg'> We already have a global cgit_version which is set from the #define'd CGIT_VERSION in cgit.c. Change ui-patch.c to use this so that we only need to rebuild cgit.o when the version changes. Signed-off-by: John Keeping <john@keeping.me.uk> 2013-03-20Makefile: re-use Git's Makefile where possibleJohn Keeping3-119/+80 Git does quite a lot of platform-specific detection in its Makefile, which can result in it defining preprocessor variables that are used in its header files. If CGit does not define the same variables it can result in different sizes of some structures in different places in the same application. For example, on Solaris Git uses it's "compat" regex library which has a different sized regex_t structure than that available in the platform regex.h. This has a knock-on effect on the size of "struct rev_info" and leads to hard to diagnose runtime issues. In order to avoid all of this, introduce a "cgit.mk" file that includes Git's Makefile and make all of the existing logic apply to CGit's objects as well. This is slightly complicated because Git's Makefile must run in Git's directory, so all references to CGit files need to be prefixed with "../". In addition, OBJECTS is a simply expanded variable in Git's Makefile so we cannot just add our objects to it. Instead we must copy the two applicable rules into "cgit.mk". This has the advantage that we can split CGit-specific CFLAGS from Git's CFLAGS and hence avoid rebuilding all of Git whenever a CGit-specific value changes. Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: Jamie Couture <jamie.couture@gmail.com>