View Single Post
Old 11-16-2013, 08:25 PM   #2
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Step 0: Get a compiler configured to build this stuff.
I'm going to use native arm debian compiler on my PC via qemu.
You can use w/e, I provide a download to the qemu ready debian image I used.

Step 1 and beyond...: Nginx: http://wiki.nginx.org/Main
I grabbed the source and configured like:

nginx-0.7.67
Quote:
CFLAGS="-O2 -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE" CXXFLAGS=${CFLAGS} LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-rpath,/mnt/us/extensions/nginx/usr/lib" ./configure --prefix=/mnt/us/extensions/nginx/usr --with-pcre --user=root --group=root --with-http_perl_module --with-perl_modules_path=/mnt/us/extensions/perl/usr/lib/5.10.1 --with-perl=/mnt/us/extensions/perl/usr/bin/perl --http-fastcgi-temp-path=/mnt/us/extensions/system/fastcgi
Quote:
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1 library is not used
+ using system zlib library

nginx path prefix: "/mnt/us/extensions/nginx/usr"
nginx binary file: "/mnt/us/extensions/nginx/usr/sbin/nginx"
nginx configuration prefix: "/mnt/us/extensions/nginx/usr/conf"
nginx configuration file: "/mnt/us/extensions/nginx/usr/conf/nginx.conf"
nginx pid file: "/mnt/us/extensions/nginx/usr/logs/nginx.pid"
nginx error log file: "/mnt/us/extensions/nginx/usr/logs/error.log"
nginx http access log file: "/mnt/us/extensions/nginx/usr/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "/mnt/us/extensions/system/fastcgi"
shove that on the kindle.

we also want to build lighttpd, just for the spawn-fcgi it has. (meh, call me lazy)

we configure it thusly:

lighttpd-1.4.19
Quote:
CFLAGS="-O2 -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE" CXXFLAGS=${CFLAGS} LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-rpath,/mnt/us/extensions/lighttpd/usr/lib" ./configure --prefix=/mnt/us/extensions/lighttpd/usr --with-fam --with-bzip2 --with-zlib --with-pcre
and shove that on the kindle

so next we need a database engine. I'm going with postgresql (mainly because mysql is bit heavy, doesn't natively support arm processor and finally is a total PITA to build) NOTE: The kindle has sqlite and RT supports that but meh. I wanted something a bit more hunky.

we configure like so:

postgresql-8.4-8.4.2
Quote:
CFLAGS="-O2 -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE" CXXFLAGS=${CFLAGS} LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-rpath,/mnt/us/extensions/postgresql/usr/lib" ./configure --prefix=/mnt/us/extensions/postgresql/usr --with-libxml --with-libxslt --with-system-tzdata=/mnt/us/extensions/postgresql/usr/share/zoneinfo/ --with-python --with-perl
we also hack thru the source removing all the getuid() checks (there are 4 IIRC) so we can run it as root.

Also we could adjust the file permission checks to be 755 (say) rather than 700 since this is gonna live on a kindle and no one should be insane enough to ACTUALLY use this in production to say, run a business. Like really. Whut? Don't. or lock it down like crazy and actually add some user accounts etc... (you are like totally on your own there)

and shove that on the kindle

Now... we also need some space for that to run in. It won't run on FAT (I couldn't get it to anyways) so let' give it a bit of ext3 space

Quote:
dd if=/dev/zero of=/mnt/us/extensions/postgresql/data/data.ext3 bs=1M count=150
mkfs.ext3 /mnt/us/extensions/postgresql/data/data.ext3
tune2fs -i 0 -c 0 /mnt/us/extensions/postgresql/data/data.ext3
mkdir /mnt/us/extensions/postgresql/data/rt
mount -o loop -t ext3 /mnt/us/extensions/postgresql/data/data.ext3 /mnt/us/extensions/postgresql/data/rt
we need to initialize that space ready for a database so we run

/mnt/us/extensions/postgresq/usr/bin/initdb /mnt/us/extensions/postgresql/data/rt

done

Next up we need perl

Configuring it goes like this:

