summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2013-07-22 07:42:16 +0200
committerSven Eden <yamakuzure@gmx.net>2013-07-22 07:42:16 +0200
commit018d9cd1d6185511b539cd25f1473a567c62b952 (patch)
treebba0f232b09d860379daaa143139ba5856956187
parentAdded a "thank you" section to the documentation. (diff)
downloadufed-018d9cd1d6185511b539cd25f1473a567c62b952.tar.gz
ufed-018d9cd1d6185511b539cd25f1473a567c62b952.tar.bz2
ufed-018d9cd1d6185511b539cd25f1473a567c62b952.zip
Added parsing of files in a possible make.conf directory, skipping backup and temporary files. The last found file with a USE assignement is used to store changes.
-rw-r--r--COPYING10
-rw-r--r--Portage.pm75
-rw-r--r--ufed.pl.in20
3 files changed, 85 insertions, 20 deletions
diff --git a/COPYING b/COPYING
index 5b6e7c6..dcfa4c2 100644
--- a/COPYING
+++ b/COPYING
@@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
-
+
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
-
+
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
-
+
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
+
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
-
+
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
diff --git a/Portage.pm b/Portage.pm
index ecf39ca..a254695 100644
--- a/Portage.pm
+++ b/Portage.pm
@@ -1,11 +1,12 @@
package Portage;
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-src/ufed/Portage.pm,v 1.3 2005/11/13 00:28:17 truedfx Exp $
+# $Header: $
use strict;
use warnings;
+use Readonly;
BEGIN {
use Exporter ();
@@ -18,6 +19,9 @@ BEGIN {
# --- public members ---
+# Set this to 1 to get debugging output
+Readonly our $DEBUG => 1;
+
# $use_flags - hashref that represents the combined and
# consolidated data about all valid use flags
# Layout of $use_flags->{flag_name}:
@@ -43,6 +47,8 @@ BEGIN {
our $use_flags;
# $used_make_conf - path of the used make.conf
+# If PREFIX/etc/[portage/]make.conf is a directory, $used_make_conf
+# points to the file the last USE settings are found in.
our $used_make_conf = "";
# --- private members ---
@@ -83,6 +89,7 @@ my $_use_template = {
};
# --- public methods ---
+sub debugMsg;
# --- private methods ---
sub _add_flag;
@@ -159,6 +166,17 @@ INIT {
# --- public methods implementations ---
+# Write a given message to STDERR adding a newline at the end
+# This function does nothing unless $DEBUG is set to something
+# different than zero
+# Parameter 1: The message
+sub debugMsg
+{
+ my ($msg) = @_;
+ $DEBUG or return;
+ print STDERR "$msg\n";
+ return;
+}
# --- private methods implementations ---
@@ -251,8 +269,16 @@ sub _determine_eprefix {
sub _determine_make_conf
{
$used_make_conf = "${_EPREFIX}/etc/portage/make.conf";
- (! -r $used_make_conf)
- and $used_make_conf = "${_EPREFIX}/etc/make.conf";
+ (-r $used_make_conf)
+ or $used_make_conf = "${_EPREFIX}/etc/make.conf";
+
+ # If $used_make_conf points to a directory now,
+ # it is emptied so _read_make_conf will determine
+ # the later used value
+
+ ( -d $used_make_conf)
+ and $used_make_conf = "";
+
return;
}
@@ -615,11 +641,46 @@ sub _read_descriptions
# The last added profile directory, if it exists, is
# /etc/portage/profile to allow recognition of user
# overrides.
+# If either of the make.conf paths is a directory, all
+# files are read in alphanumerical order. The file
+# changes are written to will be the last file that
+# contains a USE assignement.
# No parameters accepted.
sub _read_make_conf {
- my %oldEnv = _read_sh("${_EPREFIX}/etc/make.conf");
- my %newEnv = _read_sh("${_EPREFIX}/etc/portage/make.conf");
- _merge (\%oldEnv, \%newEnv);
+ my ($stOldPath, $stNewPath) = ( "${_EPREFIX}/etc/make.conf",
+ "${_EPREFIX}/etc/portage/make.conf" );
+ my (%oldEnv, %newEnv) = ([], []);
+ my $lastUSEFile = "";
+
+ for my $confPath ($stOldPath, $stNewPath) {
+ if ( -d $confPath) {
+ for my $confFile (sort glob("$confPath/*")) {
+ # Skip backup and temporary files
+ $confFile =~ /(?:\.bak|~|\.old|\.tmp)$/
+ and next;
+
+ # Now read the file and merge its content
+ debugMsg("Reading $confFile");
+ %newEnv = _read_sh($confFile);
+ _merge (\%oldEnv, \%newEnv);
+ defined($newEnv{USE})
+ and $lastUSEFile = $confFile
+ and debugMsg(" -> USE flags found");
+ }
+ } else {
+ %newEnv = _read_sh($confPath);
+ _merge (\%oldEnv, \%newEnv);
+ $lastUSEFile = $confPath;
+ }
+ }
+
+ # If there is no used make.conf found, yet, save it:
+ if ( 0 == length($used_make_conf) ) {
+ $used_make_conf = $lastUSEFile;
+ $used_make_conf =~ /\/make\.conf$/
+ or print "Using $used_make_conf as USE flags file\n";
+ }
+ debugMsg("$used_make_conf will be used to store changes");
# Note the conf state of the read flags:
for my $flag ( keys %{$oldEnv{USE}}) {
diff --git a/ufed.pl.in b/ufed.pl.in
index 3bc048a..5f10a22 100644
--- a/ufed.pl.in
+++ b/ufed.pl.in
@@ -2,9 +2,9 @@
use strict;
use warnings;
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-src/ufed/ufed.pl,v 1.45 2005/10/18 11:14:33 truedfx Exp $
+# $
use lib qw{XX_perldir@};
use Portage;
@@ -133,13 +133,15 @@ sub flags_dialog {
my @flags = grep { $_ ne '--*' } do { local $/; split /\n/, <$fh> };
close $fh;
save_flags finalise @flags;
- } elsif($rc==1)
- { print "Cancelled, not saving changes.\n" }
+ } elsif($rc==1) {
+ print "Cancelled, not saving changes.\n";
+ }
exit $rc;
- } elsif(POSIX::WIFSIGNALED($?))
- { kill POSIX::WTERMSIG($?), $$ }
- else
- { exit 127 }
+ } elsif(POSIX::WIFSIGNALED($?)) {
+ kill (POSIX::WTERMSIG($?), $$);
+ } else {
+ exit 127;
+ }
return;
}
@@ -309,6 +311,8 @@ EOF
open my $makeconf, '>', $makeconf_name or die "Couldn't open $makeconf_name\n";
print $makeconf $_;
close $makeconf;
+ $makeconf_name =~ /\/make\.conf$/
+ or print "USE flags written to $makeconf_name\n";
}
return;