Update - SlimServer working, needed to add YAML-Syck,
and some compression libs, will update perl binary soon.
But for now we have this linked against the native mysql
and local perl codebase!:
Some hacks needed "Library/SlimDevices/slimserver.pref":
dbpassword: ''
dbsource: dbi:mysql:database=slimserver
dbusername: root
And some other bits and bobs (fake a system_profiler) to fool the server.
But we are a go (takes a while to start up):
# cd SlimServer_v6.5.4
# ./slimserver.pl
* Warning: SlimServer must not be run as root! iphone - carry on! *
2007-12-29 20:06:55.9757 Warning: Migrating from 6.3.x used with MySQL!
2007-12-29 20:08:05.3406 Your data source needs to be configured. Please open your web browser,
2007-12-29 20:08:05.3452 go to the following URL, and click on the "Server Settings" link.
2007-12-29 20:08:05.3478 The URL to access SlimServer is now:
http://iPhone:9000/
Tada!
updates - DBD/DBI working:
# cat test.pl
use DBI; my $ds='DBI:mysql:mysql:localhost';my $un='root';my $pw='';
my $d=DBI->connect($ds,$un,$pw);
my $s=$d->prepare(qq{select host from user where host like '%iPhone'});
$s->execute();print $s->fetchrow_array()."\n";
# /opt/iphone/bin/perl ./test.pl
iPhone
Hurray!
Demo client code for Phoney
This works on the iphone with this version of perl
#!/opt/iphone/bin/perl -w
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "imac",
PeerPort => "22",
)
or die "cannot connect to ssh port at imac";
while ( <$remote> ) { print }
# ./client.pl
SSH-1.99-OpenSSH_4.5
^C
Added some modules to help out some folks
perl.with.extra.modules.tgz now also contains the
bootstrap compiler that will work on OSX 10.4.10 on Intel to build new modules, as the
boot strap method below.
=head2 Wed Oct 10 23:08:12 2007: CModule L HTML::Parser|HTML::Parser
=head2 Wed Oct 10 23:28:20 2007: CModule L Compress::Zlib|Compress::Zlib
=head2 Wed Oct 10 23:35:15 2007: CModule L Compress::Raw::Zlib|Compress::Raw::Zlib
=head2 Sat Oct 27 18:41:23 2007: CModule L LWP|LWP
=head2 Sat Oct 27 18:43:25 2007: CModule L URI|URI
=head2 Sat Oct 27 18:44:57 2007: CModule L SOAP::Lite|SOAP::Lite
=head2 Sat Oct 27 18:46:07 2007: CModule L XML::Simple|XML::Simple
=head2 Sat Oct 27 18:47:09 2007: CModule L HTML::Template|HTML::Template
=head2 Sat Nov 3 22:33:57 2007: CModule L XML::Parser|XML::Parser
Another example boot strap
mac /perlmodules/ uname -a
Darwin imac 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-
792.22.5~1/RELEASE_I386 i386 i386
wget http://search.cpan.org/CPAN/authors/id/M/MS/MSERGEANT/XML-Parser-2.34.ta...
imac /perlmodules/ tar zxvf XML-Parser-2.34.tar.gz
imac /XML-Parser-2.34/ /opt/iphone/bin/perl.bootstrap Makefile.PL
Checking if your kit is complete...
Looks good
Have /opt/iphone/lib/perl5/5.8.8/arm-apple-darwin-i386/Config.pm expected /opt/iphone/lib/perl5/5.8.8/
arm-apple-darw
in-2level/Config.pm
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [arm-apple-darwin-i386]
Config says: [arm-apple-darwin-i386]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Have /opt/iphone/lib/perl5/5.8.8/arm-apple-darwin-i386/Config.pm expected /opt/iphone/lib/perl5/5.8.8/
arm-apple-darw
in-2level/Config.pm
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [arm-apple-darwin-i386]
Config says: [arm-apple-darwin-i386]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Writing Makefile for XML::Parser::Expat
Writing Makefile for XML::Parser
imac /XML-Parser-2.34/ make
cp Parser/Encodings/x-sjis-cp932.enc blib/lib/XML/Parser/Encodings/x-sjis-cp932.enc
cp Parser/Encodings/iso-8859-7.enc blib/lib/XML/Parser/Encodings/iso-8859-7.enc
cp Parser/Style/Tree.pm blib/lib/XML/Parser/Style/Tree.pm
cp Parser/Encodings/iso-8859-9.enc blib/lib/XML/Parser/Encodings/iso-8859-9.enc
cp Parser/Encodings/x-euc-jp-unicode.enc blib/lib/XML/Parser/Encodings/x-euc-jp-unicode.enc
cp Parser/Encodings/README blib/lib/XML/Parser/Encodings/README
cp Parser/Encodings/euc-kr.enc blib/lib/XML/Parser/Encodings/euc-kr.enc
cp Parser/Encodings/windows-1250.enc blib/lib/XML/Parser/Encodings/windows-1250.enc
cp Parser/Encodings/windows-1252.enc blib/lib/XML/Parser/Encodings/windows-1252.enc
cp Parser/Encodings/big5.enc blib/lib/XML/Parser/Encodings/big5.enc
cp Parser/Encodings/iso-8859-3.enc blib/lib/XML/Parser/Encodings/iso-8859-3.enc
cp Parser/Encodings/Japanese_Encodings.msg blib/lib/XML/Parser/Encodings/Japanese_Encodings.msg
cp Parser/Style/Subs.pm blib/lib/XML/Parser/Style/Subs.pm
cp Parser/Encodings/iso-8859-4.enc blib/lib/XML/Parser/Encodings/iso-8859-4.enc
cp Parser/Encodings/iso-8859-8.enc blib/lib/XML/Parser/Encodings/iso-8859-8.enc
cp Parser/Encodings/x-euc-jp-jisx0221.enc blib/lib/XML/Parser/Encodings/x-euc-jp-jisx0221.enc
cp Parser/Encodings/iso-8859-2.enc blib/lib/XML/Parser/Encodings/iso-8859-2.enc
cp Parser/Encodings/x-sjis-jdk117.enc blib/lib/XML/Parser/Encodings/x-sjis-jdk117.enc
cp Parser/Encodings/x-sjis-unicode.enc blib/lib/XML/Parser/Encodings/x-sjis-unicode.enc
cp Parser/LWPExternEnt.pl blib/lib/XML/Parser/LWPExternEnt.pl
cp Parser/Style/Objects.pm blib/lib/XML/Parser/Style/Objects.pm
cp Parser.pm blib/lib/XML/Parser.pm
cp Parser/Style/Debug.pm blib/lib/XML/Parser/Style/Debug.pm
cp Parser/Encodings/x-sjis-jisx0221.enc blib/lib/XML/Parser/Encodings/x-sjis-jisx0221.enc
cp Parser/Style/Stream.pm blib/lib/XML/Parser/Style/Stream.pm
cp Parser/Encodings/iso-8859-5.enc blib/lib/XML/Parser/Encodings/iso-8859-5.enc
cp Expat.pm ../blib/lib/XML/Parser/Expat.pm
/opt/iphone/bin/perl.bootstrap /opt/iphone/lib/perl5/5.8.8/ExtUtils/xsubpp -noprototypes -typemap /opt/iphone/lib/pe
rl5/5.8.8/ExtUtils/typemap -typemap typemap Expat.xs > Expat.xsc && mv Expat.xsc Expat.c
arm-apple-darwin-cc -c -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-st
atement -O0 -DVERSION=\"2.34\" -DXS_VERSION=\"2.34\" "-I/opt/iphone/lib/perl5/5.8.8/arm-apple-darwin-2level/CORE"
Expat.c
Running Mkbootstrap for XML::Parser::Expat ()
chmod 644 Expat.bs
rm -f ../blib/arch/auto/XML/Parser/Expat/Expat.bundle
env MACOSX_DEPLOYMENT_TARGET=10.3 arm-apple-darwin-cc -bundle -undefined dynamic_lookup Expat.o
-o ../blib/arch/auto/XML/Parser/Expat/Expat.bundle \
-lexpat \
chmod 755 ../blib/arch/auto/XML/Parser/Expat/Expat.bundle
cp Expat.bs ../blib/arch/auto/XML/Parser/Expat/Expat.bs
chmod 644 ../blib/arch/auto/XML/Parser/Expat/Expat.bs
Manifying ../blib/man3/XML::Parser::Expat.3
Manifying blib/man3/XML::Parser::Style::Objects.3
Manifying blib/man3/XML::Parser::Style::Debug.3
Manifying blib/man3/XML::Parser.3
Manifying blib/man3/XML::Parser::Style::Subs.3
Manifying blib/man3/XML::Parser::Style::Tree.3
Manifying blib/man3/XML::Parser::Style::Stream.3
Boot strap via CPAN and then rsync
On the i386 box:
imac /perlmodules/ /opt/iphone/bin/perl.bootstrap -MCPAN -eshell
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')
cpan> force install Compress::Raw::Zlib
CPAN: Storable loaded ok
Going to read /Users/core/.cpan/Metadata
Database was generated on Wed, 10 Oct 2007 22:36:45 GMT
Running install for module Compress::Raw::Zlib
Running make for P/PM/PMQS/Compress-Raw-Zlib-2.006.tar.gz
CPAN: Digest::MD5 loaded ok
[snip - clearly the tests fail]
Writing /opt/iphone/lib/perl5/site_perl/5.8.8/arm-apple-darwin-2level/auto/Compress/Raw/Zlib/.packlist
Appending installation info to /opt/iphone/lib/perl5/5.8.8/arm-apple-darwin-2level/perllocal.pod
/usr/bin/make install -- OK
Now a quick rsync:
imac /iphone/ rsync -av /opt/iphone/ root@iphone:opt/iphone/
root@iphone's password:
building file list ... done
lib/perl5/site_perl/5.8.8/
lib/perl5/site_perl/5.8.8/Compress/
lib/perl5/site_perl/5.8.8/Compress/Zlib.pm
[snip]
Over on the iphone:
# /opt/iphone/bin/perl.arm -MCompress::Raw::Zlib -e "print q[zlib ver ]. Compress::Raw::Zlib::ZLIB_VERSION.qq[\n]"
zlib ver 1.2.3
Perfect!
Cross compiled modules...
Thanks to LiquidIce for suggesting this one!
With a boot strap we can do this:
23:06 imac /HTML-Parser-3.56/ file blib/arch/auto/HTML/Parser/Parser.bundle
23:06 blib/arch/auto/HTML/Parser/Parser.bundle: Mach-O bundle acorn
# cat test.html test.pl
<html>
<body>
this is a test
</body>
</html>
#!/opt/iphone/bin/perl -w
use strict;
package HTMLStrip;
use base "HTML::Parser";
sub text {
my ($self, $text) = @_;
print $text;
}
my $p = new HTMLStrip;
while (<>) { $p->parse($_); }
$p->eof;
# ./test.pl < test.html
this is a test
I need to package this method up when I get a chance
PERL
GO, GO NATIVE PERL - this was all done on the iphone!
# /opt/iphone/bin/perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')
cpan> install Getopt::Long
Running install for module Getopt::Long
Running make for J/JV/JV/Getopt-Long-2.36.tar.gz
Fetching with Net::FTP:
ftp://cpan.pair.com/pub/CPAN/authors/id/J/JV/JV/Getopt-Long-2.36.tar.gz
CPAN.pm: Going to build J/JV/JV/Getopt-Long-2.36.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Getopt::Long
[SNIP]
Installing /opt/iphone/lib/perl5/5.8.8/Getopt/Long.pm
Installing /opt/iphone/man/man3/Getopt::Long.3
Appending installation info to /opt/iphone/lib/perl5/5.8.8/arm-apple-darwin-2level/perllocal.pod
make install -- OK
AND NOW FOR THE MAGIC
# cat test.pl
#!/opt/iphone/bin/perl
use strict;
use Getopt::Long;
my $adj1;
my $adj2;
&GetOptions("adj1:s" => \$adj1,
"adj2:s" => \$adj2,
);
print "\nThe " . $adj1 . " iphone is " . $adj2 . "!\n";
AND NOW FOR THE MAGIC - LETS run the CODE!
# ./test.pl -adj1 smelly -adj2 forceful
The smelly iphone is forceful!
# ./test.pl -adj1 gorgeous -adj2 beautiful
The gorgeous iphone is beautiful!