summaryrefslogtreecommitdiff
path: root/Debian/Dgit/Policy/Debian.pm
blob: 12f1ee11a9418ce6031e0c12b1fb5f0312790b40 (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
# -*- perl -*-

package Debian::Dgit::Policy::Debian;

use strict;
use warnings;

use POSIX;

BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;
    @ISA         = qw(Exporter);
    @EXPORT      = qw(poldb_path poldb_setup $poldbh);
    %EXPORT_TAGS = ( );
    @EXPORT_OK   = qw();
}

our @EXPORT_OK;

our $poldbh;

sub poldb_path ($) {
    my ($repos) = @_;
    return "$repos/policy.sqlite3";
}

sub poldb_setup ($;$) {
    my ($policydb, $hook) = @_;

    $poldbh ||= DBI->connect("dbi:SQLite:$policydb",'','', {
	RaiseError=>1, PrintError=>1, AutoCommit=>0
			   });

    $hook->() if $hook;

    $poldbh->do("PRAGMA foreign_keys = ON");
}

1;