-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Torsten Veller
committed
Jan 16, 2011
1 parent
5f6bb6d
commit efcaa15
Showing
5 changed files
with
128 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
Changes | ||
------- | ||
|
||
0.02.09 | ||
- Fixed bugs that occured when using new profiles (2008.0+) | ||
- Implemented getPortageMakeParam() | ||
- getArch() is now a wrapper for getPortageMakeParam() only | ||
|
||
0.02.08 | ||
- Fixed bug #216484 - Affected function: getArch() | ||
|
||
0.02.07 | ||
- Optional parameter repo: getAvailableEbuilds() | ||
- New functions: searchPackageByHerd(), searchPackageByMaintainer() | ||
- Fixed bug #178745 - Affected function: getParamFromFile() | ||
|
||
0.02.06 | ||
- fileBelongsToPackage(): Do not die if CONTENTS file is missing. (Reported by Michael Cummings <[email protected]>) | ||
- Speedup functions getFilesOfInstalledPackage(), fileBelongsToPackage() | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ package PortageXS; | |
# | ||
# author : Christian Hartmann <[email protected]> | ||
# license : GPL-2 | ||
# header : $Header: /srv/cvsroot/portagexs/trunk/lib/PortageXS.pm,v 1.13 2007/05/20 14:17:40 ian Exp $ | ||
# header : $Header: /srv/cvsroot/portagexs/trunk/lib/PortageXS.pm,v 1.14 2008/12/01 19:53:27 ian Exp $ | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# | ||
|
@@ -17,7 +17,7 @@ package PortageXS; | |
# | ||
# ----------------------------------------------------------------------------- | ||
|
||
$VERSION='0.02.07'; | ||
$VERSION='0.02.09'; | ||
|
||
use PortageXS::Core; | ||
use PortageXS::System; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ package PortageXS::Core; | |
# | ||
# author : Christian Hartmann <[email protected]> | ||
# license : GPL-2 | ||
# header : $Header: /srv/cvsroot/portagexs/trunk/lib/PortageXS/Core.pm,v 1.17 2007/05/20 14:17:40 ian Exp $ | ||
# header : $Header: /srv/cvsroot/portagexs/trunk/lib/PortageXS/Core.pm,v 1.19 2008/12/01 19:53:27 ian Exp $ | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# | ||
|
@@ -18,10 +18,13 @@ package PortageXS::Core; | |
# ----------------------------------------------------------------------------- | ||
|
||
use DirHandle; | ||
use Shell::EnvImporter; | ||
require Exporter; | ||
our @ISA = qw(Exporter PortageXS); | ||
our @EXPORT = qw( | ||
getArch | ||
getPortageMakeParam | ||
getPortageMakeParamHelper | ||
getPortdir | ||
getPortdirOverlay | ||
getFileContents | ||
|
@@ -51,15 +54,50 @@ our @EXPORT = qw( | |
|
||
# Description: | ||
# Returnvalue is ARCH set in the system-profile. | ||
# Wrapper for old getArch()-version. Use getPortageMakeParam() instead. | ||
# | ||
# Example: | ||
# $arch=$pxs->getArch(); | ||
sub getArch { | ||
my $self = shift; | ||
my $curPath = ''; | ||
return $self->getPortageMakeParam('ARCH'); | ||
} | ||
|
||
# Description: | ||
# Helper for getPortageMakeParam() | ||
sub getPortageMakeParamHelper { | ||
my $self = shift; | ||
my $curPath = shift; | ||
my @files = (); | ||
my $parent = ''; | ||
my $buffer = ''; | ||
|
||
if (-e $curPath.'/make.defaults') { | ||
push(@files,$curPath.'/make.defaults'); | ||
} | ||
if (! -e $curPath.'/parent') { | ||
return @files; | ||
} | ||
$parent=$self->getFileContents($curPath.'/parent'); | ||
foreach (split(/\n/,$parent)) { | ||
push(@files,$self->getPortageMakeParamHelper($curPath.'/'.$_)); | ||
} | ||
|
||
return @files; | ||
} | ||
|
||
# Description: | ||
# Returnvalue is $PARAM set in the system-profile. | ||
# | ||
# Example: | ||
# $arch=$pxs->getPortageMakeParam(); | ||
sub getPortageMakeParam { | ||
my $self = shift; | ||
my $param = shift; | ||
my @files = (); | ||
my @etcfiles = qw(/etc/make.globals /etc/make.conf); | ||
my @profilefiles = (); | ||
my $v = ''; | ||
my $parent = ''; | ||
|
||
if(!-e $self->{'MAKE_PROFILE_PATH'}) { | ||
$self->print_err('Profile not set!'); | ||
|
@@ -69,22 +107,42 @@ sub getArch { | |
$curPath=$self->getProfilePath(); | ||
} | ||
|
||
while(1) { | ||
if (-e $curPath.'/make.defaults') { | ||
push(@files,$curPath.'/make.defaults'); | ||
@profilefiles=$self->getPortageMakeParamHelper($curPath); | ||
push(@files,reverse(@profilefiles)); | ||
push(@files,@etcfiles); | ||
|
||
foreach (@files) { | ||
my $importer = Shell::EnvImporter->new( shell => "bash", | ||
file => $_, | ||
auto_run => 1, | ||
auto_import => 1 | ||
); | ||
|
||
$importer->shellobj->envcmd('set'); | ||
$importer->run(); | ||
|
||
if ($ENV{$param} ne '') { | ||
$v=$ENV{$param}; | ||
$v=~s/\\t/ /g; | ||
$v=~s/\t/ /g; | ||
$v=~s/^\$'(.*)'$/$1/m; | ||
$v=~s/^'(.*)'$/$1/m; | ||
$v=~s/\\n/ /g; | ||
$v=~s/\\|\'|\\'|\$//gmxs; | ||
$v=~s/^\s//; | ||
$v=~s/\s$//; | ||
$v=~s/\s{2,}/ /g; | ||
} | ||
if (! -e $curPath.'/parent') { last; } | ||
$parent=$self->getFileContents($curPath.'/parent'); | ||
chomp($parent); | ||
$curPath.='/'.$parent; | ||
|
||
$importer->restore_env(); | ||
} | ||
|
||
$buffer.=$self->getFileContents('/etc/make.conf').$self->getFileContents('/etc/make.globals'); | ||
foreach(@files) { | ||
$buffer.=$self->getFileContents($_); | ||
# - Defaults > | ||
if ($param eq 'PORTDIR' && !$v) { | ||
$v='/usr/portage'; | ||
} | ||
|
||
return $self->getParamFromFile($buffer,'ARCH','firstseen'); | ||
return $v; | ||
} | ||
|
||
# Description: | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ package PortageXS::Useflags; | |
# | ||
# author : Christian Hartmann <[email protected]> | ||
# license : GPL-2 | ||
# header : $Header: /srv/cvsroot/portagexs/trunk/lib/PortageXS/Useflags.pm,v 1.6 2007/04/19 09:05:16 ian Exp $ | ||
# header : $Header: /srv/cvsroot/portagexs/trunk/lib/PortageXS/Useflags.pm,v 1.7 2008/12/01 20:30:23 ian Exp $ | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# | ||
|
@@ -25,6 +25,7 @@ our @EXPORT = qw( | |
getUsedescs | ||
sortUseflags | ||
getUsemasksFromProfile | ||
getUsemasksFromProfileHelper | ||
); | ||
|
||
# Description: | ||
|
@@ -110,6 +111,28 @@ sub sortUseflags { | |
return sort(@use1),sort(@use2); | ||
} | ||
|
||
# Description: | ||
# Helper for getUsemasksFromProfile() | ||
sub getUsemasksFromProfileHelper { | ||
my $self = shift; | ||
my $curPath = shift; | ||
my @files = (); | ||
my $parent = ''; | ||
|
||
if (-e $curPath.'/use.mask') { | ||
push(@files,$curPath.'/use.mask'); | ||
} | ||
if (! -e $curPath.'/parent') { | ||
return @files; | ||
} | ||
$parent=$self->getFileContents($curPath.'/parent'); | ||
foreach (split(/\n/,$parent)) { | ||
push(@files,$self->getUsemasksFromProfileHelper($curPath.'/'.$_)); | ||
} | ||
|
||
return @files; | ||
} | ||
|
||
# Description: | ||
# Returnvalue is an array containing all masked useflags set in the system-profile. | ||
# | ||
|
@@ -135,15 +158,17 @@ sub getUsemasksFromProfile { | |
$curPath=$self->getProfilePath(); | ||
} | ||
|
||
while(1) { | ||
if (-e $curPath.'/use.mask') { | ||
push(@files,$curPath.'/use.mask'); | ||
} | ||
if (! -e $curPath.'/parent') { last; } | ||
$parent=$self->getFileContents($curPath.'/parent'); | ||
chomp($parent); | ||
$curPath.='/'.$parent; | ||
} | ||
# while(1) { | ||
# print "-->".$curPath."<--\n"; | ||
# if (-e $curPath.'/use.mask') { | ||
# push(@files,$curPath.'/use.mask'); | ||
# } | ||
# if (! -e $curPath.'/parent') { last; } | ||
# $parent=$self->getFileContents($curPath.'/parent'); | ||
# chomp($parent); | ||
# $curPath.='/'.$parent; | ||
# } | ||
@files = $self->getUsemasksFromProfileHelper($curPath); | ||
|
||
$buffer.=$self->getFileContents($self->{'PORTDIR'}.'/profiles/base/use.mask')."\n"; | ||
foreach(reverse(@files)) { | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
|
||
use lib '../..'; | ||
use PortageXS; | ||
|
||
my $pxs=PortageXS->new(); | ||
print "Arch: ".$pxs->getPortageMakeParam('ARCH')."\n"; |