Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37509629
en ru br
ALT Linux repos
S:1.4.3-alt1

Group :: System/Configuration/Packaging
RPM: apt-repo

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064122366511750014522gustar00rootroot0000000000000052 comment=a678f8082ce1f56453538dce25ae138b9f7b1e16
apt-repo-1.2.0/000075500000000000000000000000001223665117500132475ustar00rootroot00000000000000apt-repo-1.2.0/.gear/000075500000000000000000000000001223665117500142435ustar00rootroot00000000000000apt-repo-1.2.0/.gear/rules000064400000000000000000000000071223665117500153150ustar00rootroot00000000000000tar: .
apt-repo-1.2.0/TODO000064400000000000000000000005641223665117500137440ustar00rootroot00000000000000- set proxy configuration for APT
- colorize output
- support mirrors
- lookup best mirror
- create local repository
- support CD and DVD sources
- l10n (both in program output and man page)
- documentation and examples on http://www.altlinux.org/Apt-repo
- show and install task packages

See https://bugzilla.altlinux.org/buglist.cgi?component=apt-repo&product=Sisyphus
apt-repo-1.2.0/apt-repo000075500000000000000000000230201223665117500147210ustar00rootroot00000000000000#!/usr/bin/perl

# apt-repo -- Manipulate APT repository list
# $Id: apt-repo,v 1.2.0 2013-11-07 12:41:00 cas Exp $

# Copyright 2011-2013 by Andrey Cherepanov (cas@altlinux.org)

# This program is free software; you can redistribute it and/or modify it
# under the terms of GNU General Public License (GPL) version 3 or later.

use strict;
use warnings;

# Default parameters
our $VERSION = '1.2.0';

my $type = 'rpm';
my $c_branch = 'classic';
my $c_task = 'task';
my $noarch = 'noarch';

my $cmd = 'list';
my $continues = 0;

$cmd = $ARGV[0] if scalar @ARGV > 0;

# Get system arch
my $arch = `/bin/uname -m`;
chomp $arch; # Truncate carriage return from output
# arch for x86_32
$arch = 'i586' if $arch =~ /^i686$/;

# Default repository pathes
my $repo_base = 'http://ftp.altlinux.org/pub/distributions/ALTLinux/';
my $repo_task = 'http://git.altlinux.org/repo/';
my $conf_main = '/etc/apt/sources.list';
my $conf_list = '/etc/apt/sources.list.d/*.list';
my %repo_keys = (
'Sisyphus' => 'alt' );
my @branches = (
'4.0',
'4.1',
'5.0',
'p5',
'5.1',
'c6',
'p6',
't6',
'p7',
't7',
'c7',
'sisyphus',
'Sisyphus'
);
my $default_key = 'updates';

# Show usage information
sub show_usage {
print <<"HELP";
Usage: apt-repo COMMAND SOURCE
Manipulate APT repository list.

COMMANDS:
list [-a] List active or all repositories
list [task] <id> List task packages
add <source> Add APT repository
rm <source|all> Remove APT repository
clean Remove all cdrom and task sources
update Update APT caches
test [task] <id> Install all packages (except *-debuginfo) from task
-h, --help Show help and exit
-v Show version and exit

<source> may be branch or task name, sources.list(5) string, URL or local path.
HELP
exit 0;
}

# Show version
sub show_version {
print "$VERSION\n";
exit 0;
}

# Return list of repositories as text
sub get_repos {
my $all = shift;
my @out = ();
my $output;

# Show all active repositories
open P, '-|', "egrep -h '^[[:space:]]*$type(-src|-dir)?[[:space:]]+' $conf_main $conf_list";
@out = <P>;
close P;
$output = join( "", @out );

# On -a show all available commented repositories
if( defined $all and $all =~ /^-a$/ ) {
open P, '-|', "egrep -h '^[[:space:]]*#[[:space:]]*$type(-src|-dir)? ' $conf_main $conf_list";
@out = <P>;
close P;
$output .= join( "", @out );
}

return $output;
}

# Get package list for task
sub get_task_content {
my $task = shift;
my @out = ();

die "Missing or wrong task number" if ! defined $task or ! $task=~ /^(\d+)$/;

open P, '-|', "curl -s http://git.altlinux.org/tasks/$task/plan/add-bin | cut -f1 | grep -v '\\-debuginfo\$' | sort ";
@out = <P>;
close P;
return @out;
}

