Created
December 31, 2013 20:37
-
-
Save Kwpolska/8201997 to your computer and use it in GitHub Desktop.
PKGBUILDer — original perl vs bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# PKGBUILDer | |
# Part of KRU | |
# Copyright Kwpolska 2010. Licensed on GPLv3. | |
# USAGE: ./build pkg1 [pkg2] [pkg3] (and more) | |
use warnings; | |
use strict; | |
use LWP::Simple; | |
use Archive::Any; | |
use Term::ANSIColor qw(:constants); | |
$SIG{'INT' } = 'freset'; $SIG{'QUIT'} = 'freset'; | |
$SIG{'HUP' } = 'freset'; $SIG{'TRAP'} = 'freset'; | |
$SIG{'ABRT'} = 'freset'; $SIG{'STOP'} = 'freset'; | |
sub info { | |
print BOLD, GREEN, "==> ", RESET, BOLD, shift."\n", RESET; | |
} | |
sub freset { | |
print RESET, BOLD, "Okay!\nExiting right now.\n", RESET; | |
exit(1); | |
} | |
sub generate { | |
my $pkg=shift; | |
info("Building package ".$pkg."..."); | |
my $tar=$pkg.".tar.gz"; | |
my $url="http://aur.archlinux.org/packages/".$pkg."/".$tar; | |
#let's download the file. | |
info("Downloading the tarball..."); | |
getstore($url, "./".$tar); | |
#untar it... | |
info("Extracting the tarball..."); | |
my $archive = Archive::Any->new("./".$tar); | |
$archive->extract; | |
#build it. | |
system('cd '.$pkg.'; time makepkg -si'); | |
info("The build finished."); | |
} | |
my $argc = $#ARGV + 1; | |
my $i = 0; | |
if ($argc eq '0') { | |
print "ERROR: No package specified. | |
HINT: ./build.pl pkg [pkg2]\n"; | |
} | |
while ($i != $argc) { | |
my $arg = $ARGV[$i]; #There was no other way. | |
generate($arg); | |
$i = $i + 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generate(package) { | |
pk=${package:0:2} | |
wget http://aur.archlinux.org/$pk/$package.tar.gz | |
tar -xzvf $package.tar.gz | |
cd $package | |
makepkg -si | |
cd .. | |
} | |
for package in $@, do generate(package); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment