Skip to content

Commit 9db56a5

Browse files
committed
use global apt config
1 parent 7f06d14 commit 9db56a5

File tree

3 files changed

+2
-35
lines changed

3 files changed

+2
-35
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APT::Update::Error-Mode "any";

internal/update/apt/apt_update.config

Lines changed: 0 additions & 1 deletion
This file was deleted.

internal/update/apt/service.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,7 @@ func runDpkgConfigureCommand(ctx context.Context) error {
154154
}
155155

156156
func runUpdateCommand(ctx context.Context) error {
157-
// Create a temporary apt config file for passing custom option,
158-
// without changing the sudoers file.
159-
config, rmConfig, err := getAptUpdateConfigFile()
160-
if err != nil {
161-
slog.Warn("cannot write apt config file, skipped", slog.String("error", err.Error()))
162-
return err
163-
}
164-
defer rmConfig()
165-
166-
cmd, err := paths.NewProcess(
167-
[]string{"APT_CONFIG", config.String()},
168-
"sudo", "apt-get", "update",
169-
)
157+
cmd, err := paths.NewProcess(nil, "sudo", "apt-get", "update")
170158
if err != nil {
171159
return err
172160
}
@@ -176,27 +164,6 @@ func runUpdateCommand(ctx context.Context) error {
176164
return nil
177165
}
178166

179-
//go:embed apt_update.config
180-
var aptUpdateConfig []byte
181-
182-
func getAptUpdateConfigFile() (*paths.Path, func(), error) {
183-
config, err := paths.MkTempFile(nil, "apt.config")
184-
if err != nil {
185-
return nil, nil, fmt.Errorf("cannot create apt config file: %w", err)
186-
}
187-
188-
if _, err = config.Write(aptUpdateConfig); err != nil {
189-
return nil, nil, fmt.Errorf("cannot write temporary apt config file: %w", err)
190-
}
191-
192-
path, err := paths.New(config.Name()).Abs()
193-
if err != nil {
194-
return nil, nil, fmt.Errorf("cannot get absolute apt config file path: %w", err)
195-
}
196-
197-
return path, func() { _ = path.Remove() }, nil
198-
}
199-
200167
func runUpgradeCommand(ctx context.Context, names []string) iter.Seq2[string, error] {
201168
env := []string{"NEEDRESTART_MODE=l"}
202169

0 commit comments

Comments
 (0)