Author: blogic
Date: 2015-01-22 10:35:40 +0100 (Thu, 22 Jan 2015)
New Revision: 44076

Added:
   trunk/include/scan.awk
Modified:
   trunk/include/scan.mk
   trunk/scripts/feeds
Log:
build: allow openwrt.git packages to be replaced by feeds

Currently, replacing a package available in openwrt.git requires
modifications in openwrt.git, or requires duplicating the package in a
feed but with a different name, which causes all kind of problems
related to dependencies (all packages selecting it would have to be
modified accordingly to select the new package).

With this change, if a package with the same name is present both in
feeds/ and package/ folders, the one in feeds/ can override the one
in package/, both in the menuconfig and during the build, by passing the
"-f" option to "./scripts/feeds install"

This mechanism is particularly useful for vendor tree, or in general for
application which needs to replace one particular package which exists
within openwrt.git by a custom/newer version.

Signed-off-by: Mathieu Olivari <[email protected]>

Added: trunk/include/scan.awk
===================================================================
--- trunk/include/scan.awk                              (rev 0)
+++ trunk/include/scan.awk      2015-01-22 09:35:40 UTC (rev 44076)
@@ -0,0 +1,17 @@
+BEGIN { FS="/" }
+$1 ~ /^feeds/ { FEEDS[$NF]=$0 }
+$1 !~ /^feeds/ { PKGS[$NF]=$0 }
+END {
+       # Filter-out OpenWrt packages which have a feeds equivalent
+       for (pkg in PKGS)
+               if (pkg in FEEDS)
+                       delete PKGS[pkg]
+       n = asort(PKGS)
+       for (i=1; i <= n; i++) {
+               print PKGS[i]
+       }
+       n = asort(FEEDS)
+       for (i=1; i <= n; i++){
+               print FEEDS[i]
+       }
+}

Modified: trunk/include/scan.mk
===================================================================
--- trunk/include/scan.mk       2015-01-22 09:35:35 UTC (rev 44075)
+++ trunk/include/scan.mk       2015-01-22 09:35:40 UTC (rev 44076)
@@ -43,7 +43,7 @@
 
 $(FILELIST):
        rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
-       $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if 
$(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -HE 'call 
(Build/DefaultTargets|Build(Package|Target)|.+Package)' | sed -e 
's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq > $@
+       $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if 
$(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -HE 'call 
(Build/DefaultTargets|Build(Package|Target)|.+Package)' | sed -e 
's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq | awk -f include/scan.awk > $@
 
 $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
        ( \

Modified: trunk/scripts/feeds
===================================================================
--- trunk/scripts/feeds 2015-01-22 09:35:35 UTC (rev 44075)
+++ trunk/scripts/feeds 2015-01-22 09:35:40 UTC (rev 44076)
@@ -358,6 +358,7 @@
 sub install_package {
        my $feed = shift;
        my $name = shift;
+       my $force = shift;
        my $ret = 0;
 
        $feed = lookup_package($feed, $name);
@@ -383,14 +384,23 @@
        $src or $src = $name;
 
        # previously installed packages set the runtime package
-       # newly installed packages set the source package
-       $installed{$src} and return 0;
+       # newly installed packages set the source package to 1
+       $installed{$src} and $installed{$src} == 1 and return 0;
 
+       # we'll trigger the override only with the 3 conditions below:
+       # - override is allowed by command line (-f)
+       # - a package with the same src exists in the core packages list
+       # - the package previously installed is not from a feed
+       my $override = 1 if ($force and is_core_package($src) and 
!$installed{$src}->{feed});
+
        # check previously installed packages
-       $installed{$name} and return 0;
+       $installed{$name} and !$override and return 0;
        $installed{$src} = 1;
-       warn "Installing package '$src'\n";
 
+       $override == 1
+               and warn "Overriding package '$src'\n"
+               or warn "Installing package '$src'\n";
+
        $install_method{$type} or do {
                warn "Unknown installation method: '$type'\n";
                return 1;
@@ -436,7 +446,7 @@
        my $feed;
        my $ret = 0;
 
-       getopts('ap:d:h', \%opts);
+       getopts('ap:d:fh', \%opts);
 
        if ($opts{h}) {
                usage();
@@ -462,7 +472,7 @@
                                        my $p = $feed_package->{$name};
                                        next if $p->{vdepends};
                                        if( $p->{name} ) {
-                                               install_package($feed, 
$p->{name}) == 0 or $ret = 1;
+                                               install_package($feed, 
$p->{name}, exists($opts{f})) == 0 or $ret = 1;
                                                get_feed($f->[1]);
                                        }
                                }
@@ -470,7 +480,7 @@
                }
        } else {
                while ($name = shift @ARGV) {
-                       install_package($feed, $name) == 0 or $ret = 1;
+                       install_package($feed, $name, exists($opts{f})) == 0 or 
$ret = 1;
                }
        }
 
@@ -638,6 +648,7 @@
            -a :           Install all packages from all feeds or from the 
specified feed using the -p option.
            -p <feedname>: Prefer this feed when installing packages.
            -d <y|m|n>:    Set default for newly installed packages.
+           -f :           Install will be forced even if the package exists in 
core OpenWrt (override)
 
        search [options] <substring>: Search for a package
        Options:
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to