# Show repositories
sub show_repo {
shift;
my $all = shift;

# List for task packages by task number or canonical form `task <number>`
if( defined $all and $all =~ /^(\d+|task)$/ ) {
$all = shift if $all =~ /^task$/;
print join( "",get_task_content( $all ) );
} else {
print get_repos( $all );
}

exit 0;
}

# Determine repository URL
sub get_url {
my $repo = shift;
my $object = shift;
my @url = @_;
my $u;
my @branch_source;

defined $repo or die "Unknown source. See `man apt-repo` for details.";

# Quick forms: known branch name or number for task
if( grep( /^\Q$repo\E$/, @branches ) ) {
$object = $repo;
$repo = 'branch';
}

if( $repo =~ /^[0-9]+$/ ) {
$object = $repo;
$repo = 'task';
}

# Branch
if( $repo =~ /^branch$/ ) {
if ( not defined $object ) {
# Show all available branch names
foreach( @branches ) {
print $_ . "\n";
}
exit 0;
}
my $key = $object;

# Fix Sisyphus name
$object = 'Sisyphus' if $object =~ /^sisyphus$/;

# Fix keys
if( exists( $repo_keys{ $object } ) ) {
$key = $repo_keys{ $object };
} else {
$key = $default_key;
}

if( $object =~ /^Sisyphus$/ ) {
# Sisyphus
$u = 'rpm [' . $key . '] ' . $repo_base . $object;
} else {
$u = 'rpm [' . $key . '] ' . $repo_base . $object . '/branch';
}

@branch_source = (
$u . ' ' . $arch . ' ' . $c_branch,
$u . ' ' . $noarch . ' ' . $c_branch
);
# For x86_64 add Arepo 2.0 source
if( $arch =~ /^x86_64$/ ) {
push( @branch_source, $u . ' x86_64-i586 ' . $c_branch);
}

return @branch_source;

}

# Task
if( $repo =~ /^task$/ ) {
if( not defined $object ) {
print "Task number is missed.\n";
exit 1;
}
if( $arch =~ /^x86_64$/ ) {
# Arepo source for x86_64
return (
'rpm ' . $repo_task . $object . '/ ' . $arch . ' ' . $c_task,
'rpm ' . $repo_task . $object . '/ x86_64-i586 ' . $c_task
);
} else {
return ( 'rpm ' . $repo_task . $object . '/ ' . $arch . ' ' . $c_task );
}
}

# URL
if( $repo =~ /^(http|ftp|rsync|file|copy|cdrom):\// ) {
my $u = 'rpm ' . $repo;
my $component = $c_branch;

if( defined $object ) {
# Architecture is defined
return ( $u . ' ' . $object . ' ' . join( ' ', @url ) );
} else {
# Mirror
return (
$u . ' ' . $arch . ' ' . $component,
$u . ' ' . $noarch . ' ' . $component
);
}
}

# Absolute path for hasher repository
if( $repo =~ /^\// ) {
return ( 'rpm file://' . $repo . ' ' . $arch . ' hasher' );
}

# In format of sources.list(5)
if( $repo =~ /^$type(-src|-dir)?\b/ ) {
if( defined $object ) {
return ( $repo . ' ' . $object . ' ' . join( ' ', @url ) );
} else {
return ( $repo );
}
}

return ();
}

# Add repository to list
sub add_repo {
shift;
my $repo = shift;
my $object = shift;
my @comps = @_;
my $a_found;
my $i_found;

my @urls = get_url( $repo, $object, @comps );

if( scalar @urls == 0 ) {
print "Nothing to add: bad source format. See `man apt-repo` for details.\n";
exit 1;
}

foreach my $u ( @urls ) {
$a_found = 0;
$i_found = 0;

#print "added $u\n";

# Lookup active
foreach( split( /\n/, get_repos( '-a' ) ) ) {
# Check active
if( /^\Q$u\E$/ ) {
# This source is active
$a_found = 1;
last;
}
# Check commented
if( /^[[:space:]]*#[[:space:]]*\Q$u\E$/ ) {
# This source is exist and commented
$i_found = 1;
last;
}
}

#print "$a_found $i_found $u\n";

# Process source
next if $a_found; # Source is active, nothing do

# Uncomment commented source
if( $i_found ) {
my $ur = quotemeta $u;
# Unescape parenthesis in sources for correct sed work
$ur =~ s/\\\(/(/;
$ur =~ s/\\\)/)/;
system "sed -i 's/^[[:space:]]*#[[:space:]]*\\($ur\\)\$/\\1/' $conf_main $conf_list";
next;
}

# Append to main sources list file
open CONFIG, '>>', "$conf_main" or die "Can't open $conf_main: $!";
print CONFIG $u . "\n";
close CONFIG;

}

exit 0 if ! $continues;
}

