Remove repo-remove stuff and update README
This commit is contained in:
parent
159b042379
commit
097299da8d
3 changed files with 22 additions and 42 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
A script to clean up pacman repos. This is primarily used for removing old versions of packages and adding new ones, but it has options to print old and new packages line-by-line so they can be parsed by other programs.
|
||||
|
||||
![A screenshot of Parcut running on my repo](/readme-assets/screenshot.png)
|
||||
|
||||
## Usage
|
||||
|
||||
First off, this depends on `natsort` and `click`, which you can install with `pip`.
|
||||
|
@ -37,19 +39,18 @@ Lists old versions of packages.
|
|||
|
||||
### `run`
|
||||
|
||||
Processes it all, runs `repo-remove` and deletes old packages, then runs `repo-add` on new packages.
|
||||
Processes it all, deletes old packages, then runs `repo-add` on new packages.
|
||||
|
||||
Arguments:
|
||||
|
||||
- `--dry-run`: Do a dry run
|
||||
- `--only-delete`: Only delete files, don't modify the repo files from them (default: false)
|
||||
- Without this argument, parcut will try to remove and add the relevant packages using `repo-add` and `repo-remove`, meaning it optionally depends on those programs.
|
||||
- <small>As long as you're on Arch, this will be installed, as it's part of pacman. Plus, if you're running a repo, you need these anyways.</small>
|
||||
- Without this argument, parcut will try to add the newest packages using `repo-add`, meaning it optionally depends on those programs.
|
||||
- <small>As long as you're on Arch, this will be installed, as it's part of pacman. Plus, if you're running a repo, you need this anyways.</small>
|
||||
|
||||
## Exit codes
|
||||
|
||||
- `0`: Completed successfully
|
||||
- `10`: Failed to remove old package from repo - probably missing write perms on the database.
|
||||
- `11`: Permission denied when trying to delete a package - missing write perms on the package.
|
||||
- `12`: Failed to add new package to repo - again, probably missing write perms on the database.
|
||||
|
||||
|
|
BIN
readme-assets/screenshot.png
Normal file
BIN
readme-assets/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 224 KiB |
|
@ -18,7 +18,7 @@ def cli():
|
|||
'--only-delete',
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Only delete files, don't run repo-remove and repo-add on their old and new versions (default: false)"
|
||||
help="Only delete files, don't run repo-add on the new versions (default: false)"
|
||||
)
|
||||
@click.argument('repo_path')
|
||||
def run(repo_path, dry_run=False, only_delete=False):
|
||||
|
@ -27,44 +27,9 @@ def run(repo_path, dry_run=False, only_delete=False):
|
|||
f'{colors.bg.bright.blue}{colors.fg.black}Dry run mode enabled; no changes will be made{colors.reset}\n'
|
||||
)
|
||||
old_packages = get_old_packages(repo_path)
|
||||
new_packages = get_new_packages(repo_path)
|
||||
repo_name = HelperFunctions.get_repo_name(repo_path)
|
||||
|
||||
if not only_delete:
|
||||
print('=== Removing old packages ===')
|
||||
for pkg in old_packages:
|
||||
print(f'Removing {pkg}...')
|
||||
if not dry_run:
|
||||
output = getstatusoutput(
|
||||
f'repo-remove {repo_path}/{repo_name}.db.tar.zst {repo_path}/{pkg}'
|
||||
)
|
||||
if output[0] != 0:
|
||||
print(
|
||||
f'{colors.bg.red}[ERROR]{colors.reset} failed to remove {pkg}'
|
||||
)
|
||||
print(f'Exit code: {output[0]}')
|
||||
print(f'Command output:\n{output[1]}')
|
||||
exit(10)
|
||||
|
||||
print(
|
||||
f'{colors.fg.green}✅ Successfully removed old packages from repo{colors.reset}'
|
||||
)
|
||||
print()
|
||||
|
||||
print('=== Deleting old packages ===')
|
||||
for pkg in old_packages:
|
||||
print(f'Deleting {pkg}...')
|
||||
if not dry_run:
|
||||
try:
|
||||
remove(f'{repo_path}/{pkg}')
|
||||
except Exception as e:
|
||||
print(f'{colors.bg.red}[ERROR]{colors.reset} failed to delete {pkg}')
|
||||
print(f'Error: {e}')
|
||||
exit(11)
|
||||
|
||||
print(f'{colors.fg.green}✅ Successfully deleted packages{colors.reset}')
|
||||
print()
|
||||
|
||||
new_packages = get_new_packages(repo_path)
|
||||
if not only_delete:
|
||||
print('=== Adding new packages ===')
|
||||
for pkg in new_packages:
|
||||
|
@ -83,7 +48,21 @@ def run(repo_path, dry_run=False, only_delete=False):
|
|||
)
|
||||
print()
|
||||
|
||||
print(f'✨ {colors.bg.green}Repo successfully updated{colors.reset} ✨')
|
||||
print('=== Deleting old packages ===')
|
||||
for pkg in old_packages:
|
||||
print(f'Deleting {pkg}...')
|
||||
if not dry_run:
|
||||
try:
|
||||
remove(f'{repo_path}/{pkg}')
|
||||
except Exception as e:
|
||||
print(f'{colors.bg.red}[ERROR]{colors.reset} failed to delete {pkg}')
|
||||
print(f'Error: {e}')
|
||||
exit(11)
|
||||
|
||||
print(f'{colors.fg.green}✅ Successfully deleted packages{colors.reset}')
|
||||
print()
|
||||
|
||||
print(f'✨ {colors.bg.green}{colors.fg.black}Repo successfully updated{colors.reset} ✨')
|
||||
|
||||
|
||||
@cli.command('list-old-packages')
|
||||
|
|
Loading…
Reference in a new issue