Difference between revisions of "Talk:VCS package guidelines"

From ArchWiki
Jump to: navigation, search
(Clarifying the first Git function)
(More on git pkgver()'s)
(34 intermediate revisions by 9 users not shown)
Line 2: Line 2:
  
 
Could we consider a guideline to use firewall-friendly protocols when possible (e.g. https://github.com/matplotlib/matplotlib.git instead of git://github.com/matplotlib/matplotlib.git)?
 
Could we consider a guideline to use firewall-friendly protocols when possible (e.g. https://github.com/matplotlib/matplotlib.git instead of git://github.com/matplotlib/matplotlib.git)?
--[[User:Mitch feaster|Mitch feaster]] 14:34, 15 November 2011 (EST)
+
<br>--[[User:Mitch feaster|Mitch feaster]] 14:34, 15 November 2011 (EST)
  
 
:It shouldn't be too hard to just mention that. As I haven't heard of anybody else ever bringing it up, it'd probably be enough.
 
:It shouldn't be too hard to just mention that. As I haven't heard of anybody else ever bringing it up, it'd probably be enough.
Line 25: Line 25:
 
::::--[[User:Det|Det]] ([[User talk:Det|talk]]) 05:54, 19 May 2013 (UTC)
 
::::--[[User:Det|Det]] ([[User talk:Det|talk]]) 05:54, 19 May 2013 (UTC)
  
== Checking out branches/tags needs clarification ==
+
:::::Hmm, there were a number of patches submitted last month for cleaning up the prototypes, looks like none have been committed yet. I do remember a discussion (IRC maybe?) questioning the proper place for the prototypes, so maybe that's why? Looking at the patches, I was mistaken anyway; they didn't update the darcs or cvs prototypes. Simple enough, I'll send in a patch myself.
 +
:::::--[[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 08:22, 19 May 2013 (UTC)
  
The {{ic|#fragment}} part of the VCS source URL has a different meaning for each type of VCS.
+
: I use this dirty hack: {{ic|<nowiki>cvs history -c -a | cut -d' ' -f2 | sort -u | tail -n 1 | sed 's|-||g"</nowiki>}} ; could probably be improved.
This can be confusing for people, especially when they are trying to checkout a specific branch or tag.
+
:--[[User:Buhman|Buhman]] ([[User talk:Buhman|talk]]) 18:00, 6 June 2013 (UTC)
Examples would reduce the chance for confusion a lot.
+
 
+
fictional examples for git and svn (don't have experience with bzr or HG)
+
 
+
check out branch {{ic|git_test}} of git://myproject.com into folder {{ic|my_git_code}} :
+
my_git_code::git://myproject.com/'''#branch=git_test'''
+
 
+
Check out branch {{ic|svn_test}} of svn://myproject.com into folder {{ic|my_svn_code}} :
+
my_svn_code::svn://myproject.com/'''branches/svn_test'''
+
 
+
[[User:Lone Wolf|Lone_Wolf]] ([[User talk:Lone Wolf|talk]]) 20:49, 16 April 2013 (UTC)
+
 
+
:Makes sense. At least for those two.
+
:--[[User:Det|Det]] ([[User talk:Det|talk]]) 22:53, 2 May 2013 (UTC)
+
  
 
== More on git pkgver()'s ==
 
== More on git pkgver()'s ==
Line 66: Line 53:
  
 
[[User:KaiSforza|KaiSforza]] ([[User talk:KaiSforza|talk]]) 20:42, 18 April 2013 (UTC)
 
[[User:KaiSforza|KaiSforza]] ([[User talk:KaiSforza|talk]]) 20:42, 18 April 2013 (UTC)
 +
 +
: What about using following sed {{ic|sed 's/-/.r/; s/-g/./'}} it is shorter than what you proposed and seems work the same way.
 +
:[[User:Anatolik|Anatolik]] ([[User talk:Anatolik|talk]]) 03:53, 12 January 2014 (UTC)
 +
 +
:: It will work with some repos, but not all. What if the tag has a dash in it?
 +
:: [[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 05:50, 12 January 2014 (UTC)
 +
 +
::: From my experience most of the tags do not contain any dashes and simpler sed expression can be used. There are some projects that use dashes e.g. {{ic|1.2-alpha}} and in this case you are right - the more complicated sed expression should be used to handle it correctly.
 +
::: [[User:Anatolik|Anatolik]] ([[User talk:Anatolik|talk]]) 20:19, 12 January 2014 (UTC)
  
 
:So Git makes some projects jump down from {{ic|x.x.x.210}} to {{ic|x.x.x.x.50}}? Is that really intended behavior?
 
:So Git makes some projects jump down from {{ic|x.x.x.210}} to {{ic|x.x.x.x.50}}? Is that really intended behavior?
Line 82: Line 78:
 
:::::--[[User:Det|Det]] ([[User talk:Det|talk]]) 05:57, 19 May 2013 (UTC)
 
:::::--[[User:Det|Det]] ([[User talk:Det|talk]]) 05:57, 19 May 2013 (UTC)
  
== Clarifying the first Git function ==
+
:I have the same issue with {{AUR|tup-git}} package that bumped its version from {{ic|0.6}} to {{ic|0.6.5}}. previously generated version was {{ic|0.6.350.gfoobar}} now it became {{ic|0.6.5}} that is smaller than previous. Generated version should split upstream version from {{ic|git describe}} version. My vote is goes to {{ic|~}} delimiter proposed above. Or maybe we can use {{ic|-}} as delimiter?
Instead of just {{ic|<nowiki>sed 's|-|.|g'</nowiki>}} it'd probably be better to give some example with {{ic|cut}} (which you're probably gonna end up using anyway) and {{ic|tr}} (which is simpler than {{ic|sed}}). Then you could either explain it like this or just mention the man pages: ''"{{ic|cut -d "-" -f2-}} cuts from the first hyphen (-) to the end, {{ic|tr - .}} converts hyphens to dots (.) and {{ic|tr -d -}} removes the hyphens"''.
+
:--[[User:Anatolik|Anatolik]] ([[User talk:Anatolik|talk]]) 11:43, 17 Jun 2013 (UTC)
 +
 
 +
::You can't have a {{ic|-}} in the pkgver, so that's out. {{ic|~}} is an option, but I kind of like the suggested {{ic|.r}}. Seems cleaner to me.
 +
::[[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 16:47, 26 July 2013 (UTC)
 +
 
 +
:::{{ic|r}} prefix is fine with me. We also need to cut leading {{ic|v}} from the version returned by git. Here is slightly modified {{ic|pkgver()}} used by {{AUR|tup-git}} package {{ic|<nowiki>git describe | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'</nowiki>}}
 +
:::--[[User:Anatolik|Anatolik]] ([[User talk:Anatolik|talk]]) 6:13, 26 Sep 2013 (UTC)
 +
 
 +
::::I'd like to see a more visible separator between the different parts of the version number, I suggest {{ic|+}} <br />{{ic|<nowiki>git describe | sed -E 's/^v//;s/-([^-]*-g)/+r\1/;s/-/+/g'</nowiki>}}
 +
::::[[User:Progandy|Progandy]] ([[User talk:Progandy|talk]]) 19:40, 21 February 2014 (UTC)
 +
 
 +
== pkgver function for hg based on tags ==
 +
 
 +
I recent came across a way with hg to show the most recent tag, as well as the number of commits from this tag (similar to the output of {{ic|git describe}}.)
  
Example:
 
 
{{hc|<nowiki>pkgver() {
 
{{hc|<nowiki>pkgver() {
 
   cd local_repo
 
   cd local_repo
   git describe --always | cut -d "-" -f2- | tr - .
+
   hg log -r . --template '{latesttag}.{latesttagdistance}.{node|short}\n'
 
}</nowiki>|
 
}</nowiki>|
2.0.6.a17a017
+
3.0.1.40.ee9a2543fcd6
 
}}
 
}}
{{Note|See the man pages of [http://unixhelp.ed.ac.uk/CGI/man-cgi?cut cut(1)] and [http://unixhelp.ed.ac.uk/CGI/man-cgi?tr+1 tr(1)] for more info.}}
 
--[[User:Det|Det]] ([[User talk:Det|talk]]) 00:22, 3 May 2013 (UTC)
 
  
:Did you test this before posting? It doesn't do anything like you think it does. [[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 22:29, 4 May 2013 (UTC)
+
Please could this be included in the page.
  
::Well, my friend, that's what makes it an ''example''. The reason I'm using {{ic|cut}} is to remove the actual project names that are often included in their tags. All the sed example does is change the hyphens ({{ic|-}}) to dots ({{ic|.}}), which is simpler to do with {{ic|tr - .}} anyway.
+
[[User:Garyvdm|Garyvdm]] ([[User talk:Garyvdm|talk]]) 09:03, 23 July 2013 (UTC)
  
::What _makes_ it so hard is that there ''isn't'' a single solution that somehow magicly worked on all scenarios. Even if you decided to be clever and started cutting the output up until the first number (with something like {{ic|$ sed 's/\([^0-9]*\)\(.*\)/\2/g'}}), you'd still end up with the wrong result whenever the "version" starts with a letter or the project name ends with a number.
+
== git pkgver: Date of last commit at the beginning of the version number for compatibility with older PKGBUILDs from AUR? ==
::--[[User:Det|Det]] ([[User talk:Det|talk]]) 21:04, 7 May 2013 (UTC)
+
  
:::Ah, I see now, you were addressing a special case. You're right, there ''isn't'' a single solution. You're also right that {{ic|tr}} is simpler and should probably be used in the example if that's all the example is going to show. It seems to be fairly common, though, to include a "v" at the beginning of the version number, in which case you'd already be using {{ic|sed}} anyway so you can just do {{ic|sed 's/^v//;s/-/./g'}} So many ways  of doing the same job. [[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 02:15, 8 May 2013 (UTC)
+
We have quite a bunch of older PKGBUILDs for -git packages in AUR which still work but which do not have a pkgver function yet. Many of these actually carry a date as version number (mostly the date of the last git commit at the time when the PKGBUILD was last updated).
  
::::That only works when they do. It doesn't remove the names from the tags, which are included in things like Wine and the entire X stack.
+
When you update these scripts to use one of the two pkgver functions suggested on the wiki page, AUR helpers like packer will (in most cases) suggest that there is a newer version in AUR on every system update. My proposal to solve this problem is a pkgver function which precedes the generated version number with the date of the last git commit:
::::{{ic|<nowiki>git describe --always | sed 's/\([^0-9]*\)\(.*\)/\2/g; s/-/./g'</nowiki>}} is the most universal approach I can think of. But it's totally unreadable and a damn lot harder to edit than some {{ic|cut}}/{{ic|tr}} example.
+
:::: --[[User:Det|Det]] ([[User talk:Det|talk]]) 20:37, 14 May 2013 (UTC)
+
  
:::::Yeah, my example was a special case as well. I'm really thinking that this is a situation where it's best just to include a very simple example and let the maintainer customize it as needed instead of trying to find a convoluted solution that works everywhere.
+
{{bc|<nowiki>
::::: -- [[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 07:11, 15 May 2013 (UTC)
+
pkgver() {
 +
cd "${_pkgname}"
 +
echo $(git log -n 1 --date=short | sed -nr 's|^Date:\s+([0-9]{4})-([0-9]{2})-([0-9]{2})$|\1\2\3|p').$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
 +
}
 +
</nowiki>}}
  
::::::In that sense the current one is pretty fitting, but it sort of gives the impression that it works "right away", which it doesn't. So at least a note for probably having to do something yourself would be good.
+
This function is *not* intended to go into PKGBUILDs in AUR, but could be proposed as a temporary "local" fix in the wiki for the period of time until the package maintainer has found time to update his PKGBUILD in AUR.
::::::--[[User:Det|Det]] ([[User talk:Det|talk]]) 06:03, 19 May 2013 (UTC)
+
 
 +
--[[User:Hardfalcon|Hardfalcon]] ([[User talk:Hardfalcon|talk]]) 21:22, 17 August 2013 (UTC)
 +
:Since it's just a local workaround, why not just hardcode a larger number in there? If you want the date of the last commit, I would suggest awk as being easier to use and to read/understand
 +
git log -n 1 --date=short | awk '/Date/ {gsub ("-",""); print $2}'
 +
:[[User:Scimmia|Scimmia]] ([[User talk:Scimmia|talk]]) 05:29, 18 August 2013 (UTC)
 +
 
 +
== shorten hg version ==
 +
 
 +
To prevent long package file name,
 +
It is proper to use this format
 +
 
 +
{{bc|<nowiki>pkgver() {
 +
  cd $_repo
 +
  _id=$(hg identify -i)
 +
  echo $(hg identify -n).${_id:0:4}
 +
}</nowiki>
 +
}}
 +
--[[User:Dlin|Dlin]] ([[User talk:Dlin|talk]]) 05:30, 26 August 2013 (UTC)
 +
 
 +
== fossil  ==
 +
 
 +
{{bc|<nowiki>pkgver() {
 +
  cd local_repo
 +
  _id=$(cat manifest.uuid 2>/dev/null)
 +
  echo ${_id:0:4}
 +
}</nowiki>
 +
}}
 +
--[[User:Dlin|Dlin]] ([[User talk:Dlin|talk]]) 05:36, 26 August 2013 (UTC)

Revision as of 19:40, 21 February 2014

https:// vs git://

Could we consider a guideline to use firewall-friendly protocols when possible (e.g. https://github.com/matplotlib/matplotlib.git instead of git://github.com/matplotlib/matplotlib.git)?
--Mitch feaster 14:34, 15 November 2011 (EST)

It shouldn't be too hard to just mention that. As I haven't heard of anybody else ever bringing it up, it'd probably be enough.
--Det (talk) 22:51, 2 May 2013 (UTC)

Updating a CVS repo

I don't use cvs. How can you describe the pkgver for cvs (for pacman 4.1)?
-- Dracorp (talk) 09:31, 6 April 2013 (UTC)

CVS is not supported in pacman 4.1 like the other VCS tools. You will need to update pkgver manually until CVS support is added.
-- Jstjohn (talk) 22:44, 15 April 2013 (UTC)
Yeah, but how about mentioning that in the article (as well as giving a download example)? Even if it's not that common anymore.
--Det (talk) 22:39, 2 May 2013 (UTC)
The download example can still be found in /usr/share/pacman/. The next version of the ABS package should update it a bit so the download happens in the prepare function where it belongs. As for pkgver, I think the generic example using date covers that, as there's not a way to get a version number from a CVS repo. Maybe a note to that effect?
-- Scimmia (talk) 07:17, 15 May 2013 (UTC)
That makes the most sense, but it might also be a good idea to rename the "Fallback" section to something like "Fallback / CVS" to make it more obvious even when you're just checking out the table of contents.
But as for ABS, as far as I can tell the last commit was over 8 months ago.
--Det (talk) 05:54, 19 May 2013 (UTC)
Hmm, there were a number of patches submitted last month for cleaning up the prototypes, looks like none have been committed yet. I do remember a discussion (IRC maybe?) questioning the proper place for the prototypes, so maybe that's why? Looking at the patches, I was mistaken anyway; they didn't update the darcs or cvs prototypes. Simple enough, I'll send in a patch myself.
--Scimmia (talk) 08:22, 19 May 2013 (UTC)
I use this dirty hack: cvs history -c -a | cut -d' ' -f2 | sort -u | tail -n 1 | sed 's|-||g" ; could probably be improved.
--Buhman (talk) 18:00, 6 June 2013 (UTC)

More on git pkgver()'s

I would also like to see packages use pkgver functions like this:

git describe --always --long | sed -E 's/([^-]*-g)/r\1/;s/-/./g'

so they are more friendly to vercmp. Current behaviour using git-git as an example:

current ver: 1.8.2.210.g123abc-1 next ver: 1.8.2.1.50.g123abc-1

vercmp 1.8.2.210.g123abc 1.8.2.1.50.g123abc
1 # the first is greater than the second

Right now, the current version is actually greater than the new version, causing a downgrade. If r is appended to the patch level (the numbers just before the g<hex> bit), then vercmp would order the versions correctly.

current ver: 1.8.2.r210.g123abc-1 next ver: 1.8.2.1.r50.g123abc-1

vercmp 1.8.2.r210.g123abc 1.8.2.1.r50.g123abc
-1 # the first is less than the second

KaiSforza (talk) 20:42, 18 April 2013 (UTC)

What about using following sed sed 's/-/.r/; s/-g/./' it is shorter than what you proposed and seems work the same way.
Anatolik (talk) 03:53, 12 January 2014 (UTC)
It will work with some repos, but not all. What if the tag has a dash in it?
Scimmia (talk) 05:50, 12 January 2014 (UTC)
From my experience most of the tags do not contain any dashes and simpler sed expression can be used. There are some projects that use dashes e.g. 1.2-alpha and in this case you are right - the more complicated sed expression should be used to handle it correctly.
Anatolik (talk) 20:19, 12 January 2014 (UTC)
So Git makes some projects jump down from x.x.x.210 to x.x.x.x.50? Is that really intended behavior?
--Det (talk) 22:48, 2 May 2013 (UTC)
Yes, that's intended behavior. That number is the number of commits since the last tag, so it will reset every time the author tags a new commit.
Scimmia (talk) 08:02, 4 May 2013 (UTC)
I noticed just now there's the .1.
--Det (talk) 20:44, 14 May 2013 (UTC)
Why not make the change for use .r or ~ instead from the actual . for prevent that problem
--Jristz (talk) 18:52, 17 May 2013 (UTC)
Well, that's what's being suggested..
--Det (talk) 05:57, 19 May 2013 (UTC)
I have the same issue with tup-gitAUR package that bumped its version from 0.6 to 0.6.5. previously generated version was 0.6.350.gfoobar now it became 0.6.5 that is smaller than previous. Generated version should split upstream version from git describe version. My vote is goes to ~ delimiter proposed above. Or maybe we can use - as delimiter?
--Anatolik (talk) 11:43, 17 Jun 2013 (UTC)
You can't have a - in the pkgver, so that's out. ~ is an option, but I kind of like the suggested .r. Seems cleaner to me.
Scimmia (talk) 16:47, 26 July 2013 (UTC)
r prefix is fine with me. We also need to cut leading v from the version returned by git. Here is slightly modified pkgver() used by tup-gitAUR package git describe | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
--Anatolik (talk) 6:13, 26 Sep 2013 (UTC)
I'd like to see a more visible separator between the different parts of the version number, I suggest +
git describe | sed -E 's/^v//;s/-([^-]*-g)/+r\1/;s/-/+/g'
Progandy (talk) 19:40, 21 February 2014 (UTC)

pkgver function for hg based on tags

I recent came across a way with hg to show the most recent tag, as well as the number of commits from this tag (similar to the output of git describe.)

pkgver() {
  cd local_repo
  hg log -r . --template '{latesttag}.{latesttagdistance}.{node|short}\n'
}
3.0.1.40.ee9a2543fcd6

Please could this be included in the page.

Garyvdm (talk) 09:03, 23 July 2013 (UTC)

git pkgver: Date of last commit at the beginning of the version number for compatibility with older PKGBUILDs from AUR?

We have quite a bunch of older PKGBUILDs for -git packages in AUR which still work but which do not have a pkgver function yet. Many of these actually carry a date as version number (mostly the date of the last git commit at the time when the PKGBUILD was last updated).

When you update these scripts to use one of the two pkgver functions suggested on the wiki page, AUR helpers like packer will (in most cases) suggest that there is a newer version in AUR on every system update. My proposal to solve this problem is a pkgver function which precedes the generated version number with the date of the last git commit:

pkgver() {
	cd "${_pkgname}"
	echo $(git log -n 1 --date=short | sed -nr 's|^Date:\s+([0-9]{4})-([0-9]{2})-([0-9]{2})$|\1\2\3|p').$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

This function is *not* intended to go into PKGBUILDs in AUR, but could be proposed as a temporary "local" fix in the wiki for the period of time until the package maintainer has found time to update his PKGBUILD in AUR.

--Hardfalcon (talk) 21:22, 17 August 2013 (UTC)

Since it's just a local workaround, why not just hardcode a larger number in there? If you want the date of the last commit, I would suggest awk as being easier to use and to read/understand
git log -n 1 --date=short | awk '/Date/ {gsub ("-",""); print $2}'
Scimmia (talk) 05:29, 18 August 2013 (UTC)

shorten hg version

To prevent long package file name, It is proper to use this format

pkgver() {
  cd $_repo
  _id=$(hg identify -i)
  echo $(hg identify -n).${_id:0:4}
}

--Dlin (talk) 05:30, 26 August 2013 (UTC)

fossil

pkgver() {
  cd local_repo
  _id=$(cat manifest.uuid 2>/dev/null)
  echo ${_id:0:4}
}

--Dlin (talk) 05:36, 26 August 2013 (UTC)