|
@@ -159,6 +159,7 @@ my %update_method = (
|
|
|
'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
|
|
'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
|
|
|
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
|
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
|
|
'update' => "git pull --ff-only",
|
|
'update' => "git pull --ff-only",
|
|
|
|
|
+ 'update_rebase' => "git pull --rebase=merges",
|
|
|
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
|
|
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
|
|
|
'post_update' => "git submodule update --init --recursive",
|
|
'post_update' => "git submodule update --init --recursive",
|
|
|
'controldir' => ".git",
|
|
'controldir' => ".git",
|
|
@@ -168,6 +169,7 @@ my %update_method = (
|
|
|
'init_branch' => "git clone --branch '%s' '%s' '%s'",
|
|
'init_branch' => "git clone --branch '%s' '%s' '%s'",
|
|
|
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
|
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
|
|
'update' => "git pull --ff-only",
|
|
'update' => "git pull --ff-only",
|
|
|
|
|
+ 'update_rebase' => "git pull --rebase=merges",
|
|
|
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
|
|
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
|
|
|
'post_update' => "git submodule update --init --recursive",
|
|
'post_update' => "git submodule update --init --recursive",
|
|
|
'controldir' => ".git",
|
|
'controldir' => ".git",
|
|
@@ -194,12 +196,13 @@ my %update_method = (
|
|
|
# src-git: pull broken
|
|
# src-git: pull broken
|
|
|
# src-cpy: broken if `basename $src` != $name
|
|
# src-cpy: broken if `basename $src` != $name
|
|
|
|
|
|
|
|
-sub update_feed_via($$$$$) {
|
|
|
|
|
|
|
+sub update_feed_via($$$$$$) {
|
|
|
my $type = shift;
|
|
my $type = shift;
|
|
|
my $name = shift;
|
|
my $name = shift;
|
|
|
my $src = shift;
|
|
my $src = shift;
|
|
|
my $relocate = shift;
|
|
my $relocate = shift;
|
|
|
my $force = shift;
|
|
my $force = shift;
|
|
|
|
|
+ my $rebase = shift;
|
|
|
|
|
|
|
|
my $m = $update_method{$type};
|
|
my $m = $update_method{$type};
|
|
|
my $localpath = "./feeds/$name";
|
|
my $localpath = "./feeds/$name";
|
|
@@ -224,6 +227,9 @@ sub update_feed_via($$$$$) {
|
|
|
if ($force && exists $m->{'update_force'}) {
|
|
if ($force && exists $m->{'update_force'}) {
|
|
|
$update_cmd = $m->{'update_force'};
|
|
$update_cmd = $m->{'update_force'};
|
|
|
}
|
|
}
|
|
|
|
|
+ if ($rebase && exists $m->{'update_rebase'}) {
|
|
|
|
|
+ $update_cmd = $m->{'update_rebase'};
|
|
|
|
|
+ }
|
|
|
system("cd '$safepath'; $update_cmd") == 0 or return 1;
|
|
system("cd '$safepath'; $update_cmd") == 0 or return 1;
|
|
|
}
|
|
}
|
|
|
if ($m->{'post_update'}) {
|
|
if ($m->{'post_update'}) {
|
|
@@ -776,12 +782,13 @@ sub uninstall {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-sub update_feed($$$$)
|
|
|
|
|
|
|
+sub update_feed($$$$$)
|
|
|
{
|
|
{
|
|
|
my $type=shift;
|
|
my $type=shift;
|
|
|
my $name=shift;
|
|
my $name=shift;
|
|
|
my $src=shift;
|
|
my $src=shift;
|
|
|
my $force_update=shift;
|
|
my $force_update=shift;
|
|
|
|
|
+ my $rebase_update=shift;
|
|
|
my $force_relocate=update_location( $name, "@$src" );
|
|
my $force_relocate=update_location( $name, "@$src" );
|
|
|
my $rv=0;
|
|
my $rv=0;
|
|
|
|
|
|
|
@@ -796,7 +803,7 @@ sub update_feed($$$$)
|
|
|
my $failed = 1;
|
|
my $failed = 1;
|
|
|
foreach my $feedsrc (@$src) {
|
|
foreach my $feedsrc (@$src) {
|
|
|
warn "Updating feed '$name' from '$feedsrc' ...\n";
|
|
warn "Updating feed '$name' from '$feedsrc' ...\n";
|
|
|
- if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update) != 0) {
|
|
|
|
|
|
|
+ if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update, $rebase_update) != 0) {
|
|
|
if ($force_update) {
|
|
if ($force_update) {
|
|
|
$rv=1;
|
|
$rv=1;
|
|
|
$failed=0;
|
|
$failed=0;
|
|
@@ -822,7 +829,7 @@ sub update {
|
|
|
$ENV{SCAN_COOKIE} = $$;
|
|
$ENV{SCAN_COOKIE} = $$;
|
|
|
$ENV{OPENWRT_VERBOSE} = 's';
|
|
$ENV{OPENWRT_VERBOSE} = 's';
|
|
|
|
|
|
|
|
- getopts('ahif', \%opts);
|
|
|
|
|
|
|
+ getopts('ahifr', \%opts);
|
|
|
%argv_feeds = map { $_ => 1 } @ARGV;
|
|
%argv_feeds = map { $_ => 1 } @ARGV;
|
|
|
|
|
|
|
|
if ($opts{h}) {
|
|
if ($opts{h}) {
|
|
@@ -830,6 +837,11 @@ sub update {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if ($opts{f} && $opts{r}) {
|
|
|
|
|
+ warn "Force and rebase are incompatible update options.\n";;
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
-d "feeds" or do {
|
|
-d "feeds" or do {
|
|
|
mkdir "feeds" or die "Unable to create the feeds directory";
|
|
mkdir "feeds" or die "Unable to create the feeds directory";
|
|
|
};
|
|
};
|
|
@@ -839,7 +851,7 @@ sub update {
|
|
|
my ($type, $name, $src) = @$feed;
|
|
my ($type, $name, $src) = @$feed;
|
|
|
next unless $#ARGV == -1 or $opts{a} or $argv_feeds{$name};
|
|
next unless $#ARGV == -1 or $opts{a} or $argv_feeds{$name};
|
|
|
if (not $opts{i}) {
|
|
if (not $opts{i}) {
|
|
|
- update_feed($type, $name, $src, $opts{f}) == 0 or $failed=1;
|
|
|
|
|
|
|
+ update_feed($type, $name, $src, $opts{f}, $opts{r}) == 0 or $failed=1;
|
|
|
}
|
|
}
|
|
|
push @index_feeds, $name;
|
|
push @index_feeds, $name;
|
|
|
}
|
|
}
|
|
@@ -904,6 +916,7 @@ Commands:
|
|
|
update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
|
|
update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
|
|
|
Options:
|
|
Options:
|
|
|
-a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
|
|
-a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
|
|
|
|
|
+ -r : Update by rebase. (git only. Useful if local commits exist)
|
|
|
-i : Recreate the index only. No feed update from repository is performed.
|
|
-i : Recreate the index only. No feed update from repository is performed.
|
|
|
-f : Force updating feeds even if there are changed, uncommitted files.
|
|
-f : Force updating feeds even if there are changed, uncommitted files.
|
|
|
|
|
|