Moving.
]]>In order to determine the base-package name, the only way I know is to parse the qt5-base package webpage. This is possible, but requires an extra download step for every single package, which slows the process. Is there an alternative way that won't require an extra download step? I couldn't seem to find this information in `pacman -S` anywhere.
]]>That looks good, I might even use it sometimes too :-) Good work!
Thank you! And thanks for the help. I've uploaded it to AUR, in case it's useful to anyone else.
I found one little improvement/simplification I overlooked before.
Nice! I've modified the script appropriately.
]]>Thanks for all your help! I've written a small script to output the last commit messages for a package. I've also included a flag (-l) to only show the last x commits.
That looks good, I might even use it sometimes too :-) Good work!
I found one little improvement/simplification I overlooked before. To find the correct repo, -Sp can be used with --print-format to give the repo name directly (instead of -Ss and sed):
# Determine which repository package is from, and build url
repo=$(pacman -Sp --print-format %r ${1} 2>/dev/null)
#!/usr/bin/env bash
# Output the comments for the last commits of a package (specified as the script's argument)
# Optionally, only display the first NUM commits, with -l NUM.
# Define usage.
usage() {
cat >&2 <<EOF
Usage: $0 [-l NUM] PACKAGE_NAME | -h
-l NUM optionally, only display NUM latest entries
-h display this help text and exit
EOF
exit 1
}
# Parse options.
while getopts 'l:h' opt; do
case "${opt}" in
l) length=$OPTARG ;;
*) usage ;;
esac
done
# Check -l argument. If $length is empty, then equivalent to flag never being specified. Zero is okay (NOP), negative is not.
if ! [[ $length =~ ^[0-9]*$ ]]; then
echo 'ERROR: wrong argument supplied to -l'
exit 1
fi
shift $((OPTIND-1))
# Check primary argument(s)
if [[ $# != 1 ]]; then
echo 'ERROR: specify a single package as argument'
exit 1
fi
# Determine which repository package is from, and build url
repo=$(pacman -Ss ^${1}$ | sed 's|/.*||;q')
case $repo in
core|extra|testing)
pre_url='https://projects.archlinux.org/svntogit/packages.git/log/trunk?h=packages/'
;;
community|multilib)
pre_url='https://projects.archlinux.org/svntogit/community.git/log/trunk?h=packages/'
;;
'') # AUR or package not found
pre_url='https://aur.archlinux.org/cgit/aur.git/log/?h='
;;
*)
echo "ERROR: Unknown repository returned (\"${repo}\")" >&2
exit 1
;;
esac
post_url='&showmsg=1'
# Parse commit log
output=$(w3m -dump "${pre_url}${1}${post_url}" | sed -n '/Commit message/,/^\s*$/p')
# Check for presence of log
if [ -z "$output" ]; then
echo "ERROR: no log found for ${1}"
exit 1
fi
# Truncate if necessary
if [ -z $length ]; then
echo "$output"
else
<<<"$output" gawk -v l=$length 'BEGIN {nth=0}; /^\s/ {print; next} {if (nth == l){exit} else {print}; nth++}'
fi
Would there be a way to not have to look up the repository as well?
Sure, just ask pacman:
pacman -Ss '^mesa$' | sed 's|/.*||;q'
It returns repository name (core, extra, community, ...). If it returns nothing, then the package doesn't exist in repositories, which means it either doesn't exist at all or it is from AUR. You can write a simple case statement in your script to figure out the correct url based on this.
]]>However, it seems that one problem with all of these methods is that you need to know which repository they are from. For example, I tried the commands on notmuch's recent update. However, because it's in the [community] repo, I had to change the path/url a little. Would there be a way to not have to look up the repository as well?
]]>dolik.rce wrote:But the repository is quite huge and there is no simple way to clone only single package. So you'd always have to download the entire thing, which is definitely not what you want.
It is possible to clone single packages. Each package has its own branch and you only have to fetch the branche you are interested in, not the whole repository. There is even a tool that helps with it.
https://aur.archlinux.org/packages/asp-git/
Oh, I didn't know the repository was organized this way. So the script could be
git clone --single-branch -b packages/mesa git://projects.archlinux.org/svntogit/packages.git
cd packages
git log -- trunk
But it still doesn't feel right to download it locally. I'd still prefer the w3m way I mentioned in my first post.
]]>But the repository is quite huge and there is no simple way to clone only single package. So you'd always have to download the entire thing, which is definitely not what you want.
It is possible to clone single packages. Each package has its own branch and you only have to fetch the branche you are interested in, not the whole repository. There is even a tool that helps with it.
https://aur.archlinux.org/packages/asp-git/
I could clone the svn repo, and I get the logs from that.
Actually, you don't need to clone it at all. With subversion, you can get the history directly from the remote server:
svn checkout --depth=empty svn://svn.archlinux.org/packages
However, I couldn't quite work out how to clone the git repos. I couldn't find a reference to that in the wiki. Probably getting remote git logs would be more efficient than the svn route. I'll also see how the web scraper version compares.
There is no way to get remote git log in the way you can do it with subversion. The closest you could do is similar to your previous approach with svn:
git clone git://projects.archlinux.org/svntogit/packages.git packages
cd pacakges
git log -- mesa
But the repository is quite huge and there is no simple way to clone only single package. So you'd always have to download the entire thing, which is definitely not what you want.
]]>You either have to clone the git repo and search for the commit messages inside that or you'll have to write a web scraper. Another option is to use the atom feed for the packages.
Thank you for the ideas. I could clone the svn repo, and I get the logs from that.
$ svn checkout --depth=empty svn://svn.archlinux.org/packages
Checked out revision 257362.
$ cd packages
$ svn update mesa
...
$ svn log mesa -l 2
------------------------------------------------------------------------
r257308 | lcarlier | 2015-12-28 08:27:21 +1100 (Mon, 28 Dec 2015) | 1 line
archrelease: copy trunk to extra-i686, extra-x86_64
------------------------------------------------------------------------
r257307 | lcarlier | 2015-12-28 08:26:19 +1100 (Mon, 28 Dec 2015) | 3 lines
upgpkg: mesa 11.1.0-2
Add libgcrypt dependency (FS#47540)
------------------------------------------------------------------------
This seems workable, and I could wrap it in a script, but the svn logs seem slightly less "clean" than the git logs. In the latter, the latest entry is "Add libgcrypt dependency", and there is no entry for the extraneous "copy trunk to…". However, I couldn't quite work out how to clone the git repos. I couldn't find a reference to that in the wiki. Probably getting remote git logs would be more efficient than the svn route. I'll also see how the web scraper version compares.
You can get the latest commit messages from the web in command line.
Thank you for the code. This works well. I'll check out the other options, but this might be best.
]]># for Arch packages:
w3m -dump 'https://projects.archlinux.org/svntogit/packages.git/log/trunk?h=packages/mesa&showmsg=1' | sed -n '/Commit message/,/^\s*$/p'
# for packages from AUR:
w3m -dump 'https://aur.archlinux.org/cgit/aur.git/log/?h=debootstrap&showmsg=1' | sed -n '/Commit message/,/^\s*$/p'
It is probably possible to do this also using links, lynx, eLinks or any other console based web browser.
]]>