# Remove repository from list
sub rm_repo {
shift;
my $repo = shift;
my $object = shift;
my @comps = @_;
my $a_found;
my $i_found;

my @urls;

if( defined $repo and $repo =~ /^all$/ ) {
# Remove all active sources
open P, '-|', "egrep -h '^[[:space:]]*$type(-src|-dir)?[[:space:]]+' $conf_main $conf_list";
@urls = <P>;
close P;

# Remove repositories by specified type
if( defined $object ) {
$object =~ /^(branch|branches|task|tasks|cdrom|cdroms)$/ or die "Missing repository type for `apt-repo rm all <type>`";
@urls = grep( /\b\Q$repo_base\E/, @urls ) if( $object =~ /^branch(es)?$/ );
@urls = grep( /\b\Q$repo_task\E[0-9]+/, @urls ) if( $object =~ /^task(s)?$/ );
@urls = grep( /^[[:space:]]*rpm[[:space:]]+cdrom:/, @urls ) if( $object =~ /^cdrom(s)?$/ );
}

} else {
@urls = get_url( $repo, $object, @comps );
}

my $has_warning = 0;
foreach my $u ( @urls ) {
$a_found = 0;
$i_found = 0;

chomp $u;

# Lookup active
foreach( split( /\n/, get_repos() ) ) {
# Check active
if( /^\Q$u\E$/ ) {
# This source is active
$a_found = 1;
last;
}
}

#print "$a_found $u\n";

# Remove from $conf_main, comment in other files
if( $a_found ) {
$u = quotemeta $u;
# Unescape parenthesis in sources for correct sed work
$u =~ s/\\\(/(/;
$u =~ s/\\\)/)/;
system "sed -i -e '/^[[:space:]]*$u\$/d' $conf_main";
system "sed -i 's/^[[:space:]]*$u\$/#$u/' $conf_list";
} else {
if( not $has_warning ) {
print "Nothing to remove: source was not found.\n";
$has_warning = 1;
}
}
}
return 0;
}

# Remove all cdrom and task repositories
sub clear_repo {
my @cmd;

@cmd = qw(rm all cdroms);
rm_repo( @cmd );

@cmd = qw(rm all tasks);
rm_repo( @cmd );

exit 0 if ! $continues;
}

# Update repo
sub update_repo {
system 'apt-get update';
exit 0 if ! $continues;
}

# Test task
sub test_task {
shift;
my $task = shift;
my @pkgs = ();
my $list = "";

$task = shift if $task =~ /^task$/;
@pkgs = get_task_content( $task );

# Add source and update indices
$continues = 1;
add_repo( ("add", "task", $task ) );
update_repo();

# Install all packages from task (except *-debuginfo)
chomp( @pkgs );
$list = join( " ", @pkgs );

# Install packages from task repository
system "apt-get install $list";

# Remove task source
rm_repo( ("rm", "task", $task ) );

exit 0;
}

# Process command line arguments

# Exiting functions
show_repo( @ARGV ) if $cmd =~ /^list$/;
show_repo( 'list', '-a' ) if $cmd =~ /^-a$/;
show_usage() if $cmd =~ /-(h|-help)$/ or scalar @ARGV == 0;
show_version() if $cmd =~ /-(v|-version)$/;
clear_repo( @ARGV ) if $cmd =~ /^clea[rn]$/;
update_repo() if $cmd =~ /^update$/;
test_task( @ARGV ) if $cmd =~ /^test$/;

# Functions with return
if( $cmd =~ /^(add|rm)$/ ) {
add_repo( @ARGV ) if $cmd =~ /^add$/;
rm_repo( @ARGV ) if $cmd =~ /^rm$/;
} else {
print "Unknown command `$cmd`.\nRun `apt-repo --help` for supported commands.\n";
exit 1;
}

