#!/usr/bin/perl use Getopt::Std; use FindBin; use Cwd; use lib "$FindBin::Bin"; use metadata; use warnings; use strict; use Cwd 'abs_path'; chdir "$FindBin::Bin/.."; $ENV{TOPDIR}=getcwd(); $ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'"; my $mk=`which gmake 2>/dev/null`; # select the right 'make' program chomp($mk); # trim trailing newline $mk or $mk = "make"; # default to 'make' # check version of make my @mkver = split /\s+/, `$mk -v`, 4; my $valid_mk = 1; $mkver[0] =~ /^GNU/ or $valid_mk = 0; $mkver[1] =~ /^Make/ or $valid_mk = 0; $mkver[2] >= "3.81" or $valid_mk = 0; $valid_mk or die "Unsupported version of make found: $mk\n"; my @feeds; my %build_packages; my %installed; my %feed_cache; my $feed_package = {}; my $feed_src = {}; sub parse_config() { my $line = 0; my %name; open FEEDS, "feeds.conf" or open FEEDS, "feeds.conf.default" or die "Unable to open feeds configuration"; while () { chomp; s/#.+$//; next unless /\S/; my @line = split /\s+/, $_, 3; my @src; $line++; my $valid = 1; $line[0] =~ /^src-\w+$/ or $valid = 0; $line[1] =~ /^\w+$/ or $valid = 0; @src = split /\s+/, $line[2]; $valid or die "Syntax error in feeds.conf, line: $line\n"; $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n"; $name{$line[1]} = 1; push @feeds, [$line[0], $line[1], \@src]; } close FEEDS; } sub update_location($$) { my $name = shift; my $url = shift; my $old_url; -d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1; if( open LOC, "< ./feeds/$name.tmp/location" ) { chomp($old_url = readline LOC); close LOC; } if( !$old_url || $old_url ne $url ) { if( open LOC, "> ./feeds/$name.tmp/location" ) { print LOC $url, "\n"; close LOC; } return $old_url ? 1 : 0; } return 0; } sub update_index($) { my $name = shift; -d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1; -d "./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1; system("$mk -s prepare-mk OPENWRT_BUILD= TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\""); system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\" SCAN_DEPS=\"$ENV{TOPDIR}/include/package*.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\""); system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index"); return 0; } my %update_method = ( 'src-svn' => { 'init' => "svn checkout '%s' '%s'", 'update' => "svn update", 'controldir' => ".svn", 'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"}, 'src-cpy' => { 'init' => "cp -Rf '%s' '%s'", 'update' => "", 'revision' => "echo -n 'local'"}, 'src-link' => { 'init' => "ln -s '%s' '%s'", 'update' => "", 'revision' => "echo -n 'local'"}, 'src-git' => { 'init' => "git clone --depth 1 '%s' '%s'", 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'", 'update' => "git pull", 'controldir' => ".git", 'revision' => "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"}, 'src-gitsvn' => { 'init' => "git svn clone -r HEAD '%s' '%s'", 'update' => "git svn rebase", 'controldir' => ".git", 'revision' => "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"}, 'src-bzr' => { 'init' => "bzr checkout --lightweight '%s' '%s'", 'update' => "bzr update", 'controldir' => ".bzr"}, 'src-hg' => { 'init' => "hg clone '%s' '%s'", 'update' => "hg pull --update", 'controldir' => ".hg"}, 'src-darcs' => { 'init' => "darcs get '%s' '%s'", 'update' => "darcs pull -a", 'controldir' => "_darcs"}, ); # src-git: pull broken # src-cpy: broken if `basename $src` != $name sub update_feed_via($$$$) { my $type = shift; my $name = shift; my $src = shift; my $relocate = shift; my $m = $update_method{$type}; my $localpath = "./feeds/$name"; my $safepath = $localpath; $safepath =~ s/'/'\\''/; my ($base, $branch) = split(/;/, $src, 2); if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) { system("rm -rf '$safepath'"); if ($m->{'init_branch'} and $branch) { system(sprintf($m->{'init_branch'}, $branch, $base, $safepath)) == 0 or return 1; } else { system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1; } } else { system("cd '$safepath'; $m->{'update'}") == 0 or return 1; } return 0; } sub get_feed($) { my $feed = shift; if (!defined($feed_cache{$feed})) { my $file = "./feeds/$feed.index"; clear_packages(); -f $file or do { print "Ignoring feed '$feed' - index missing\n"; return; }; parse_package_metadata($file) or return; $feed_cache{$feed} = [ { %package }, { %srcpackage } ]; } $feed_package = $feed_cache{$feed}->[0]; $feed_src = $feed_cache{$feed}->[1]; return $feed_cache{$feed}->[0]; } sub get_installed() { system("$mk -s prepare-tmpinfo OPENWRT_BUILD="); clear_packages(); parse_package_metadata("./tmp/.packageinfo"); %installed = %package; } sub search_feed { my $feed = shift; my @substr = @_; my $display; return unless @substr > 0; get_feed($feed); foreach my $name (sort { lc($a) cmp lc($b) } ke
#
# Copyright (C) 2006-2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=uboot-envtools
PKG_VERSION:=20081215
PKG_RELEASE:=2

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/u/uboot-envtools/

include $(INCLUDE_DIR)/package.mk

define Package/uboot-envtools
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=read/modify U-Boot bootloader environment
  DEPENDS:= @LINUX_2_6 +zlib
endef

define Package/uboot-envtools/description
 This package includes tools to read and modify U-Boot bootloader environment.
endef

define Package/uboot-envtools/install
	$(INSTALL_DIR) $(1)/usr/sbin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/fw_printenv $(1)/usr/sbin/
	ln -sf fw_printenv $(1)/usr/sbin/fw_setenv
endef

$(eval $(call BuildPackage,uboot-envtools))
mkdir "feeds" or die "Unable to create the feeds directory"; }; if ( ($#ARGV == -1) or $opts{a}) { foreach my $feed (@feeds) { my ($type, $name, $src) = @$feed; update_feed($type, $name, $src, $perform_update); } } else { while ($feed_name = shift @ARGV) { foreach my $feed (@feeds) { my ($type, $name, $src) = @$feed; if($feed_name ne $name) { next; } update_feed($type, $name, $src, $perform_update); } } } refresh_config(); return 0; } sub usage() { print < [options] Commands: list [options]: List feeds, their content and revisions (if installed) Options: -s : List of feed names and their URL. -r : List packages of specified feed. -d : Use specified delimiter to distinguish rows (default: spaces) install [options] : Install a package Options: -a : Install all packages from all feeds or from the specified feed using the -p option. -p : Prefer this feed when installing packages. -d : Set default for newly installed packages. search [options] : Search for a package Options: -r : Only search in this feed uninstall -a|: Uninstall a package Options: -a : Uninstalls all packages. update -a|: Update packages and lists of feeds in feeds.conf . Options: -a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated. -i : Recreate the index only. No feed update from repository is performed. clean: Remove downloaded/generated files. EOF exit(1); } my %commands = ( 'list' => \&list, 'update' => \&update, 'install' => \&install, 'search' => \&search, 'uninstall' => \&uninstall, 'clean' => sub { system("rm -rf feeds"); } ); my $arg = shift @ARGV; $arg or usage(); parse_config; foreach my $cmd (keys %commands) { $arg eq $cmd and do { exit(&{$commands{$cmd}}()); }; } usage();