Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: Manually create aurto.db #96

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aur
Submodule aur updated from 4d87c4 to 0d3425
12 changes: 7 additions & 5 deletions bin/aurto
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ if [[ $EUID -eq 0 ]]; then
user=$(cat /usr/lib/aurto/user)
exec sudo -u "$user" "$0" "$@"
else
echo "aurto not intialised. Run $(green aurto init) as a non-root user"
echo "aurto not initialised. Run $(green aurto init) as a non-root user"
exit 1
fi
fi
@@ -23,7 +23,7 @@ lib_dir="$bin_dir/../lib/aurto"
source "$lib_dir/shared-functions"

if [[ $command != "init" ]] && ! initialised; then
echo "aurto not intialised. Run $(green aurto init)"
echo "aurto not initialised. Run $(green aurto init)"
exit 1
fi

@@ -133,17 +133,19 @@ if [ "$command" == "add" ] && [ -n "$arg1" ]; then

elif [ "$command" == "addpkg" ] && [ -n "$arg1" ]; then
check_new_package_trust "${@:2}"
echo "aurto: Running: $(dim repo-add /var/cache/pacman/aurto/aurto.db.tar) $(cyan "${*:2}")" >&2
repo-add /var/cache/pacman/aurto/aurto.db.tar "${@:2}"
db_tar_path=$(readlink -f /var/cache/pacman/aurto/aurto.db)
echo "aurto: Running: $(dim repo-add "$db_tar_path") $(cyan "${*:2}")" >&2
repo-add "$db_tar_path" "${@:2}"
for pkg in "${@:2}"; do
cp "$pkg" /var/cache/pacman/aurto/
done
aurto_sync

elif [ "$command" == "remove" ] && [ -n "$arg1" ]; then
db_tar_path=$(readlink -f /var/cache/pacman/aurto/aurto.db)
removed=""
for pkg in "${@:2}"; do
if remove_out=$(repo-remove /var/cache/pacman/aurto/aurto.db.tar "$pkg" 2>&1); then
if remove_out=$(repo-remove "$db_tar_path" "$pkg" 2>&1); then
if [[ $remove_out = *"ERROR"* ]]; then
# may no longer be necessary as repo-remove seems to exit non-zero in this case
echo "aurto: $(cyan "$pkg") $(red not found)" >&2
5 changes: 3 additions & 2 deletions lib/aurto/install
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ init() {
chmod 700 /usr/lib/aurto/user

install -d /var/cache/pacman/aurto -o "$user"
sudo -u "$user" repo-add /var/cache/pacman/aurto/aurto.db.tar 2>/dev/null
sudo -u "$user" tar acf /var/cache/pacman/aurto/aurto.db.tar.zst -T /dev/null
sudo -u "$user" ln -rsf /var/cache/pacman/aurto/aurto.db{.tar.zst,}

if ! test -f /etc/aurto/trusted-users; then
echo 'aurto: Adding default trusted users -> /etc/aurto/trusted-users' >&2
@@ -94,4 +95,4 @@ elif [[ $command == "remove" ]]; then
else
echo "unknown command: $command" >&2
exit 1
fi
fi
4 changes: 2 additions & 2 deletions trust-check/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.