__END__
apt-repo-1.2.0/apt-repo.8000064400000000000000000000074011223665117500150710ustar00rootroot00000000000000.\" $Id$
.\"
.\" Man page for the apt-repo program.
.\"
.\" Copyright (c) 2011-2013 Andrey Cherepanov <cas@altlinux.org>
.\"
.\" This software is distributed under the GNU General Public License (GPL)
.\" version 3 or later.
.\"
.Os Linux
.Dd "November 06, 2013"
.ds volume-operating-system Linux
.Dt apt\-repo 8
.\"
.Sh NAME
.Nm apt\-repo
.Nd Manipulate APT repository list
.\"
.Sh SYNOPSIS
.Nm apt\-repo
.Op list
.Op Fl a
.Nm apt\-repo
list
.Op task
.Ar id
.Nm apt\-repo
add
.Ar source
.Nm apt\-repo
rm
.Ar source|all
.Op Ar type
.Nm apt\-repo
clean
.Nm apt\-repo
update
.Nm apt\-repo
test
.Op task
.Ar id
.Nm apt\-repo
.Op Fl h
.Op Fl v
.\"
.Sh DESCRIPTION
The
.Nm apt\-repo
script allow to show, add and remove
.Tn APT
repositories specified by
.Ar source
in
.Xr sources.list 5
format,
.Tn URL
with optional component, branch name or task number.
.Sh OPTIONS
.Bl -tag -width Ds
.It list
Show active repositories in
.Xr sources.list 5
format. If
.Fl a
is specified all available repositories are displayed (inactive are commended by
.Ql #
).
.It list [task] Ar id
Show names of all available packages (except *-debuginfo) in specified by
.Ar id
task repository.
.It add Ar source
Add
.Ar source
to list of active repositories.
.It rm Ar source [<type>]
Remove or comment
.Ar source
if it is active. Special keyword
.Ar all
removes all active sources. The
.Ar all
keyword followed by optional
.Ar <type>
removes all sources of specified type:
.Ql branch
or
.Ql branches
removes all branch sources,
.Ql task
or
.Ql tasks
removes all tasks sources,
.Ql cdrom
or
.Ql cdroms
removes all cdrom sources.
.It clean
Removes all cdrom and task sources.
.It update
Run
.Dl apt\-get update
to update
.Tn APT
cache from active repositories.
.It test [task] Ar id
Install all available packages (except *-debuginfo) from specified by
.Ar id
task repository.
.It Fl h Fl \-help
Print usage information and quit.
.It Fl v Fl \-version
Print version and quit.
.El
.\"
.Sh "SOURCE FORMAT"
.Ss "APT Source"
Source can be specified in
.Xr sources.list 5
format:
.Pp
.Dl apt\-repo add \*qrpm http://git.altlinux.org/repo/39115/ i586 task\*q
.Pp
Recognized repository types: rpm, rpm-dir and rpm-src. It is allowed to
specify source as separate words. If trailing architecture and component
are missed two lines will be added (current system architecture and
.Ql noarch
) with component
.Ql classic
.
.Ss "URL"
.Tn APT
supports file://, copy://, http://, ftp://, rsync:// and cdrom:// protocols.
.Tn URL
with required protocol may trail optional architecture and one or more
components. If architecture and component are missed two lines will be added
(current system architecture and
.Ql noarch
) with component
.Ql classic .
This form is useful to add branch on mirror server.
.Pp
Example:
.Pp
.Dl apt\-repo add ftp://mirror.yandex.ru/altlinux/p7/branch
.Ss "Absolute Path"
Local directory beginning with
.Ql /
added as hasher repository: with current system architecture and
.Xr hasher
component.
.Pp
.Dl apt\-repo add /opt/repo
.Ss "Branch"
Branch is named repository consist from two parts (current system architecture
and 'noarch'). By default official server is used. Full form:
.Pp
.Dl apt\-repo add branch <name of branch>
.Pp
Keyword
.Ql branch
may be omitted. Example:
.Pp
.Dl apt\-repo add p7
.Pp
Run
.Dl apt\-repo add branch
.Pp
without name of branch displays all available branch names.
.Ss "Task"
Task is small repository for one or more subtask built in http://git.altlinux.org
infrastructure. This source is used to install software for test purpose.
Any task has unique number. Full form:
.Pp
.Dl apt\-repo add task <number of task>
.Pp
Keyword
.Ql task
may be omitted. Example:
.Pp
.Dl apt\-repo add 39115
.\"
.Sh "SEE ALSO"
.Xr sources.list 5 ,
.Xr apt\-cache 8 ,
.Xr apt\-get 8
.\"
.Sh AUTHORS
.An Andrey Cherepanov
.Mt cas@altlinux.org
apt-repo-1.2.0/apt-repo.spec000064400000000000000000000065661223665117500156670ustar00rootroot00000000000000Name: apt-repo
Version: 1.2.0
Release: alt1

