# apt-suggest-auto

Over time, packages installed as dependencies of manually-installed packages accumulate as "manually installed" in the APT database, preventing autoremoval when they are no longer needed. **apt-suggest-auto** identifies such packages by simulating the effect of marking each one as automatically installed and checking whether it would become eligible for autoremoval. Only packages that remain required by other installed packages are suggested for reclassification. It serves as a modern replacement for debfoster and deborphan.

## Features

* **Identifies Manually Installed Packages:** Scans the APT cache for packages currently marked as manually installed.
* **Safe Simulation:** Simulates marking each package as auto-installed and rejects any that would become eligible for autoremoval.
* **Prevents Accidental Autoremoval:** Only suggests packages that remain required by other installed packages.
* **Optional Application:** The `--apply` flag commits the changes, marking the identified packages as automatically installed.
* **Scripting Friendly Output:** The `--raw` flag outputs a plain list of markable packages, one per line.
* **APT Configuration Options:** The `-o` flag passes APT configuration options, e.g. `-o Dir::State::status=/path/to/status`.

## Installation

### From Debian package

```bash
sudo dpkg -i apt-suggest-auto_0.1_all.deb
```

### From source

```bash
git clone https://salsa.debian.org/lucas/apt-suggest-auto.git
cd apt-suggest-auto
sudo dpkg-buildpackage -us -uc -b
sudo dpkg -i ../apt-suggest-auto_0.1_all.deb
```

## Usage

### Simulation (Default)

By default, the tool performs a simulation and lists packages that can be safely marked as automatic, without making any changes.

```bash
apt-suggest-auto
```

Example output:

```
Found X manually installed packages.
Simulating changes to identify safely markable packages...
Successfully identified Y packages that can be safely marked as automatic:
  - package-name-1
  - package-name-2
  - ...
Need to keep Z packages as manual to prevent their autoremoval:
  - package-name-A
  - package-name-B
  - ...

*** This was a simulation. No actual changes were made to your system. ***
```

### Applying Changes

To mark the identified packages as automatically installed, use the `--apply` flag. This requires root privileges.

```bash
sudo apt-suggest-auto --apply
```

### Raw Output for Scripting

To get a plain list of packages that can be safely marked as automatic, use the `--raw` flag:

```bash
apt-suggest-auto --raw
```

Example output:

```
package-name-1
package-name-2
...
```

This can be piped to other commands:

```bash
apt-suggest-auto --raw | xargs echo "Packages to mark auto: "
```

### APT Configuration Options

Pass APT configuration options with `-o`:

```bash
apt-suggest-auto -o Dir::State::status=/path/to/status
```

Can be used multiple times:

```bash
apt-suggest-auto -o APT::Get::Assume-Yes=true -o Dir::State::status=/path/to/status
```

## Contributing

Contributions are welcome! Please feel free to open issues or submit merge requests on the [Salsa repository](https://salsa.debian.org/lucas/apt-suggest-auto).

## License

This project is licensed under the [GPL-2.0-or-later License](https://www.gnu.org/licenses/gpl-2.0.en.html).