Arepa

 view release on metacpan or  search on metacpan

doc/TODO  view on Meta::CPAN

* Create a default keyring with the Opera key, and make it part of the
  distribution (use it for the initial /var/arepa/keyring/uploaders.gpg)
* Figure out some permissions for package.db that work for both www-data and
  arepa-master. Should package.db be created by default as an empty database?

* The user, after installation, will have to "su - arepa-master" and create a
  new GPG key for it. The secret key ID should be in the configuration

* Make www-data be part of a new group, arepa. That group should be the group
  for all the interesting directories, and those directories should have the
  gid bit set.
* Have to set the umask to 0002 to reprepro creates the files with the
  appropriate permissions

Pending
-------

* sometimes installation of build-essential and such fails
* it would be nice having the canonical distribution name when generating the
  apt sources line so it just works
* it would be good having some tool to either generate the reprepro

install_arepa.pl  view on Meta::CPAN

my $web_user    = "www-data";
my $web_group   = "www-data";

my $config = Arepa::Config->new("/etc/arepa/config.yml");

my $uid = getgrnam($arepa_user);
if (!defined $uid) {
    print STDERR "ERROR: User '$arepa_user' doesn't exist\n";
    exit 1;
}
my $gid = getgrnam($arepa_group);
if (!defined $gid) {
    print STDERR "ERROR: Group '$arepa_group' doesn't exist\n";
    exit 1;
}
my $web_uid = getgrnam($web_user);
if (!defined $web_uid) {
    print STDERR "ERROR: User '$web_user' doesn't exist\n";
    exit 1;
}
my $web_gid = getgrnam($web_group);
if (!defined $web_gid) {
    print STDERR "ERROR: Group '$web_group' doesn't exist\n";
    exit 1;
}

my $package_db_path = $config->get_key("package_db");
foreach my $path (dirname($package_db_path),
                  $config->get_key("repository:path"),
                  File::Spec->catfile($config->get_key("repository:path"),
                                      "conf"),
                  $config->get_key("upload_queue:path"),
                  $config->get_key("dir:build_logs")) {
    print "Creating directory $path\n";
    mkpath($path);
    chown($uid, $gid, $path);
    symchmod("g+w", $path);
}

my $builder_dir = "/etc/arepa/builders";
print "Creating builder configuration directory $builder_dir\n";
mkpath($builder_dir);
chown($uid, $gid, $builder_dir);
symchmod("g+w", $builder_dir);

print "Creating package DB in $package_db_path\n";
my $package_db = Arepa::PackageDb->new($package_db_path);
chown($uid, $gid, $package_db_path);
symchmod("g+w", $package_db_path);

my $db_dir = dirname($package_db_path);
print "Fixing permissions for database directory $db_dir\n";
chown($uid, $gid, $db_dir);
symchmod("g+w", $db_dir);

my $session_db_path = $config->get_key("web_ui:session_db");
if (! -r $session_db_path) {
    print "Creating web UI session DB in $session_db_path\n";
    open F, ">>$session_db_path"; close F;
    my $sqlite_cmd = <<EOC;
echo "CREATE TABLE session (sid VARCHAR(40) PRIMARY KEY, data TEXT, expires INTEGER UNSIGNED NOT NULL, UNIQUE(sid));" | sqlite3 '$session_db_path'
EOC
    print "Creating session DB schema with:\n$sqlite_cmd";
    system($sqlite_cmd);
    chown($web_uid, $web_gid, $session_db_path);
    symchmod("g+w", $session_db_path);
}

my $repo_dists_conf = File::Spec->catfile($config->get_key("repository:path"),
                                          "conf",
                                          "distributions");
print "Creating repo configuration file in $repo_dists_conf\n";
open F, ">>$repo_dists_conf";
close F;
chown($uid, $gid, $repo_dists_conf);
symchmod("g+w", $repo_dists_conf);

my $gpg_dir = $config->get_key("web_ui:gpg_homedir");
print "Creating GPG directory in $gpg_dir\n";
mkpath($gpg_dir);
chown($web_uid, $web_gid, $gpg_dir);
chmod(0700, $gpg_dir);

my $gpg_options = File::Spec->catfile($config->get_key("web_ui:gpg_homedir"),
                                      "options");
if (! -f $gpg_options) {
    print "Creating options file $gpg_options\n";
    my $keyrings_dir =
        File::Spec->catfile(dirname($config->get_key("web_ui:gpg_homedir")),
                            "keyrings");
    mkpath($keyrings_dir);
    chown($uid, $gid, $keyrings_dir);
    symchmod("g+w", $keyrings_dir);

    open F, ">$gpg_options";
    print F "keyring $keyrings_dir/uploaders.gpg\n";
    close F;
    chown($uid, $gid, $gpg_options);
    symchmod("g+w", $gpg_options);
}

lib/Arepa/Builder/Sbuild.pm  view on Meta::CPAN

            }
        }
    }
    else {
        print STDERR "Couldn't check for a 'localhost' alias in $full_etc_hosts_path\n";
    }

    # Make sure certain directories exist and are writable by the 'sbuild'
    # group
    $self->ui_module->print_title("Creating build directories");
    my ($login, $pass, $uid, $gid) = getpwnam($Arepa::AREPA_MASTER_USER);
    if (!defined $login) {
        croak "'" . $Arepa::AREPA_MASTER_USER . "' user doesn't exist!";
    }
    foreach my $dir (qw(build var/lib/sbuild var/lib/sbuild/srcdep-lock)) {
        my $full_path = "$builder_dir/$dir";
        unless (-d $full_path) {
            mkpath $full_path;
            find({ wanted => sub {
                        chmod("g+w", $File::Find::name);
                        chown $uid, $gid, $File::Find::name;
                   },
                   follow => 0 },
                 $full_path);
        }
    }

    $self->ui_module->print_title("Binding files");
    Arepa::Builder::Sbuild->init($builder_name);

    $self->ui_module->print_title("Updating package list");



( run in 1.585 second using v1.01-cache-2.11-cpan-5735350b133 )