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

Added a "--repo <file>" option #58

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
40 changes: 29 additions & 11 deletions packer
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ usage() {
echo ' --auronly - only do actions for aur'
echo ' --devel - update devel packages during -Su'
echo ' --skipinteg - when using makepkg, do not check md5s'
echo ' --repo - specify a local repository to update'
echo ' -h - outputs this message'
exit
}
Expand Down Expand Up @@ -287,15 +288,19 @@ aurinstall() {
. PKGBUILD
confirm_edit "${COLOR6}Edit $install with \$EDITOR? [Y/n]${ENDCOLOR} " "$install"

# Installation (makepkg and pacman)
# Build
if [[ $UID -eq 0 ]]; then
makepkg $MAKEPKGOPTS --asroot -f
else
makepkg $MAKEPKGOPTS -f
fi

[[ $? -ne 0 ]] && echo "The build failed." && return 1
if [[ $2 = dependency ]]; then

# Install
if [[ $repofile ]]; then
cp -t "$(dirname "$repofile")" $pkgname-*$PKGEXT
repo-add "$repofile" $pkgname-*$PKGEXT
elif [[ $2 = dependency ]]; then
runasroot pacman ${PACOPTS[@]} --asdeps -U $pkgname-*$PKGEXT
elif [[ $2 = explicit ]]; then
runasroot pacman ${PACOPTS[@]} -U $pkgname-*$PKGEXT
Expand Down Expand Up @@ -357,14 +362,16 @@ installhandling() {
exit
fi
# Test if aurpackages are already installed; echo warning if so
for pkg in "${aurtargets[@]}"; do
if existsinlocal "$pkg"; then
localversion="$(pacman -Qs "$pkg" | grep -F "local/$pkg" | cut -d ' ' -f 2)"
if ! aurversionisnewer "$pkg" "$localversion"; then
echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling"
if ! [[ $repofile ]]; then
for pkg in "${aurtargets[@]}"; do
if existsinlocal "$pkg"; then
localversion="$(pacman -Qs "$pkg" | grep -F "local/$pkg" | cut -d ' ' -f 2)"
if ! aurversionisnewer "$pkg" "$localversion"; then
echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling"
fi
fi
fi
done
done
fi

# Echo warning if packages are out of date
for pkg in "${aurtargets[@]}" "${aurdepends[@]}"; do
Expand Down Expand Up @@ -454,6 +461,7 @@ while [[ $1 ]]; do
'--auronly') auronly='1' ;;
'--devel') devel='1' ;;
'--skipinteg') MAKEPKGOPTS="--skipinteg" ;;
'--repo') repofile=$(readlink -m "$2") ; auronly='1' ; shift ;;
'--') shift ; packageargs+=("$@") ; break ;;
-*) echo "packer: Option \`$1' is not valid." ; exit 5 ;;
*) packageargs+=("$1") ;;
Expand Down Expand Up @@ -483,7 +491,17 @@ if [[ $option = update ]]; then
# Aur update
echo -e "${COLOR5}:: ${COLOR1}Synchronizing aur database...${ENDCOLOR}"
IFS=$'\n'
packages=( $(pacman -Qm) )
packages=()
if [[ $repofile ]]; then
repodescs=( $(tar tzf $repofile | grep -e "/desc$") )
for repodesc in "${repodescs[@]}"; do
pkg=$(tar xzOf "$repofile" "$repodesc" | awk '/^%NAME%$/ { getline; print $0 }')
ver=$(tar xzOf "$repofile" "$repodesc" | awk '/^%VERSION%$/ { getline; print $0 }')
packages+=( "$pkg $ver" )
done
else
packages+=( $(pacman -Qm) )
fi
newpackages=()
checkignores=()
total="${#packages[@]}"
Expand Down