mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Merge branch 'master' of github.com:webmin/webmin
This commit is contained in:
125
makemoduledeb.pl
125
makemoduledeb.pl
@@ -25,14 +25,23 @@ my $changelog_file = "$debian_dir/changelog";
|
||||
my $files_file = "$debian_dir/files";
|
||||
|
||||
# Parse command-line args
|
||||
my ($force_theme, $url, $upstream, $provides, $debdepends, $debrecommends,
|
||||
my ($force_theme, $url, $upstream, $debdepends, $debrecommends,
|
||||
$no_prefix, $force_usermin, $release, $allow_overwrite, $final_mod,
|
||||
$dsc_file, $dir, $ver, @exclude);
|
||||
|
||||
while(@ARGV) {
|
||||
my $a = shift(@ARGV);
|
||||
if ($a eq "--force-theme") {
|
||||
$force_theme = 1;
|
||||
if ($a eq "--deb-depends") {
|
||||
$debdepends = 1;
|
||||
}
|
||||
elsif ($a eq "--deb-recommends") {
|
||||
$debrecommends = 1;
|
||||
}
|
||||
# --recommends, --suggests, --conflicts, --provides and --obsoletes are
|
||||
# not for Webmin modules, and not meant to have prefix, and populated
|
||||
# from module.info automatically
|
||||
elsif ($a eq "--no-prefix") {
|
||||
$no_prefix = 1;
|
||||
}
|
||||
elsif ($a eq "--licence" || $a eq "--license") {
|
||||
$licence = shift(@ARGV);
|
||||
@@ -46,17 +55,8 @@ while(@ARGV) {
|
||||
elsif ($a eq "--upstream") {
|
||||
$upstream = shift(@ARGV);
|
||||
}
|
||||
elsif ($a eq "--provides") {
|
||||
$provides = shift(@ARGV);
|
||||
}
|
||||
elsif ($a eq "--deb-depends") {
|
||||
$debdepends = 1;
|
||||
}
|
||||
elsif ($a eq "--deb-recommends") {
|
||||
$debrecommends = 1;
|
||||
}
|
||||
elsif ($a eq "--no-prefix") {
|
||||
$no_prefix = 1;
|
||||
elsif ($a eq "--release") {
|
||||
$release = shift(@ARGV);
|
||||
}
|
||||
elsif ($a eq "--usermin") {
|
||||
$force_usermin = 1;
|
||||
@@ -67,15 +67,15 @@ while(@ARGV) {
|
||||
elsif ($a eq "--dir") {
|
||||
$final_mod = shift(@ARGV);
|
||||
}
|
||||
elsif ($a eq "--release") {
|
||||
$release = shift(@ARGV);
|
||||
}
|
||||
elsif ($a eq "--allow-overwrite") {
|
||||
$allow_overwrite = 1;
|
||||
}
|
||||
elsif ($a eq "--dsc-file") {
|
||||
$dsc_file = shift(@ARGV);
|
||||
}
|
||||
elsif ($a eq "--force-theme") {
|
||||
$force_theme = 1;
|
||||
}
|
||||
elsif ($a eq "--exclude") {
|
||||
push(@exclude, shift(@ARGV));
|
||||
}
|
||||
@@ -96,20 +96,24 @@ while(@ARGV) {
|
||||
# Validate args
|
||||
if (!$dir) {
|
||||
print "usage: ", CYAN, "makemoduledeb.pl ";
|
||||
print YELLOW, "[--force-theme]\n";
|
||||
print CYAN, "<module> [version]";
|
||||
print YELLOW, "\n";
|
||||
print " [--deb-depends]\n";
|
||||
print " [--deb-recommends]\n";
|
||||
print " [--no-prefix]\n";
|
||||
print " [--licence name]\n";
|
||||
print " [--email 'name <address>']\n";
|
||||
print " [--url url]\n";
|
||||
print " [--upstream 'name <address>']\n";
|
||||
print " [--provides 'name1 name2']\n";
|
||||
print " [--release version]\n";
|
||||
print " [--usermin]\n";
|
||||
print " [--target-dir directory]\n";
|
||||
print " [--dir directory-in-package]\n";
|
||||
print " [--allow-overwrite]\n";
|
||||
print " [--dsc-file file.dsc]\n";
|
||||
print CYAN, " <module> ";
|
||||
print YELLOW, "[version]\n", RESET;
|
||||
print " [--force-theme]\n";
|
||||
print " [--exclude file-or-dir]\n";
|
||||
print RESET, "\n";
|
||||
exit(1);
|
||||
}
|
||||
chop(my $par = `dirname $dir`);
|
||||
@@ -258,20 +262,74 @@ if ($debdepends && exists($minfo{'depends'})) {
|
||||
}
|
||||
my $rdeps = join(", ", @rdeps);
|
||||
|
||||
# Recommends: header
|
||||
# Build list of recommended packages on other DEBs, for inclusion as an DEB
|
||||
# Recommends: header (Webmin module with prefixes)
|
||||
my $rrecom = "";
|
||||
if ($debrecommends && defined($minfo{'recommends'})) {
|
||||
my @rrecom;
|
||||
foreach my $d (split(/\s+/, $minfo{'recommends'})) {
|
||||
push(@rrecom, $prefix.$d);
|
||||
}
|
||||
$rrecom = join(", ", @rrecom);
|
||||
}
|
||||
|
||||
# Build (append) list of required packages (not Webmin modules)
|
||||
my @rrequires = ( );
|
||||
if (exists($minfo{'deb_requires'})) {
|
||||
foreach my $debrequire (split(/\s+/, $minfo{'deb_requires'})) {
|
||||
push(@rrequires, $debrequire);
|
||||
}
|
||||
$rdeps .= ", " . join(", ", @rrequires) if (@rrequires);
|
||||
}
|
||||
|
||||
# Build (append) list of recommended packages (not Webmin modules)
|
||||
my @rrecommends = ( );
|
||||
if ($debrecommends && exists($minfo{'recommends'})) {
|
||||
foreach my $debrecommend (split(/\s+/, $minfo{'recommends'})) {
|
||||
if (exists($minfo{'deb_recommends'})) {
|
||||
foreach my $debrecommend (split(/\s+/, $minfo{'deb_recommends'})) {
|
||||
push(@rrecommends, $debrecommend);
|
||||
}
|
||||
$rrecom .= ", " . join(", ", @rrecommends) if (@rrecommends);
|
||||
}
|
||||
|
||||
# Build (standalone) list of suggested packages (not Webmin modules)
|
||||
my @rsuggests = ( );
|
||||
if (exists($minfo{'deb_suggests'})) {
|
||||
foreach my $debsuggest (split(/\s+/, $minfo{'deb_suggests'})) {
|
||||
push(@rsuggests, $debsuggest);
|
||||
}
|
||||
}
|
||||
|
||||
# If module has 'provides', consider it too
|
||||
$provides .= ($provides ? " " : "") . "$prefix$mod";
|
||||
$provides .= ($provides ? " " : "") . $minfo{'provides'}
|
||||
if (exists($minfo{'provides'}));
|
||||
my @provides = split(/\s+/, $provides);
|
||||
$provides = join(", ", @provides);
|
||||
# Build (standalone) list of conflicts (not Webmin modules)
|
||||
my @rconflicts = ( );
|
||||
if (exists($minfo{'deb_conflicts'})) {
|
||||
foreach my $debconflict (split(/\s+/, $minfo{'deb_conflicts'})) {
|
||||
push(@rconflicts, $debconflict);
|
||||
}
|
||||
}
|
||||
|
||||
# Build (standalone) list of replaces (not Webmin modules)
|
||||
my @rreplaces = ( );
|
||||
if (exists($minfo{'deb_replaces'})) {
|
||||
foreach my $debreplace (split(/\s+/, $minfo{'deb_replaces'})) {
|
||||
push(@rreplaces, $debreplace);
|
||||
}
|
||||
}
|
||||
|
||||
# Build (standalone) list of obsoletes (replaces+conflicts) (not Webmin modules)
|
||||
if (exists($minfo{'deb_obsoletes'})) {
|
||||
foreach my $debobsolete (split(/\s+/, $minfo{'deb_obsoletes'})) {
|
||||
push(@rconflicts, $debobsolete);
|
||||
push(@rreplaces, $debobsolete);
|
||||
}
|
||||
}
|
||||
|
||||
# Build (standalone) list of provides (not Webmin modules)
|
||||
my @rprovides = ( );
|
||||
if (exists($minfo{'deb_provides'})) {
|
||||
foreach my $debprovide (split(/\s+/, $minfo{'deb_provides'})) {
|
||||
push(@rprovides, $debprovide);
|
||||
}
|
||||
}
|
||||
|
||||
# Create the control file
|
||||
my $kbsize = int(($size-1) / 1024)+1;
|
||||
@@ -285,12 +343,15 @@ Architecture: all
|
||||
Essential: no
|
||||
Depends: $rdeps
|
||||
EOF
|
||||
print $CONTROL "Recommends: ", join(", ", @rrecommends), "\n" if (@rrecommends);
|
||||
print $CONTROL "Recommends: $rrecom\n" if ($rrecom);
|
||||
print $CONTROL "Suggests: ", join(", ", @rsuggests), "\n" if (@rsuggests);
|
||||
print $CONTROL "Conflicts: ", join(", ", @rconflicts), "\n" if (@rconflicts);
|
||||
print $CONTROL "Replaces: ", join(", ", @rreplaces), "\n" if (@rreplaces);
|
||||
print $CONTROL "Provides: ", join(", ", @rprovides), "\n" if (@rprovides);
|
||||
print $CONTROL <<EOF;
|
||||
Pre-Depends: bash, perl
|
||||
Installed-Size: $kbsize
|
||||
Maintainer: $email
|
||||
Provides: $provides
|
||||
Description: $desc
|
||||
EOF
|
||||
close($CONTROL);
|
||||
|
||||
136
makemodulerpm.pl
136
makemodulerpm.pl
@@ -33,42 +33,27 @@ $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin";
|
||||
my $allow_overwrite = 0;
|
||||
|
||||
my ($force_theme, $rpmdepends, $rpmrecommends, $no_prefix, $set_prefix, $vendor,
|
||||
$provides, $obsoletes, $url, $force_usermin, $final_mod, $sign, $keyname,
|
||||
$epoch, $dir, $ver, @extrareqs, @exclude);
|
||||
$url, $force_usermin, $final_mod, $sign, $keyname,
|
||||
$epoch, $dir, $ver, @exclude);
|
||||
|
||||
# Parse command-line args
|
||||
while(@ARGV) {
|
||||
# XXX Untainting isn't needed when running as non-root?
|
||||
my $a = &untaint(shift(@ARGV));
|
||||
if ($a eq "--force-theme") {
|
||||
$force_theme = 1;
|
||||
}
|
||||
elsif ($a eq "--rpm-dir") {
|
||||
$basedir = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--licence" || $a eq "--license") {
|
||||
$licence = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--rpm-depends") {
|
||||
if ($a eq "--rpm-depends") {
|
||||
$rpmdepends = 1;
|
||||
}
|
||||
elsif ($a eq "--rpm-recommends") {
|
||||
$rpmrecommends = 1;
|
||||
}
|
||||
# --recommends, --suggests, --conflicts, --provides and --obsoletes are
|
||||
# not for Webmin modules, and not meant to have prefix, and populated
|
||||
# from module.info automatically
|
||||
elsif ($a eq "--no-prefix") {
|
||||
$no_prefix = 1;
|
||||
}
|
||||
elsif ($a eq "--prefix") {
|
||||
$set_prefix = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--vendor") {
|
||||
$vendor = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--provides") {
|
||||
$provides = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--obsoletes") {
|
||||
$obsoletes = &untaint(shift(@ARGV));
|
||||
elsif ($a eq "--licence" || $a eq "--license") {
|
||||
$licence = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--url") {
|
||||
$url = shift(@ARGV);
|
||||
@@ -85,12 +70,21 @@ while(@ARGV) {
|
||||
elsif ($a eq "--dir") {
|
||||
$final_mod = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--requires") {
|
||||
push(@extrareqs, shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--allow-overwrite") {
|
||||
$allow_overwrite = 1;
|
||||
}
|
||||
elsif ($a eq "--force-theme") {
|
||||
$force_theme = 1;
|
||||
}
|
||||
elsif ($a eq "--rpm-dir") {
|
||||
$basedir = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--prefix") {
|
||||
$set_prefix = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--vendor") {
|
||||
$vendor = &untaint(shift(@ARGV));
|
||||
}
|
||||
elsif ($a eq "--sign") {
|
||||
$sign = 1;
|
||||
}
|
||||
@@ -120,24 +114,27 @@ while(@ARGV) {
|
||||
# Validate args
|
||||
if (!$dir) {
|
||||
print "usage: ";
|
||||
print CYAN, "makemodulerpm.pl ";
|
||||
print YELLOW, "[--force-theme]\n";
|
||||
print " [--rpm-dir directory]\n";
|
||||
print CYAN, "makemodulerpm.pl <module> [version]", RESET;
|
||||
print YELLOW, "\n";
|
||||
print " [--rpm-depends]\n";
|
||||
print " [--rpm-recommends]\n";
|
||||
print " [--rpm-dir directory]\n";
|
||||
print " [--no-prefix]\n";
|
||||
print " [--prefix prefix]\n";
|
||||
print " [--vendor name]\n";
|
||||
print " [--licence name]\n";
|
||||
print " [--url url]\n";
|
||||
print " [--provides provides]\n";
|
||||
print " [--usermin]\n";
|
||||
print " [--release number]\n";
|
||||
print " [--epoch number]\n";
|
||||
print " [--target-dir directory]\n";
|
||||
print " [--dir directory-in-package]\n";
|
||||
print " [--allow-overwrite]\n";
|
||||
print CYAN, " <module> ";
|
||||
print YELLOW, "[version]\n", RESET;
|
||||
print " [--force-theme]\n";
|
||||
print " [--sign]\n";
|
||||
print " [--key keyname]\n";
|
||||
print " [--exclude file]\n";
|
||||
print RESET, "\n";
|
||||
exit(1);
|
||||
}
|
||||
my $par;
|
||||
@@ -244,7 +241,7 @@ system("/bin/rm -rf /tmp/makemodulerpm");
|
||||
|
||||
# Build list of dependencies on other RPMs, for inclusion as an RPM
|
||||
# Requires: header
|
||||
my $rdeps;
|
||||
my $rdeps = "";
|
||||
if ($rpmdepends && defined($minfo{'depends'})) {
|
||||
my @rdeps;
|
||||
foreach my $d (split(/\s+/, $minfo{'depends'})) {
|
||||
@@ -283,24 +280,71 @@ if ($rpmdepends && defined($minfo{'depends'})) {
|
||||
$dver ? ($prefix.$dmod, ">=", $dver) :
|
||||
($prefix.$dmod));
|
||||
}
|
||||
$rdeps = join(" ", @rdeps, @extrareqs);
|
||||
$rdeps = join(" ", @rdeps);
|
||||
}
|
||||
|
||||
# Build list of recommended packages
|
||||
# Build list of recommended packages on other RPMs, for inclusion as an RPM
|
||||
# Recommends: header (Webmin module with prefixes)
|
||||
my $rrecom = "";
|
||||
if ($rpmrecommends && defined($minfo{'recommends'})) {
|
||||
my @rrecom;
|
||||
foreach my $d (split(/\s+/, $minfo{'recommends'})) {
|
||||
push(@rrecom, $prefix.$d);
|
||||
}
|
||||
$rrecom = join(" ", @rrecom);
|
||||
}
|
||||
|
||||
# Build (append) list of required packages (not Webmin modules)
|
||||
my @rrequires = ( );
|
||||
if (exists($minfo{'rpm_requires'})) {
|
||||
foreach my $rpmrequire (split(/\s+/, $minfo{'rpm_requires'})) {
|
||||
push(@rrequires, $rpmrequire);
|
||||
}
|
||||
$rdeps .= " " . join(" ", @rrequires) if (@rrequires);
|
||||
}
|
||||
|
||||
# Build (append) list of recommended packages (not Webmin modules)
|
||||
my @rrecommends = ( );
|
||||
if ($rpmrecommends && exists($minfo{'recommends'})) {
|
||||
foreach my $rpmrecommend (split(/\s+/, $minfo{'recommends'})) {
|
||||
if (exists($minfo{'rpm_recommends'})) {
|
||||
foreach my $rpmrecommend (split(/\s+/, $minfo{'rpm_recommends'})) {
|
||||
push(@rrecommends, $rpmrecommend);
|
||||
}
|
||||
$rrecom .= " " . join(" ", @rrecommends) if (@rrecommends);
|
||||
}
|
||||
|
||||
# If module has 'provides', consider it too
|
||||
$provides .= ($provides ? " " : "") . $minfo{'provides'}
|
||||
if (exists($minfo{'provides'}));
|
||||
# Build (standalone) list of suggested packages (not Webmin modules)
|
||||
my @rsuggests = ( );
|
||||
if (exists($minfo{'rpm_suggests'})) {
|
||||
foreach my $rpmsuggest (split(/\s+/, $minfo{'rpm_suggests'})) {
|
||||
push(@rsuggests, $rpmsuggest);
|
||||
}
|
||||
}
|
||||
|
||||
# Build (standalone) list of conflicts (not Webmin modules)
|
||||
my @rconflicts = ( );
|
||||
if (exists($minfo{'rpm_conflicts'})) {
|
||||
foreach my $rpmconflict (split(/\s+/, $minfo{'rpm_conflicts'})) {
|
||||
push(@rconflicts, $rpmconflict);
|
||||
}
|
||||
}
|
||||
|
||||
# Build (standalone) list of provides (not Webmin modules)
|
||||
my @rprovides = ( );
|
||||
if (exists($minfo{'rpm_provides'})) {
|
||||
foreach my $rpmprovide (split(/\s+/, $minfo{'rpm_provides'})) {
|
||||
push(@rprovides, $rpmprovide);
|
||||
}
|
||||
}
|
||||
|
||||
# Build (standalone) list of obsoletes (not Webmin modules)
|
||||
my @robsoletes = ( );
|
||||
if (exists($minfo{'rpm_obsoletes'})) {
|
||||
foreach my $rpmobsolete (split(/\s+/, $minfo{'rpm_obsoletes'})) {
|
||||
push(@robsoletes, $rpmobsolete);
|
||||
}
|
||||
}
|
||||
|
||||
# Create the SPEC file
|
||||
my $providesheader = $provides ? "Provides: $provides" : "";
|
||||
my $obsoletesheader = $obsoletes ? "Obsoletes: $obsoletes" : "";
|
||||
my $vendorheader = $vendor ? "Vendor: $vendor" : "";
|
||||
my $urlheader = $url ? "URL: $url" : "";
|
||||
my $epochheader = $epoch ? "Epoch: $epoch" : "";
|
||||
@@ -318,7 +362,11 @@ Version: $ver
|
||||
Release: $release
|
||||
Requires: /bin/sh /usr/bin/perl /usr/libexec/$prog $rdeps
|
||||
EOF
|
||||
print $SPEC "Recommends: " . join(" ", @rrecommends) . "\n" if (@rrecommends);
|
||||
print $SPEC "Recommends: $rrecom\n" if ($rrecom);
|
||||
print $SPEC "Suggests: " . join(" ", @rsuggests) . "\n" if (@rsuggests);
|
||||
print $SPEC "Conflicts: " . join(" ", @rconflicts) . "\n" if (@rconflicts);
|
||||
print $SPEC "Provides: " . join(" ", @rprovides) . "\n" if (@rprovides);
|
||||
print $SPEC "Obsoletes: " . join(" ", @robsoletes) . "\n" if (@robsoletes);
|
||||
print $SPEC <<EOF;
|
||||
Autoreq: 0
|
||||
Autoprov: 0
|
||||
@@ -328,8 +376,6 @@ Source: $mod.tar.gz
|
||||
BuildRoot: /tmp/%{name}-%{version}
|
||||
BuildArchitectures: noarch
|
||||
$epochheader
|
||||
$providesheader
|
||||
$obsoletesheader
|
||||
$vendorheader
|
||||
$urlheader
|
||||
%description
|
||||
|
||||
@@ -68,8 +68,9 @@ my $lock_supported = &get_account_lock_support();
|
||||
# Old way for checking account locking
|
||||
my $locked = $u->[$fieldmap{'account_locked'}] eq 'Y';
|
||||
# New account locking check
|
||||
if (!exists($fieldmap{'account_locked'}) ||
|
||||
!defined($u->[$fieldmap{'account_locked'}])) {
|
||||
if (!$in{'new'} &&
|
||||
(!exists($fieldmap{'account_locked'}) ||
|
||||
!defined($u->[$fieldmap{'account_locked'}]))) {
|
||||
$locked = &get_account_lock_status($u->[1], $u->[0]);
|
||||
}
|
||||
print &ui_table_row($text{'user_pass'},
|
||||
|
||||
@@ -338,22 +338,43 @@ enforce_package_priority() {
|
||||
repo_pkg_pref=$1
|
||||
disttarget=$2
|
||||
|
||||
# Extract the relevant entries for the target distribution
|
||||
match=$(echo "$repo_pkg_pref" | grep -o "${disttarget}:[^ =]*[^ ]*")
|
||||
# Save and set IFS to newline only
|
||||
old_ifs=$IFS
|
||||
IFS='
|
||||
'
|
||||
|
||||
if [ -n "$match" ]; then
|
||||
# Extract the package name
|
||||
package=$(echo "$match" | sed -e "s/^${disttarget}:\([^=]*\).*/\1/")
|
||||
# Extract the priority and version parameters (if present)
|
||||
priority=$(echo "$match" | sed -n -e "s/^${disttarget}:[^=]*=\([^=]*\)=.*$/\1/p")
|
||||
version=$(echo "$match" | sed -n -e "s/^${disttarget}:[^=]*=[^=]*=\(.*\)$/\1/p")
|
||||
# Extract all entries for the target distribution
|
||||
for entry in $repo_pkg_pref; do
|
||||
case "$entry" in
|
||||
${disttarget}:*)
|
||||
# Extract the action and the rest of the entry
|
||||
action=${entry#"$disttarget:"}
|
||||
action=${action%%:*}
|
||||
entry=${entry#"$disttarget:$action:"}
|
||||
entry=$disttarget:$entry
|
||||
|
||||
# Output package, priority, and version parameters (empty if not present)
|
||||
echo "$package ${priority:-} ${version:-}"
|
||||
return 0
|
||||
# Remove the prefix
|
||||
spec="${entry#"${disttarget}":}"
|
||||
|
||||
# Parse package=priority=version format
|
||||
package="${spec%%=*}"
|
||||
remainder="${spec#*=}"
|
||||
|
||||
# Check if remainder is empty or just a package name
|
||||
if [ "$remainder" = "$spec" ]; then
|
||||
printf "%s\t%s %s %s\n" "${action:-}" "$package" "" ""
|
||||
else
|
||||
priority="${remainder%%=*}"
|
||||
version="${remainder#*=}"
|
||||
[ "$version" = "$remainder" ] && version=""
|
||||
printf "%s\t%s %s %s\n" "${action:-}" "$package" "${priority:-}" "${version:-}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
return 1
|
||||
# Restore IFS
|
||||
IFS=$old_ifs
|
||||
}
|
||||
|
||||
download_key() {
|
||||
@@ -392,16 +413,29 @@ setup_repos() {
|
||||
cp -f "$repo_key" \
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-$repo_key_suffix"
|
||||
echo " .. done"
|
||||
# Configure packages priority if provided
|
||||
# Configure packages extra preferences if given
|
||||
if [ -n "$repo_pkg_prefs" ]; then
|
||||
repo_pkg_prefs_rs=$(enforce_package_priority "$repo_pkg_prefs" "rpm")
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " Setting up package exclusion for repository .."
|
||||
package=$(echo "$repo_pkg_prefs_rs" | awk '{print $1}')
|
||||
repo_extra_opts="exclude=$package"
|
||||
echo " .. done"
|
||||
repo_extra_opts=$(printf '%s\n' "$repo_pkg_prefs_rs" | awk -F'\t' '
|
||||
function trim(s) {
|
||||
sub(/^[ \t]+/, "", s)
|
||||
sub(/[ \t]+$/, "", s)
|
||||
return s
|
||||
}
|
||||
{
|
||||
key = trim($1)
|
||||
val = trim($2)
|
||||
if (key in opts)
|
||||
opts[key] = opts[key] " " val
|
||||
else
|
||||
echo " Cleaning up package priority configuration .."
|
||||
opts[key] = val
|
||||
}
|
||||
END {
|
||||
for (k in opts)
|
||||
printf "%s=%s\n", k, trim(opts[k])
|
||||
}')
|
||||
if [ -n "$repo_pkg_prefs_rs" ]; then
|
||||
echo " Setting up package exclusion for repository .."
|
||||
echo " .. done"
|
||||
fi
|
||||
fi
|
||||
@@ -445,20 +479,41 @@ EOF
|
||||
# Configure packages priority if provided
|
||||
debian_repo_prefs="/etc/apt/preferences.d/$repoid_debian_like-$repo_dist-package-priority"
|
||||
if [ -n "$repo_pkg_prefs" ]; then
|
||||
repo_pkg_prefs_rs=$(enforce_package_priority "$repo_pkg_prefs" "deb")
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " Setting up package priority for repository .."
|
||||
package=$(echo "$repo_pkg_prefs_rs" | awk '{print $1}')
|
||||
priority=$(echo "$repo_pkg_prefs_rs" | awk '{print $2}')
|
||||
version=$(echo "$repo_pkg_prefs_rs" | awk '{print $3}')
|
||||
cat << EOF > "$debian_repo_prefs"
|
||||
Package: $package
|
||||
Pin: version /$version\$/
|
||||
Pin-Priority: $priority
|
||||
EOF
|
||||
echo " .. done"
|
||||
fi
|
||||
# Clear the file first
|
||||
: > "$debian_repo_prefs"
|
||||
|
||||
# Process all matching packages
|
||||
pkg_lines=$(enforce_package_priority "$repo_pkg_prefs" "deb")
|
||||
tab=$(printf '\t')
|
||||
while IFS="$tab" read -r action rest || [ -n "$action" ]; do
|
||||
[ -n "$action" ] || continue
|
||||
# shellcheck disable=SC2086
|
||||
IFS=' ' set -- $rest
|
||||
package=$1
|
||||
priority=$2
|
||||
version=$3
|
||||
[ -n "$package" ] || continue
|
||||
# Process the action
|
||||
case $action in
|
||||
# Set package priority
|
||||
pin)
|
||||
if [ -n "$version" ]; then
|
||||
pin_line="Pin: version /$version\$/"
|
||||
else
|
||||
pin_line="Pin: release *"
|
||||
fi
|
||||
cat >> "$debian_repo_prefs" <<EOF
|
||||
Package: $package
|
||||
$pin_line
|
||||
Pin-Priority: ${priority:-500}
|
||||
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
done <<EOF
|
||||
$pkg_lines
|
||||
EOF
|
||||
elif [ -f "$debian_repo_prefs" ]; then
|
||||
echo " Cleaning up package priority configuration .."
|
||||
rm -f "$debian_repo_prefs"
|
||||
echo " .. done"
|
||||
|
||||
Reference in New Issue
Block a user