Generate negative dependencies

Provide the updater with list of negative dependencies, based on the
packages' file collisions. We want to not fail when attempting to
install such packages, but want to solve it upfront.
parent 07a55a0e
......@@ -92,7 +92,7 @@ Package 'opkg-trans' { replan = true }
Install 'opkg-trans' 'updater-ng' { critical = true }
Install 'userlists' { critical = true }
-- Install everything that was in the image
-- Negative dependencies generated from file collisions
EOF
# Other lists
echo 'config pkglists pkglists' > package/feeds/turrispackages/opkg-trans/files/updater.config
......@@ -232,6 +232,10 @@ echo Install $(sed -n 's|Package: \(.*\)|"\1"|p' $OPKG_STATUS | egrep -v '"updat
[ \! -f "lists/base_add" ] || echo Install $(cat "lists/base_add.$TARGET_BOARD" | sed 's|^\([^#]\+\)$|"\1"|') " { critical = true }" >> base.lua
[ \! -f "lists/base_add.$TARGET_BOARD" ] || echo Install $(cat "lists/base_add.$TARGET_BOARD" | sed 's|^\([^#]\+\)$|"\1"|') " { critical = true }" >> base.lua
mv base.lua $PUB_BIN_DIR/lists
# Generate packages that block each other, based on their file collisions
# For some reason, mktemp -d doesn't work with TMPDIR set, so avoid that here.
TMPDIR= ./scripts/negative_deps.pl $PUB_BIN_DIR >>$PUB_BIN_DIR/lists/base.lua
echo '-- Install everything that was in the image' >>$PUB_BIN_DIR/lists/base.lua
for i in lists/*.list; do
LUA="$(basename $i .list).lua"
[ "$i" = lists/base.list ] || echo 'if features and features.provides then' > $PUB_BIN_DIR/lists/"$LUA"
......
#!/usr/bin/perl
# Copyright (C) 2017 CZ.NIC
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# This script scans all packages available in a provided directory and
# generates list of packages blocking each other, in the format of updater
# configuration.
use strict;
use warnings;
use Cwd qw(cwd);
use FindBin;
# First get list of all the packages we have
chdir $ARGV[0] if $ARGV[0];
open my $found, '-|', 'find', cwd, '-name', '*.ipk' or die "Can't read find: $!\n";
my @found_packages = <$found>;
close $found or die "Error reading from find: $!/$?\n";
chomp @found_packages;
# Assing an owner to each file (or multiple, if there are).
my %file_owners;
for my $package (@found_packages) {
# An external shell script analyses each package
open my $pkg_content, '-|', $FindBin::Bin . "/pkg-content.sh", $package or die "Can't get content of package $package: $!\n";
# The first line of the output is the package name
my $pkg_name = <$pkg_content>;
chomp $pkg_name;
for my $file (<$pkg_content>) {
chomp $file;
push @{$file_owners{$file}}, $pkg_name;
}
close $pkg_content or die "Error reading package content: $!/$?\n";
}
my %collisions;
for my $owners (values %file_owners) { # We don't care on *which* file the collision happens
for my $blocked (@$owners) {
for my $blocker (@$owners) {
if ($blocked ne $blocker) {
$collisions{$blocked}->{$blocker} = 1;
}
}
}
}
while (my ($blocked, $blockers) = each %collisions) {
print "Package '$blocked' { deps = {" . (join ', ', map "Not('$_')", keys %$blockers) . "} }\n";
}
#!/bin/sh
# Copyright (C) 2017 CZ.NIC
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# Get a name of a package in the given file and list its files.
set -e
WORKDIR="$(mktemp -d)"
trap 'cd / && rm -rf "$WORKDIR"' EXIT HUP INT QUIT ILL TRAP ABRT BUS FPE SEGV PIPE ALRM TERM
cd "$WORKDIR"
gzip -d <"$1" | tar x
gzip -d <control.tar.gz | tar x
sed -ne 's/^Package: //p' control
mkdir data
cd data
gzip -d <../data.tar.gz | tar x
find -type f
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment