Description: remove self-update functionality
Author: Félix Sipma <felix@debian.org>
Forwarded: not-needed
Last-Update: 2024-02-09
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/doc/manual_rest.rst
+++ b/doc/manual_rest.rst
@@ -51,7 +51,6 @@ Usage help is available:
     Additional Commands:
       generate      Generate manual pages and auto-completion files (bash, fish, zsh, powershell)
       help          Help about any command
-      self-update   Update the restic binary
       version       Print version information
 
     Flags:
--- a/doc/bash-completion.sh
+++ b/doc/bash-completion.sh
@@ -3343,80 +3343,6 @@ _restic_rewrite()
     noun_aliases=()
 }
 
-_restic_self-update()
-{
-    last_command="restic_self-update"
-
-    command_aliases=()
-
-    commands=()
-
-    flags=()
-    two_word_flags=()
-    local_nonpersistent_flags=()
-    flags_with_completion=()
-    flags_completion=()
-
-    flags+=("--help")
-    flags+=("-h")
-    local_nonpersistent_flags+=("--help")
-    local_nonpersistent_flags+=("-h")
-    flags+=("--output=")
-    two_word_flags+=("--output")
-    local_nonpersistent_flags+=("--output")
-    local_nonpersistent_flags+=("--output=")
-    flags+=("--cacert=")
-    two_word_flags+=("--cacert")
-    flags+=("--cache-dir=")
-    two_word_flags+=("--cache-dir")
-    flags+=("--cleanup-cache")
-    flags+=("--compression=")
-    two_word_flags+=("--compression")
-    flags+=("--http-user-agent=")
-    two_word_flags+=("--http-user-agent")
-    flags+=("--insecure-no-password")
-    flags+=("--insecure-tls")
-    flags+=("--json")
-    flags+=("--key-hint=")
-    two_word_flags+=("--key-hint")
-    flags+=("--limit-download=")
-    two_word_flags+=("--limit-download")
-    flags+=("--limit-upload=")
-    two_word_flags+=("--limit-upload")
-    flags+=("--no-cache")
-    flags+=("--no-extra-verify")
-    flags+=("--no-lock")
-    flags+=("--option=")
-    two_word_flags+=("--option")
-    two_word_flags+=("-o")
-    flags+=("--pack-size=")
-    two_word_flags+=("--pack-size")
-    flags+=("--password-command=")
-    two_word_flags+=("--password-command")
-    flags+=("--password-file=")
-    two_word_flags+=("--password-file")
-    two_word_flags+=("-p")
-    flags+=("--quiet")
-    flags+=("-q")
-    flags+=("--repo=")
-    two_word_flags+=("--repo")
-    two_word_flags+=("-r")
-    flags+=("--repository-file=")
-    two_word_flags+=("--repository-file")
-    flags+=("--retry-lock=")
-    two_word_flags+=("--retry-lock")
-    flags+=("--stuck-request-timeout=")
-    two_word_flags+=("--stuck-request-timeout")
-    flags+=("--tls-client-cert=")
-    two_word_flags+=("--tls-client-cert")
-    flags+=("--verbose")
-    flags+=("-v")
-
-    must_have_one_flag=()
-    must_have_one_noun=()
-    noun_aliases=()
-}
-
 _restic_snapshots()
 {
     last_command="restic_snapshots"
@@ -3874,7 +3800,6 @@ _restic_root_command()
     commands+=("repair")
     commands+=("restore")
     commands+=("rewrite")
-    commands+=("self-update")
     commands+=("snapshots")
     commands+=("stats")
     commands+=("tag")
--- a/cmd/restic/main.go
+++ b/cmd/restic/main.go
@@ -110,7 +110,7 @@ The full documentation can be found at h
 // user for authentication).
 func needsPassword(cmd string) bool {
 	switch cmd {
-	case "cache", "generate", "help", "options", "self-update", "version", "__complete":
+	case "cache", "generate", "help", "options", "version", "__complete":
 		return false
 	default:
 		return true
--- a/doc/man/restic-self-update.1
+++ /dev/null
@@ -1,138 +0,0 @@
-.nh
-.TH "restic backup" "1" "Jan 2017" "generated by \fBrestic generate\fR" ""
-
-.SH NAME
-restic-self-update - Update the restic binary
-
-
-.SH SYNOPSIS
-\fBrestic self-update [flags]\fP
-
-
-.SH DESCRIPTION
-The command "self-update" downloads the latest stable release of restic from
-GitHub and replaces the currently running binary. After download, the
-authenticity of the binary is verified using the GPG signature on the release
-files.
-
-
-.SH EXIT STATUS
-Exit status is 0 if the command was successful.
-Exit status is 1 if there was any error.
-Exit status is 10 if the repository does not exist.
-Exit status is 11 if the repository is already locked.
-Exit status is 12 if the password is incorrect.
-
-
-.SH OPTIONS
-\fB-h\fP, \fB--help\fP[=false]
-	help for self-update
-
-.PP
-\fB--output\fP=""
-	Save the downloaded file as \fBfilename\fR (default: running binary itself)
-
-
-.SH OPTIONS INHERITED FROM PARENT COMMANDS
-\fB--cacert\fP=[]
-	\fBfile\fR to load root certificates from (default: use system certificates or $RESTIC_CACERT)
-
-.PP
-\fB--cache-dir\fP=""
-	set the cache \fBdirectory\fR\&. (default: use system default cache directory)
-
-.PP
-\fB--cleanup-cache\fP[=false]
-	auto remove old cache directories
-
-.PP
-\fB--compression\fP=auto
-	compression mode (only available for repository format version 2), one of (auto|off|max) (default: $RESTIC_COMPRESSION)
-
-.PP
-\fB--http-user-agent\fP=""
-	set a http user agent for outgoing http requests
-
-.PP
-\fB--insecure-no-password\fP[=false]
-	use an empty password for the repository, must be passed to every restic command (insecure)
-
-.PP
-\fB--insecure-tls\fP[=false]
-	skip TLS certificate verification when connecting to the repository (insecure)
-
-.PP
-\fB--json\fP[=false]
-	set output mode to JSON for commands that support it
-
-.PP
-\fB--key-hint\fP=""
-	\fBkey\fR ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
-
-.PP
-\fB--limit-download\fP=0
-	limits downloads to a maximum \fBrate\fR in KiB/s. (default: unlimited)
-
-.PP
-\fB--limit-upload\fP=0
-	limits uploads to a maximum \fBrate\fR in KiB/s. (default: unlimited)
-
-.PP
-\fB--no-cache\fP[=false]
-	do not use a local cache
-
-.PP
-\fB--no-extra-verify\fP[=false]
-	skip additional verification of data before upload (see documentation)
-
-.PP
-\fB--no-lock\fP[=false]
-	do not lock the repository, this allows some operations on read-only repositories
-
-.PP
-\fB-o\fP, \fB--option\fP=[]
-	set extended option (\fBkey=value\fR, can be specified multiple times)
-
-.PP
-\fB--pack-size\fP=0
-	set target pack \fBsize\fR in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)
-
-.PP
-\fB--password-command\fP=""
-	shell \fBcommand\fR to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)
-
-.PP
-\fB-p\fP, \fB--password-file\fP=""
-	\fBfile\fR to read the repository password from (default: $RESTIC_PASSWORD_FILE)
-
-.PP
-\fB-q\fP, \fB--quiet\fP[=false]
-	do not output comprehensive progress report
-
-.PP
-\fB-r\fP, \fB--repo\fP=""
-	\fBrepository\fR to backup to or restore from (default: $RESTIC_REPOSITORY)
-
-.PP
-\fB--repository-file\fP=""
-	\fBfile\fR to read the repository location from (default: $RESTIC_REPOSITORY_FILE)
-
-.PP
-\fB--retry-lock\fP=0s
-	retry to lock the repository if it is already locked, takes a value like 5m or 2h (default: no retries)
-
-.PP
-\fB--stuck-request-timeout\fP=5m0s
-	\fBduration\fR after which to retry stuck requests
-
-.PP
-\fB--tls-client-cert\fP=""
-	path to a \fBfile\fR containing PEM encoded TLS client certificate and private key (default: $RESTIC_TLS_CLIENT_CERT)
-
-.PP
-\fB-v\fP, \fB--verbose\fP[=0]
-	be verbose (specify multiple times or a level using --verbose=n``, max level/times is 2)
-
-
-.SH SEE ALSO
-\fBrestic(1)\fP
--- a/doc/man/restic.1
+++ b/doc/man/restic.1
@@ -123,4 +123,4 @@ The full documentation can be found at h
 
 
 .SH SEE ALSO
-\fBrestic-backup(1)\fP, \fBrestic-cache(1)\fP, \fBrestic-cat(1)\fP, \fBrestic-check(1)\fP, \fBrestic-copy(1)\fP, \fBrestic-diff(1)\fP, \fBrestic-dump(1)\fP, \fBrestic-features(1)\fP, \fBrestic-find(1)\fP, \fBrestic-forget(1)\fP, \fBrestic-generate(1)\fP, \fBrestic-init(1)\fP, \fBrestic-key(1)\fP, \fBrestic-list(1)\fP, \fBrestic-ls(1)\fP, \fBrestic-migrate(1)\fP, \fBrestic-mount(1)\fP, \fBrestic-options(1)\fP, \fBrestic-prune(1)\fP, \fBrestic-recover(1)\fP, \fBrestic-repair(1)\fP, \fBrestic-restore(1)\fP, \fBrestic-rewrite(1)\fP, \fBrestic-self-update(1)\fP, \fBrestic-snapshots(1)\fP, \fBrestic-stats(1)\fP, \fBrestic-tag(1)\fP, \fBrestic-unlock(1)\fP, \fBrestic-version(1)\fP
+\fBrestic-backup(1)\fP, \fBrestic-cache(1)\fP, \fBrestic-cat(1)\fP, \fBrestic-check(1)\fP, \fBrestic-copy(1)\fP, \fBrestic-diff(1)\fP, \fBrestic-dump(1)\fP, \fBrestic-features(1)\fP, \fBrestic-find(1)\fP, \fBrestic-forget(1)\fP, \fBrestic-generate(1)\fP, \fBrestic-init(1)\fP, \fBrestic-key(1)\fP, \fBrestic-list(1)\fP, \fBrestic-ls(1)\fP, \fBrestic-migrate(1)\fP, \fBrestic-mount(1)\fP, \fBrestic-options(1)\fP, \fBrestic-prune(1)\fP, \fBrestic-recover(1)\fP, \fBrestic-repair(1)\fP, \fBrestic-restore(1)\fP, \fBrestic-rewrite(1)\fP, \fBrestic-snapshots(1)\fP, \fBrestic-stats(1)\fP, \fBrestic-tag(1)\fP, \fBrestic-unlock(1)\fP, \fBrestic-version(1)\fP
--- a/cmd/restic/cmd_self_update.go
+++ /dev/null
@@ -1,100 +0,0 @@
-//go:build selfupdate
-
-package main
-
-import (
-	"context"
-	"os"
-	"path/filepath"
-
-	"github.com/restic/restic/internal/errors"
-	"github.com/restic/restic/internal/selfupdate"
-	"github.com/spf13/cobra"
-	"github.com/spf13/pflag"
-)
-
-func registerSelfUpdateCommand(cmd *cobra.Command) {
-	cmd.AddCommand(
-		newSelfUpdateCommand(),
-	)
-}
-
-func newSelfUpdateCommand() *cobra.Command {
-	var opts SelfUpdateOptions
-
-	cmd := &cobra.Command{
-		Use:   "self-update [flags]",
-		Short: "Update the restic binary",
-		Long: `
-The command "self-update" downloads the latest stable release of restic from
-GitHub and replaces the currently running binary. After download, the
-authenticity of the binary is verified using the GPG signature on the release
-files.
-
-EXIT STATUS
-===========
-
-Exit status is 0 if the command was successful.
-Exit status is 1 if there was any error.
-Exit status is 10 if the repository does not exist.
-Exit status is 11 if the repository is already locked.
-Exit status is 12 if the password is incorrect.
-`,
-		DisableAutoGenTag: true,
-		RunE: func(cmd *cobra.Command, args []string) error {
-			return runSelfUpdate(cmd.Context(), opts, globalOptions, args)
-		},
-	}
-
-	opts.AddFlags(cmd.Flags())
-	return cmd
-}
-
-// SelfUpdateOptions collects all options for the update-restic command.
-type SelfUpdateOptions struct {
-	Output string
-}
-
-func (opts *SelfUpdateOptions) AddFlags(f *pflag.FlagSet) {
-	f.StringVar(&opts.Output, "output", "", "Save the downloaded file as `filename` (default: running binary itself)")
-}
-
-func runSelfUpdate(ctx context.Context, opts SelfUpdateOptions, gopts GlobalOptions, args []string) error {
-	if opts.Output == "" {
-		file, err := os.Executable()
-		if err != nil {
-			return errors.Wrap(err, "unable to find executable")
-		}
-
-		opts.Output = file
-	}
-
-	fi, err := os.Lstat(opts.Output)
-	if err != nil {
-		dirname := filepath.Dir(opts.Output)
-		di, err := os.Lstat(dirname)
-		if err != nil {
-			return err
-		}
-		if !di.Mode().IsDir() {
-			return errors.Fatalf("output parent path %v is not a directory, use --output to specify a different file path", dirname)
-		}
-	} else {
-		if !fi.Mode().IsRegular() {
-			return errors.Fatalf("output path %v is not a normal file, use --output to specify a different file path", opts.Output)
-		}
-	}
-
-	Verbosef("writing restic to %v\n", opts.Output)
-
-	v, err := selfupdate.DownloadLatestStableRelease(ctx, opts.Output, version, Verbosef)
-	if err != nil {
-		return errors.Fatalf("unable to update restic: %v", err)
-	}
-
-	if v != version {
-		Printf("successfully updated restic to version %v\n", v)
-	}
-
-	return nil
-}
