From b00a59c0b953bf7688fc60a976bac74194886a0c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 20 Mar 2022 11:45:31 +0100 Subject: dselect: Add https support Recognize the method and update the documentation and prompts. --- dselect/setup | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'dselect/setup') diff --git a/dselect/setup b/dselect/setup index 522362e68..6b816ccfe 100755 --- a/dselect/setup +++ b/dselect/setup @@ -29,7 +29,7 @@ my $boldon=`setterm -bold on`; my $boldoff=`setterm -bold off`; my @known_types = ('deb'); -my @known_access = ('http', 'ftp', 'file'); +my @known_access = ('https', 'http', 'ftp', 'file'); my @typical_distributions = ('stable', 'unstable', 'testing'); my @typical_components = ('main', 'contrib', 'non-free', 'non-free-firmware'); @@ -118,7 +118,7 @@ sub get_source { } $type = 'deb'; - $urn = "http://deb.debian.org/debian" unless $urn; + $urn = "https://deb.debian.org/debian" unless $urn; $distribution = "stable" unless $distribution; $components = "main contrib non-free non-free-firmware" unless $components; @@ -232,6 +232,7 @@ sub get_sources { print " For example:\n"; print " file:/mnt/debian,\n"; print " ftp://ftp.example.org/debian,\n"; + print " https://deb.debian.org/debian,\n"; print " http://deb.debian.org/debian,\n"; # print " and the special mirror scheme,\n"; # print " mirror:http://www.debian.org/archivemirrors \n"; -- cgit v1.2.3-70-g09d2 From 45466eb7dff31b60b834bbc8b78d0b0bf562bba3 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 20 Mar 2022 12:00:22 +0100 Subject: dselect: Refactor bold printing into its own function --- dselect/setup | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'dselect/setup') diff --git a/dselect/setup b/dselect/setup index 6b816ccfe..ba1a4ca33 100755 --- a/dselect/setup +++ b/dselect/setup @@ -36,6 +36,12 @@ my @typical_components = ('main', 'contrib', 'non-free', 'non-free-firmware') my %known_access = map {($_,$_)} @known_access; my %typical_distributions = map {($_,$_)} @typical_distributions; +sub print_bold { + my $msg = shift; + + print "$boldon$msg$boldoff"; +} + # Read the config file, creating source records sub read_config { my %params = @_; @@ -130,7 +136,7 @@ sub get_source { while (!$done) { print "\n"; - print "$boldon URL [$urn]: $boldoff"; + print_bold(" URL [$urn]: "); $answer=; chomp ($answer); @@ -159,10 +165,10 @@ sub get_source { print " Please give the distribution tag to get or a path to the\n"; print " package file ending in a /. The distribution\n"; - print " tags are typically something like:$boldon "; - print join(' ', @typical_distributions), "$boldoff\n"; + print " tags are typically something like: "; + print_bold(join(' ', @typical_distributions) . "\n"); print "\n"; - print "$boldon Distribution [$distribution]:$boldoff "; + print_bold(" Distribution [$distribution]: "); $answer=; chomp ($answer); $answer =~ s/\s*//og; @@ -193,10 +199,10 @@ sub get_components { print "\n"; print " Please give the components to get\n"; - print " The components are typically something like:$boldon "; - print join(' ', @typical_components), "$boldoff\n"; + print " The components are typically something like: "; + print_bold(join(' ', @typical_components) . "\n"); print "\n"; - print "$boldon Components [$default]:$boldoff "; + print_bold(" Components [$default]: "); $answer=; chomp ($answer); $answer =~ s/\s+/ /og; @@ -219,12 +225,12 @@ sub get_sources { @Oldconfig = &read_config('Filename' => $config_file) } - print "\t$boldon Set up a list of distribution source locations $boldoff \n"; + print_bold("\t Set up a list of distribution source locations\n"); print "\n"; print " Please give the base URL of the debian distribution.\n"; - print " The access schemes I know about are:$boldon "; - print join (' ', @known_access), "$boldoff\n"; + print " The access schemes I know about are: "; + print_bold(join (' ', @known_access) . "\n"); # print " The mirror scheme is special that it does not specify the\n"; # print " location of a debian archive but specifies the location\n"; # print " of a list of mirrors to use to access the archive.\n"; @@ -247,7 +253,7 @@ sub get_sources { push (@Config, &get_source()); } print "\n"; - print "$boldon Would you like to add another source?[y/N]$boldoff "; + print_bold(" Would you like to add another source? [y/N] "); my $answer = ; chomp ($answer); $answer =~ s/\s+/ /og; @@ -266,11 +272,11 @@ sub main { if (-e $config_file) { my @Oldconfig = &read_config('Filename' => $config_file); - print "$boldon I see you already have a source list.$boldoff\n"; + print_bold(" I see you already have a source list.\n"); print "-" x 72, "\n"; &print_config('Config' => \@Oldconfig); print "-" x 72, "\n"; - print "$boldon Do you wish to overwrite it? [y/N]$boldoff "; + print_bold(" Do you wish to overwrite it? [y/N] "); my $answer = ; chomp ($answer); $answer =~ s/\s+/ /og; -- cgit v1.2.3-70-g09d2 From d8f4038b45507620f7696fecd8527345f1f384db Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 20 Mar 2022 12:03:44 +0100 Subject: dselect: Use strict and warnings pragmas Move the warnings from the shebang into a proper pragma, so that we are sure it will be enabled regardless of the script being called explicitly without the flag. --- dselect/setup | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'dselect/setup') diff --git a/dselect/setup b/dselect/setup index ba1a4ca33..ac910d1c1 100755 --- a/dselect/setup +++ b/dselect/setup @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # -*- Mode: Perl -*- # setup.pl --- # Author : Manoj Srivastava ( srivasta@tiamat.datasync.com ) @@ -14,7 +14,8 @@ # This file is designed to go into /usr/lib/apt/methods/setup # -#use strict; +use strict; +use warnings; #use diagnostics; #printf STDERR "DEBUG: Arguments $ARGV[0];$ARGV[1];$ARGV[2];\n"; -- cgit v1.2.3-70-g09d2 From 372d90ec8a395b77f2aec94174054021231e695d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 20 Mar 2022 12:06:50 +0100 Subject: dselect: Use Term::ANSIColor instead of forking setterm --- dselect/setup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'dselect/setup') diff --git a/dselect/setup b/dselect/setup index ac910d1c1..3d4bc6309 100755 --- a/dselect/setup +++ b/dselect/setup @@ -20,14 +20,16 @@ use warnings; #printf STDERR "DEBUG: Arguments $ARGV[0];$ARGV[1];$ARGV[2];\n"; +use Term::ANSIColor; + # Handle the arguments my $vardir=$ARGV[0]; my $method=$ARGV[1]; my $option=$ARGV[2]; my $config_file = '/etc/apt/sources.list'; -my $boldon=`setterm -bold on`; -my $boldoff=`setterm -bold off`; +my $boldon = color('bold'); +my $boldoff = color('reset'); my @known_types = ('deb'); my @known_access = ('https', 'http', 'ftp', 'file'); -- cgit v1.2.3-70-g09d2 From 6eb1c4cff637caad5713dd3fb569dc460b59a579 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 20 Mar 2022 12:08:35 +0100 Subject: dselect: Use qw() instead of lists of quoted strings --- dselect/setup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dselect/setup') diff --git a/dselect/setup b/dselect/setup index 3d4bc6309..cea4b9caf 100755 --- a/dselect/setup +++ b/dselect/setup @@ -31,10 +31,10 @@ my $config_file = '/etc/apt/sources.list'; my $boldon = color('bold'); my $boldoff = color('reset'); -my @known_types = ('deb'); -my @known_access = ('https', 'http', 'ftp', 'file'); -my @typical_distributions = ('stable', 'unstable', 'testing'); -my @typical_components = ('main', 'contrib', 'non-free', 'non-free-firmware'); +my @known_types = qw(deb); +my @known_access = qw(https http ftp file); +my @typical_distributions = qw(stable unstable testing); +my @typical_components = qw(main contrib non-free non-free-firmware); my %known_access = map {($_,$_)} @known_access; my %typical_distributions = map {($_,$_)} @typical_distributions; -- cgit v1.2.3-70-g09d2 From e17f8916fd32228009293087a6fdc6d8c9c9db9f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 20 Mar 2022 12:23:18 +0100 Subject: dselect: Replaces obsolete file comment header with copyright and SPDX marker The information in the header was probably mostly useful to the author, but even then, it seems it has long past its usefulness once it got integrated into apt proper. --- dselect/setup | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'dselect/setup') diff --git a/dselect/setup b/dselect/setup index cea4b9caf..aed7baa26 100755 --- a/dselect/setup +++ b/dselect/setup @@ -1,18 +1,7 @@ #!/usr/bin/perl -# -*- Mode: Perl -*- -# setup.pl --- -# Author : Manoj Srivastava ( srivasta@tiamat.datasync.com ) -# Created On : Wed Mar 4 15:11:47 1998 -# Created On Node : tiamat.datasync.com -# Last Modified By : Manoj Srivastava -# Last Modified On : Tue May 19 11:25:32 1998 -# Last Machine Used: tiamat.datasync.com -# Update Count : 87 -# Status : Unknown, Use with caution! -# HISTORY : -# Description : -# This file is designed to go into /usr/lib/apt/methods/setup -# +# Copyright (c) 1998 Manoj Srivastava +# +# SPDX-License-Identifier: GPL-2.0+ use strict; use warnings; -- cgit v1.2.3-70-g09d2