You are not logged in.

#1 2009-12-31 08:26:20

dalingrin
Member
Registered: 2009-03-18
Posts: 128

pbfetch - Please not another AUR frontend

pbfetch is an AUR frontend and optionally a Pacman wrapper.

Background and Motivation
I originally intended to keep pbfetch private, as there are already so many AUR frontends but, after using it for a bit I've decided to let others use, change, belittle, mock, praise and/or look at it.
pbfetch(PKGBUILD fetch) started as merely a script to download a PKGBUILD from the AUR. I usually like to edit and run makepkg myself for AUR packages, however, there are times where I like a simple
automated approach. With all due respect to the developers, I found yaourt to be slow(especially on my old laptop). After seeing how complicated yaourt has become I decided to extend pbfetch to encompass most if not all
my Arch package managment needs.

Features
[Current]
- Can optionally wrap pacman functionality so one can use pbfetch for most pacman commands(eg. pbfetch -Sy, pbfetch -Qs, pbfetch -Rd)
- Search AUR
- Download and extract AUR tar.gz to build directory
- Option to edit PKGBUILD after download
- Option to make the package with or without installing
- Dependecy checking(mostly complete, though removes versioning for dependencies not found in official repos)
- Check for and install AUR updates
- Option to choose which AUR updates to install
- Optional color output
- By default uses sudo where needed
[Todo]
- Refactoring for readabilty and speed(already much faster than yaourt)
- Further ABS support(currently only copies local abs pkg directory to build directory)
- Better commandline option parsing(possibly getopts)
- Add edit PKGBUILD option to pacman fallback commands(currently auto-edit only with AUR specific commands)
- Prettier text output
- Willing to consider any requests


Overview
I had two types of users in mind as I made/make pbfetch.
1.) Those who prefer to have 1 tool to manage AUR and official repositories
2.) Those who prefer to keep their AUR frontend separate from Pacman

As such there are two sets of command line options: those that are AUR specific, and optionally, commands that call the pacman binary and extend for AUR functions.
I have chosen to call pacman directly where ever possible rather than reimpliment pacman's functions.
The following is a copy of pbfetch's usage prompt:

Usage: pbfetch [opiton] [package1] [package2] ....

  options:
    -d  Download from aur and extract to build directory
    -de Download from aur, extract and edit PKGBUILD
    -m  Download from aur, extract, and make the package(s)
    -me Download from aur, extract, edit PKGBUILD and
        make the package(s)
    -i  Download from aur, extract, make and install package(s)
    -ie Download from aur, extract, edit PKGBUILD, make and
        install package(s)
    -s  Search aur for any package given
        (Searches name and description)
    -sa Search repo and aur for any package given
    -u  Check aur for package updates
    -ue Check aur for package updates and 
        edit PKGBUILD before install
    -ua Check aur and official repos for updates
    -abs Copy from local abs folder to build directory
    -v  Display version information


  Pacman Fallback(On by default)
    options:
      -S Attempt install with Pacman if package not found
         in repo then install from AUR
      -Ss Search Pacman repos and AUR
      -Sy Refresh database then install from repo or
          AUR if not found in repository
      -Syu --aur  Refresh database and upgrade from repo and
           AUR

Example: pbfetch -S xorg
         pbfetch -d nvidia-beta nvidia-utils-beta


  pbfetch will also pass any pacman related options to the 
  pacman binary specifed in the script, eg. pbfetch -Qs

[Configuration]
The config file is stored in /etc/pbfetch.conf
There you can set whether to enable color output, pacman fallback, various working directories etc.
The pacman binary can be specified as well.(Tested with pacman and pacman-color)
Default build directory is ~/build/


[Notes]
- pbfetch can be called just like pacman and it will pass the command line options untouch if you prefer. Or it can extend pacman's sync to include AUR processing. This is set in the configuration.

- When checking for AUR updates (eg. pbfetch -u, or pbfetch -Syu --aur) you will be prompted to either accept the updates or you may opt to only choose certain updates. To choose, type the number as seen next
  to the corresponding update. Separate each respective package number by a space.

