#!/usr/bin/perl -w # create SBo.sqlite3 database for SBoTools limnoria plugin. # run with one argument: the path to the SBo repo. This is # the directory named after the version number, which contains # SLACKBUILDS.TXT. A git clone will *not* do, needs to be a # rsync or wget -r copy. # Actually only SLACKBUILDS.TXT, TAGS.txt, and the */*/*.info files # are used. # database isn't fully normalized. *shrug*. print <) { /^MAINTAINER="(.*?)"/m and $mname = $1; /^EMAIL="(.*?)"/m and $ename = $1; } close $info; if(!$maintids{$mname}) { $mname =~ s/'/''/g; $lastmaint++; print "insert into maintainers values($lastmaint, '$mname');\n"; $maintids{$mname} = $lastmaint; } if(!$emailids{$ename}) { $ename =~ s/'/''/g; $lastemail++; print "insert into emails values($lastemail, '$ename');\n"; $emailids{$ename} = $lastemail; } return ($maintids{$mname}, $emailids{$ename}); } open $sbtxt, "<" . $sbopath . "/SLACKBUILDS.TXT" or die $!; { local $/ = ''; while(<$sbtxt>) { my ($name, $cat, $ver, $deps, $desc, $maintid, $emailid); $deps = ""; chomp; /^SLACKBUILD NAME:\s+(\S+)$/m and $name = $1; /^SLACKBUILD LOCATION:\s+\.\/([^\/]*)\//m and $cat = $1; /^SLACKBUILD VERSION:\s+(\S+)$/m and $ver = $1; /^SLACKBUILD REQUIRES:\s+(\S.+)\n/m and $deps = $1; /^SLACKBUILD SHORT DESCRIPTION:\s+(.+)$/m and $desc = $1; if($desc =~ /^$name \((.+)\)$/) { $desc = $1; } $desc =~ s/'/''/g; $catid = get_cat_id($cat); $buildcat{$name} = $catid; $buildver{$name} = $ver; $builddeps{$name} = $deps; $builddesc{$name} = $desc; ($maintid, $emailid) = get_maint($cat, $name); $buildmaint{$name} = $maintid; $buildemail{$name} = $emailid; push @builds, $name; } } close $sbtxt; print "\n"; $buildid = 0; for(@builds) { $buildid++; $buildids{$_} = $buildid; print <) { my ($build, $t, @tags); chomp; next if /: No tags found for/; ($build, $t) = /^([^:]*):\s+(.*)$/; @tags = split /,/, $t; for(@tags) { next if /^\s*$/; s/'/''/g; print <