Summary: Script for manipulation APT repository list
License: GPLv3+
Group: System/Configuration/Packaging
URL: http://altlinux.org/apt-repo
Packager: Andrey Cherepanov <cas@altlinux.org>
BuildArch: noarch

Source: %name-%version.tar
BuildRequires: gzip
Requires: apt
Requires: curl

%description
The apt-repo script allow to show, add and remove APT repositories specified
by address in sources.list(5) format, URL with optional component, branch
name or task number.

%prep
%setup

%install
install -Dm755 %name %buildroot%_bindir/%name
mkdir -p %buildroot%_man1dir
install -Dpm 644 %name.8 %buildroot%_man8dir/%name.8
gzip %buildroot%_man8dir/%name.8

%find_lang %name

%files -f %name.lang
%doc TODO
%_bindir/%name
%doc %_man8dir/%name.8.gz

%changelog
* Thu Nov 07 2013 Andrey Cherepanov <cas@altlinux.org> 1.2.0-alt1
- Add `apt-repo test task <num>` for install all task packages
(except *-debuginfo)
- Get package list from task
- Add t7 and c7 in available repository list

* Tue Oct 29 2013 Andrey Cherepanov <cas@altlinux.org> 1.1.6-alt1
- Add task source with Arepo on x86_64

* Fri Aug 30 2013 Andrey Cherepanov <cas@altlinux.org> 1.1.5-alt1
- Add copy:// protocol support in sources (ALT #29071)
- Fix man page:
- Move man page to section 8 (System administration commands and daemons)
- Fix OS name in section name (Linux instead of BSD)
- Add copy:// protocol support
- Remove trailing whitespace and empty lines

* Sat May 25 2013 Andrey Cherepanov <cas@altlinux.org> 1.1.4-alt1
- Set common key `update` for all branches for easy migration to newer
branch because there is no branch-specific key without apt-conf update

* Thu May 23 2013 Andrey Cherepanov <cas@altlinux.org> 1.1.3-alt1
- Add arepo 2.0 source too on adding x86_64 branch
- Show only one warning on non-existing source removal
- Add official keys for p6 and p7 brahches
- Display warning about unsupported command

* Sat Apr 27 2013 Andrey Cherepanov <cas@altlinux.org> 1.1.2-alt1
- Add support for branches t6, p7, t7
- Use apt-repo clean instead clear

* Tue Nov 20 2012 Andrey Cherepanov <cas@altlinux.org> 1.1.1-alt1
- Add apt-repo clear command to remove all cdrom and task repositories
- Fix add cdrom source if it exist in list
- Check for wrong type on mass source deletion
- Remove error message on empty deletion

* Tue Nov 29 2011 Andrey Cherepanov <cas@altlinux.org> 1.1.0-alt1
- Remove man page from program to separate file
- Support remove only specified type of sources
- Fix cdrom source remove

* Mon May 16 2011 Andrey Cherepanov <cas@altlinux.org> 1.0.3-alt1
- Describe source definition in help
- Add keyword `all` in tm command to remove all active sources
- Fix use source as one string

* Mon May 09 2011 Andrey Cherepanov <cas@altlinux.org> 1.0.2-alt1
- Make error messages more informational (closes: #25417)
- Inform about missed task number
- Show all available branch names
- Complete documentation
- Support sources.list(5) tokens in command line
- Pass all arguments as parts of source line (closes: #25418)
- Support quick forms of source: known branch name or number for task
- Fix URL for Sisyphus. Support absolute pathname for hasher repo.

* Tue Apr 19 2011 Andrey Cherepanov <cas@altlinux.org> 1.0.1-alt1
- Fix arch definition on x86_64 (closes: #25464)

* Thu Mar 31 2011 Andrey Cherepanov <cas@altlinux.org> 1.0-alt1
- Initial build in Sisyphus

 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin