PApp
view release on metacpan or search on metacpan
I18n/I18n.pm view on Meta::CPAN
Export translation domain C<$domain> in binary hash format to directory
C<$path>, creating it if necessary.
=cut
sub export_dpo($$;$$) {
my ($domain, $path, $uid, $gid, $attr) = @_;
local $PApp::SQL::DBH = PApp::Config::DBH;
mkdir $path, defined $attr ? $attr | 0111 : 0755;
chown $uid, $gid, $path if defined $uid;
unlink for glob "$path/*.dpo";
for my $lang (sql_fetchall "select distinct s.lang
from msgid i, msgstr s
where i.domain = ? and i.nr = s.nr",
$domain) {
my $pofile = "$path/$lang.dpo";
my $st = sql_exec \my($id, $msg),
"select id, msg
from msgid i, msgstr s
where i.domain = ? and i.nr = s.nr and s.lang = ?
I18n/I18n.pm view on Meta::CPAN
next outer unless $prime % $i;
}
last;
}
}
my $dpo = new PApp::I18n::DPO_Writer "$pofile~", $prime;
while ($st->fetch) {
$dpo->add(utf8_on $id,utf8_on $msg) if $id ne $msg;
}
undef $dpo;
chown $uid, $gid, "$pofile~" if defined $uid;
chmod $attr, "$pofile~" if defined $attr;
rename "$pofile~", $pofile;
push @files, $pofile;
} else {
unlink $pofile;
}
}
}
package PApp::I18n::PO_Reader;
Makefile.PL view on Meta::CPAN
# 5.7. is DEFINITELY required, due to utf8 support
# maybe 5.6.1 will work, once it's out, but I doubt it.
require 5.007;
use Config;
WriteMakefile(
'dist' => {
PREOP => '(sdf -2txt_pod doc/intro.sdf; rm intro.out) | tee README >$(DISTVNAME)/README; '.
'chown -R root.root .; chmod -R u=rwX,go=rX . ;',
COMPRESS => 'gzip -9v',
SUFFIX => '.gz',
DIST_DEFAULT=> 'predist',
},
'NAME' => 'PApp',
'VERSION_FROM' => 'PApp.pm',
'DIR' => [qw(I18n Recode Storable)],
'LIBS' => [''],
'DEFINE' => '',
'INC' => '',
papp-install view on Meta::CPAN
my $create_options = $ENV{PAPP_CREATE_TBALE_OPTIONS} || "ENGINE=MyISAM";
sub crdir {
local $_ = shift;
print "Creating directory $_... ";
if (-d $_) {
print "[skipped] ";
} else {
mkdir $_, 0777 or die "$!\n";
}
chown $CFG{PAPP_UID}, $CFG{PAPP_GID}, $_;
print "ok\n";
}
sub install($$) {
my ($s, $d) = @_;
if (compare($s, $d)) {
copy($s, "$d~") or die "copy($s,$d~): $!\n";
chown $CFG{PAPP_UID}, $CFG{PAPP_GID}, "$d~";
chmod ((stat $s)[2] & 07777, "$d~");
rename "$d~", $d or die "rename($d~,$d): $!\n";
0;
} else {
chown $CFG{PAPP_UID}, $CFG{PAPP_GID}, $d;
chmod ((stat $s)[2] & 07777, $d);
1;
}
}
if ($mode_install) {
crdir $lib;
crdir $CFG{I18NDIR};
for my $dir (qw(style etc)) {
papp-install view on Meta::CPAN
}
}
my $umask = umask 022;
mkdir $ETCDIR, 0777;
umask 077;
unless ($mode_skipconfig) {
install ("config", "$ETCDIR/config"); chmod 0644, "$ETCDIR/config";
install ("secure", "$ETCDIR/secure"); chmod 0600, "$ETCDIR/secure";
umask $umask;
print "\n$ETCDIR/secure is mode 600, better chown or chgrp it to the group your webserver or trusted user is running under.\n\n";
}
}
if ($mode_init || $mode_update) {
print <<EOF;
This initializes the database and library directories used by PApp. It
assumes that the DBD driver understands the "func" method. MySQL currently
does this.
write-config view on Meta::CPAN
EOF
get_value 0, "SYSID", "unique system id", "0";
use Socket;
$CFG{SYSID} = unpack "N", Socket::inet_aton $CFG{SYSID};
print <<EOF;
PApp will usually run as a specific user/group (e.g. www/www). All files
installed will be chown'ed to that uid/gid, including the file that
contains "secret" information.
EOF
do {
if (defined getpwuid $CFG{PAPP_UID}) {
$CFG{PAPP_UID} = getpwuid ($CFG{PAPP_UID});
}
get_value 0, "PAPP_UID", "papp user id", "0";
} until (($CFG{PAPP_UID} ne ((getpwnam $CFG{PAPP_UID})[2])
( run in 1.387 second using v1.01-cache-2.11-cpan-71847e10f99 )