perl-5.10.x
Quote:
CFLAGS="-O2 -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE" CXXFLAGS=${CFLAGS} LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-rpath,/mnt/us/extensions/perl/usr/lib" ./Configure -des -Dprefix=/mnt/us/extensions/perl/usr -Dvendorprefix=/mnt/us/extensions/perl/usr -Dpager="/usr/bin/less" -Duseshrplib
(you can remove the -des and do it more slowly, up to you, I've done it both ways in the past)

we also need to add one or two missing required modules via cpan.

MISSING RT MODULES to get via CPAN
Quote:
HTTP::Request::Common LWP Encode Crypt::Eksblowfish Module::Versions::Report List::MoreUtils DBI Devel::StackTrace HTTP::Message Text::Password::Pronounceable Devel::GlobalDestruction Time::ParseDate Tree::Simple HTML::Scrubber HTML::Quoted Mail::Mailer Data::GUID HTML::Mason HTML::Entities LWP::Simple Symbol::Global::Name DateTime::Format::Natural Plack Class::Accessor Text::Wrapper Regexp::Common::net::CIDR Log::Dispatch HTML::FormatText::WithLinks::AndTables DateTime CGI::Emulate::PSGI Text::Quoted Regexp::IPv6 CSS::Squish DateTime::Locale CGI::PSGI Apache::Session Date::Extract HTML::Mason::PSGIHandler MIME::Entity Locale::Maketext::Lexicon Module::Refresh Role::Basic Date::Manip HTML::RewriteAttributes Text::Template XML::RSS Text::WikiFormat DBIx::SearchBuilder File::ShareDir Regexp::Common HTML::FormatText::WithLinks Mail::Header Locale::Maketext::Fuzzy Email::Address::List Net::CIDR JSON UNIVERSAL::require Email::Address Plack::Handler::Starlet URI::QueryParam URI MIME::Types FCGI::ProcManager FCGI GD::Text GD GD::Graph PerlIO::eol GnuPG::Interface IPC::Run GraphViz Data::ICal LWP::UserAgent Crypt::SSLeay Net::SSL LWP::Protocol::https Mozilla::CA Apache::Request Apache::DBI Apache::DBI DBD::Pg Convert::Color SOME LWP::UserAgent Mozilla::CA Net::SSL LWP::Protocol::https Crypt::SSLeay Convert::Color DBD::Pg Apache::DBI URI MIME::Types URI::QueryParam Data::ICal Apache::DBI Apache::Request HTTP::Request::Common LWP IPC::Run GraphViz PerlIO::eol GnuPG::Interface GD::Graph GD::Text GD FCGI::ProcManager FCGI DateTime CGI::Emulate::PSGI Text::Quoted Regexp::IPv6 Encode Crypt::Eksblowfish CSS::Squish DateTime::Locale CGI::PSGI Module::Versions::Report Apache::Session Date::Extract HTML::Mason::PSGIHandler MIME::Entity List::MoreUtils DBI Locale::Maketext::Lexicon Devel::StackTrace Module::Refresh Role::Basic HTTP::Message Text::Password::Pronounceable Devel::GlobalDestruction Time::ParseDate Date::Manip HTML::RewriteAttributes Tree::Simple Text::Template HTML::Scrubber HTML::Quoted Text::WikiFormat XML::RSS DBIx::SearchBuilder Data::GUID Mail::Mailer File::ShareDir Regexp::Common HTML::Mason HTML::Entities LWP::Simple Symbol::Global::Name HTML::FormatText::WithLinks DateTime::Format::Natural Plack Mail::Header Class::Accessor Locale::Maketext::Fuzzy Email::Address::List Text::Wrapper Regexp::Common::net::CIDR HTML::FormatText::WithLinks::AndTables Log::Dispatch Net::CIDR JSON UNIVERSAL::require Email::Address Plack::Handler::Starlet
did I say one or two? okay I lied, lots...

here is one way to install a SINGLE one of those that bypasses to need to do self testing...
Quote:
perl -MCPAN -e "CPAN::Shell->notest('install', 'Plack::Handler::Starlet')"
fortunately some idiot already downloaded/tested all the ones we need...
You can also limit the above list by removing inessential thing like Graphviz etc... (I did this)

Quote:
If the script reports any missing dependencies, install them by
hand, or run the following command as a user who has permission to
install perl modules on your system:
make fixdeps

(I did it by hand, meh)

don't shove that on the kindle just yet.


[SNIP ADD THE CONFIGURING postgresql HERE ]

We need to configure RT like this:

rt-4.2.0
Quote:
CFLAGS="-O2 -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE" CXXFLAGS=${CFLAGS} LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-rpath,/mnt/us/extensions/rt/usr/lib" ./configure --prefix=/mnt/us/extensions/rt/usr --with-my-user-group --with-db-dba=root --with-db-port=5432 --with-web-handler=fastcgi,standalone,modperl2 --with-db-type=Pg
[SNIP ADD THE CONFIGURING AND BUILDING RT HERE ]

and then a couple of extra commands pointed at our postgresql database server
[Add details about that.]



Okay let's test out our RT fast-cgi module
[root@kindle root]# LD_LIBRARY_PATH=/mnt/us/extensions/postgresql/usr/lib/:$LD_LIBRARY_PATH /mnt/us/extensions/lighttpd/usr/bin/spawn-fcgi -p 127.0.0.1 -p 9000 -f /mnt/us/extensions/rt/usr/sbin/rt-server.fcgi
Quote:
spawn-fcgi.c.197: child spawned successfully: PID: 26985
[root@kindle root]# FastCGI: manager (pid 26985): initialized
FastCGI: server (pid 26990): initialized
FastCGI: manager (pid 26985): server (pid 26990) started
seems to work

[SNIP ADD THE CONFIGURING nginx HERE ]

TBC:



[JUMP TO STARTING THE DATABASE]

[root@kindle bin]# /mnt/us/extensions/postgresql/usr/bin/postgres -D /mnt/us/extensions/postgresql/data/rt
Quote:
"root" execution of the PostgreSQL server is not permitted.
But this is a kindle so... yeah...
The server WILL be started as a privileged user ID
obviously this could lead to possible system security compromise.
but we don't have much choice so... dont go running your business from this :P
YOU HAVE BEEN WARNED :D.

LOG: could not create IPv6 socket: Address family not supported by protocol
LOG: database system was shut down at 2013-11-16 23:55:15 GMT
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
so that's working...

Now the DOCS say we can WITHOUT running nginx use the invocation:
[root@kindle root]# LD_LIBRARY_PATH=/mnt/us/extensions/postgresql/usr/lib/:$LD_LIBRARY_PATH /mnt/us/extensions/rt/usr/sbin/rt-server

and browse the thing, however doing so will top out the memory required to above 240 MB and the kindle will reboot...

So... not an option.

Last edited by twobob; 11-16-2013 at 10:07 PM.
twobob is offline   Reply With Quote