[Known or potential caveats]
- All verbose options such as "--needed" are passed to pacman untouched. However some of the short hand versions have not been implemented when using sync (eg. pbfetch -Sg xorg) in combination with the fallback option set.
- I've written the script with sudo in mind. The script inserts sudo where needed.
- Color output assumes dark terminal background. Color can either be turned off or individual colors and be changed in the config file
- pbfetch was made in my limited free time over the last month so testing of features has been limited to say the least.

[Development]
- I have put pbfetch up on github @ http://github.com/dalingrin/pbfetch
- Please feel free contribute or make requests

Make no mistake, I have no dreams of pbfetch becoming the next popular AUR frontend like yaourt. I have had fun writing it so far (first bash script) and thought a few like minded individual(s) may enjoy using it as well.

Package can be found @ http://aur.archlinux.org/packages.php?ID=33256

Last edited by dalingrin (2010-09-13 21:58:27)

Offline

#2 2010-01-03 04:35:49

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: pbfetch - Please not another AUR frontend

Update: Fixed bug in AUR search output order. Search output should be sorted by package name.

Offline

#3 2010-01-03 05:59:52

Kasumi_Ninja
Member
Registered: 2009-12-31
Posts: 54

Re: pbfetch - Please not another AUR frontend

This looks exactly what I was searching for smile Thanks for sharing!

Offline

#4 2010-01-03 06:20:38

Kasumi_Ninja
Member
Registered: 2009-12-31
Posts: 54

Re: pbfetch - Please not another AUR frontend

I have disabled sudo, still I get the following error:

pbfetch -me qhandbrake-git

==> qhandbrake-git [Downloaded]
==> qhandbrake-git [Extracted]
  -> qhandbrake-git [Edit complete]

Checking package for AUR dependencies...
==> ERROR: Cannot find the sudo binary! Is sudo installed?
    Missing dependencies cannot be installed or removed as a normal user
    without sudo; install and configure sudo to auto-resolve dependencies.

cat /etc/pbfetch.conf

#!/bin/bash

################## !WARNING! ####################
#################################################
# This file must contain only valid bash syntax #
#################################################



#####################################
#### Pacman sync fallback to AUR ####
#####################################
fallback=true
#fallback=false

#########################################
#### Clean up after package building ####
#########################################
# if false then package along with source
# will be left in the build directory
clean=true
#clean=false

#########################
#### Colorize output ####
#########################
color=true
#color=false

# default colors
color1="\e[1;37m" # white
color2="\e[1;34m" # blue
color3="\e[1;31m" # red
color4="\e[1;32m" # green
color5="\e[1;33m" # yellow
color6="\e[1;35m" # magenta


#######################
#### Pacman binary ####
#######################
pacmanBin="pacman"
#pacmanBin="pacman-color" # Recommend if using color output

############################################
#### Automatically use sudo when needed ####
############################################
#useSudo=true
useSudo=false

#########################
#### PKGBUILD editor ####
#########################
editor="nano"
#editor="gvim"

#########################
#### BUILD DIRECTORY ####
#########################
buildDir=~/build

##############################
#### PACMAN PACKAGE CACHE ####
##############################
pkgCache=/var/cache/pacman/pkg/

#############################
#### LOCAL abs DIRECTORY ####
#############################
abs="/var/abs"

#################
#### aur URL ####
#################
aur="http://aur.archlinux.org/packages"

Offline

#5 2010-01-03 06:26:42

humanzoo
Member
Registered: 2007-10-14
Posts: 28

Re: pbfetch - Please not another AUR frontend

This is pretty nifty. I'm finding it a nice speed improvement over yaourt. One little thing I'm running into now though:

When I check for updates to AUR packages, pbfetch reports picard-bzr has an update, even though the revision installed (1013-1) is newer than the package in AUR (978-2). I've got a number of AUR packages installed, and that's the only one doing that (thought it is the only bzr package I have installed). I tried letting it build and install the update, but it still reports there's a new update after that.

Anyway, I dig pbfetch. Thanks for making it!

Offline

#6 2010-01-03 06:47:12

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: pbfetch - Please not another AUR frontend

Kasumi_Ninja wrote:

I have disabled sudo, still I get the following error:

pbfetch -me qhandbrake-git

==> qhandbrake-git [Downloaded]
==> qhandbrake-git [Extracted]
  -> qhandbrake-git [Edit complete]

Checking package for AUR dependencies...
==> ERROR: Cannot find the sudo binary! Is sudo installed?
    Missing dependencies cannot be installed or removed as a normal user
    without sudo; install and configure sudo to auto-resolve dependencies.

This is makepkg complaining. In order for makepkg to install dependencies you must install sudo, unfortunately.
I didn't think about sudo being a requirement for 'makepkg -s.' Given this, I'll make sudo a dependency for pbfetch.

Offline

#7 2010-01-03 07:57:54

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: pbfetch - Please not another AUR frontend

Update: Version comparison fix(now using vercmp)

Offline

#8 2010-01-03 08:22:18

Kasumi_Ninja
Member
Registered: 2009-12-31
Posts: 54

Re: pbfetch - Please not another AUR frontend

dalingrin wrote:
Kasumi_Ninja wrote:

I have disabled sudo, still I get the following error:

pbfetch -me qhandbrake-git

==> qhandbrake-git [Downloaded]
==> qhandbrake-git [Extracted]
  -> qhandbrake-git [Edit complete]

Checking package for AUR dependencies...
==> ERROR: Cannot find the sudo binary! Is sudo installed?
    Missing dependencies cannot be installed or removed as a normal user
    without sudo; install and configure sudo to auto-resolve dependencies.

This is makepkg complaining. In order for makepkg to install dependencies you must install sudo, unfortunately.
I didn't think about sudo being a requirement for 'makepkg -s.' Given this, I'll make sudo a dependency for pbfetch.

That's to bad. I don't use sudo and don't intent to.

Offline

#9 2010-01-03 08:28:31

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: pbfetch - Please not another AUR frontend

So you just run it as root?
I'll look into reimplementing 'makepkg -s' functionality when I get a chance. It shouldn't be too hard given how I have it checking for AUR dependencies.

Offline

#10 2010-01-03 08:32:26

Kasumi_Ninja
Member
Registered: 2009-12-31
Posts: 54

Re: pbfetch - Please not another AUR frontend

dalingrin wrote:

So you just run it as root?
I'll look into reimplementing 'makepkg -s' functionality when I get a chance. It shouldn't be too hard given how I have it checking for AUR dependencies.

I always run 'makepkg' as a regular user.

Offline

#11 2010-01-03 08:45:34

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: pbfetch - Please not another AUR frontend

I have read _very_ little of your code. But I have some suggestions.

Your AUR search algorithm is too silly. Just search for gmpy and alephone to see what I mean.

The config file being a requirement is not a good idea. Instead, you should make buildDir fallback to current directory (or a temporary one in /tmp) if no config file is found. Otherwise, w/o a config file, the results.lst file is written to /results.lst. Also, what if there is a results.lst file in that buildDir? Although there really is no need for such a temporary file, if you insist writing it, you should put it in /tmp and make its name uniq. Read `man mktemp' for that.

Anyway, good first piece of bash.

Last edited by lolilolicon (2010-01-03 08:56:15)


This silver ladybug at line 28...

Offline

#12 2010-01-04 04:11:00

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: pbfetch - Please not another AUR frontend

Thanks for the suggestions.

[Update]
-Removed aforementioned temporary file processing.
-Removed binary searches in favor of using grep statements because of
a discrepancy in bash string comparisons and gnu sort.
-Changed how AUR updates were processed. Previously I used multiple
concurrent curl calls to get AUR package version info. pbfetch now uses one curl call
for all packages installed from AUR. Slightly slower, but no longer killing the AUR server.
Still decently fast because only one handshake required.

Update was not heavily tested because I will be out of town next week and I wanted to fix some
bugs before leaving.
So please report any bugs you find.


Another [Update]
-Added some concurrency for some minor speedups in searching and upgrading packages

Last edited by dalingrin (2010-01-04 05:31:17)

Offline

#13 2010-09-13 21:56:41

dalingrin
Member
Registered: 2009-03-18
Posts: 128

Re: pbfetch - Please not another AUR frontend

For anyone that is interested. I am back to Archlinux after an extended break.
I've updated pbfetch to better support package groups and removed the config file requirement.

Offline

Board footer

Powered by FluxBB