Bug 198869 - USE_GITHUB doesn't set WRKSRC correctly.
Summary: USE_GITHUB doesn't set WRKSRC correctly.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Bryan Drewery
URL:
Keywords:
: 198921 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-03-24 13:44 UTC by Dmitry Marakasov
Modified: 2015-03-26 09:28 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov freebsd_committer freebsd_triage 2015-03-24 13:44:00 UTC
USE_GITHUB sets WRKSRC incorrectly in some cases. For instance, see games/freeblocks with removed GH_COMMIT. After `make fetch makesum extract`:

Index: Makefile
===================================================================
--- Makefile	(revision 382055)
+++ Makefile	(working copy)
@@ -14,7 +14,7 @@
 USE_GITHUB=	yes
 GH_ACCOUNT=	dorkster
 GH_TAGNAME=	v${PORTVERSION}
-GH_COMMIT=	3c58e62
+#GH_COMMIT=	3c58e62
 
 USES=		cmake
 CMAKE_ARGS=	-DDATADIR="${DATADIR_REL}"
Index: distinfo
===================================================================
--- distinfo	(revision 382055)
+++ distinfo	(working copy)
@@ -1,2 +1,2 @@
-SHA256 (freeblocks-0.5.tar.gz) = 0d24a2b61a504e76ea71b95436272353d1e74721438b158a31706dd211866e9c
-SIZE (freeblocks-0.5.tar.gz) = 7914638
+SHA256 (dorkster-freeblocks-0.5-v0.5_GH0.tar.gz) = 8da72ccf7bcba585fcd8b65943f590f51aff06286f3ed920a13c0c90fb392e06
+SIZE (dorkster-freeblocks-0.5-v0.5_GH0.tar.gz) = 7914439

% make -V WRKSRC 
.../games/freeblocks/work/freeblocks-v0.5
% ls work
freeblocks-0.5

As I understand, github removes leading v from the tag name, so we should do the same.
Comment 1 Antoine Brodin freebsd_committer freebsd_triage 2015-03-24 13:54:34 UTC
I believe you have to use:
DISTVERSIONPREFIX=      v
instead of using GH_TAGNAME
Comment 2 Mathieu Arnold freebsd_committer freebsd_triage 2015-03-24 13:56:19 UTC
First, may I point you to the third example of the USE_GITHUB part of the porter's handbook:

https://www.freebsd.org/doc/en/books/porters-handbook/makefile-distfiles.html#makefile-master_sites-github-ex3

Then, I'd say you have a local patch:

$ make makesum extract
===>  License GPLv3 accepted by the user
===>  Found saved configuration for freeblocks-0.5
===>   freeblocks-0.5 depends on file: /usr/local/sbin/pkg - found
=> freeblocks-v0.5_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch https://codeload.github.com/dorkster/freeblocks/tar.gz/v0.5?dummy=/freeblocks-v0.5_GH0.tar.gz
freeblocks-v0.5_GH0.tar.gz                    100% of 7728 kB 2999 kBps 00m03s
===> Fetching all distfiles required by freeblocks-0.5 for building
===>  License GPLv3 accepted by the user
===>  Found saved configuration for freeblocks-0.5
===>   freeblocks-0.5 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by freeblocks-0.5 for building
===>  Extracting for freeblocks-0.5
=> SHA256 Checksum OK for freeblocks-v0.5_GH0.tar.gz.
$ make -V WRKSRC
/home/mat/ports/games/freeblocks/work/freeblocks-0.5
Comment 3 Mathieu Arnold freebsd_committer freebsd_triage 2015-03-24 14:07:01 UTC
Ah, no, sorry, you don't have a local patch, you're doing it wrong though, like antoine and I said, you should use DISTVERSIONPREFIX.
Comment 4 Bryan Drewery freebsd_committer freebsd_triage 2015-03-24 15:27:32 UTC
I'm looking
Comment 5 Bryan Drewery freebsd_committer freebsd_triage 2015-03-24 16:19:06 UTC
(In reply to Mathieu Arnold from comment #3)

While this is preferred, I do not consider it required. There is a bug here for sure. I am fixing.
Comment 6 Bryan Drewery freebsd_committer freebsd_triage 2015-03-24 16:21:32 UTC
I almost think github changed something. Downloading a tag of vVERSION is stripping the 'v' from their extraction directory. It is stupid trickery they are doing. The tag used to download (and used in the repo) does not match the extraction dir!
Comment 7 Bryan Drewery freebsd_committer freebsd_triage 2015-03-24 16:34:47 UTC
The only change was us using the main URL. Github has magic in there to determine their own filename (and extraction dir). It is in the response header as the filename, but we ignore that and use our own.

~/svn/ports/games/freeblocks # curl -LI 'https://codeload.github.com/dorkster/freeblocks/tar.gz/v0.5'
HTTP/1.1 200 OK
Content-Length: 7914439
Access-Control-Allow-Origin: https://render.githubusercontent.com
Content-Security-Policy: default-src 'none'
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
Vary: Authorization,Accept-Encoding
ETag: "3c58e62370b81d11696acf566b2a984f9837b836"
Content-Type: application/x-gzip
Content-Disposition: attachment; filename=freeblocks-0.5.tar.gz
Date: Tue, 24 Mar 2015 16:33:42 GMT


For now I will just make a GH_TAGNAME_EXTRACT and we'll maintain that as we discover other replacements they are doing.
Comment 8 Chris Hutchinson 2015-03-24 16:39:14 UTC
Not sure if this applies, but there was talk about
FreeBSD using "legacy" GITHUB API, and a need to use
the (their) current API. Try as I might, I haven't
been able to find it through a search here. But I'm
guessing it'd be fairly easy to find through a search
on @ports || @port-bugs.
The final resolution was a decision to use the new API.
Which has now been implemented. This has been within
the last 7 days. So maybe there's still some holes to
plug?

Like I said, just a thought.

--Chris
Comment 9 commit-hook freebsd_committer freebsd_triage 2015-03-24 16:43:05 UTC
A commit references this bug:

Author: bdrewery
Date: Tue Mar 24 16:42:39 UTC 2015
New revision: 382120
URL: https://svnweb.freebsd.org/changeset/ports/382120

Log:
  Github's main archive link silently is converting tags starting with 'v' to
  not have 'v' in the filename downloaded or the extraction directory. The
  filename is not an issue since we force to use DISTNAME via the ?dummy trick
  to fetch(1). Due to this though we must make the same replacement for tags
  since we are not using their filename (which matches the extraction dir).

  Incidentally this is working if DISTVERSIONPREFIX=v is used since that value
  was not used in WRKSRC.

  With hat:	portmgr
  PR:		198869

Changes:
  head/Mk/bsd.port.mk
  head/Mk/bsd.sites.mk
Comment 10 Bryan Drewery freebsd_committer freebsd_triage 2015-03-24 16:44:39 UTC
(In reply to Chris Hutchinson from comment #8)

We do use the main URL now rather than the "legacy" URL since r381618.

As for using the API we cannot since it actually just redirects to the
legacy tarball. This reverts us back to requiring GH_COMMIT even for
tagged downloads and will break portscout again.

The API link is discussed in Bug #194898.
Comment 11 Dmitry Marakasov freebsd_committer freebsd_triage 2015-03-24 17:05:51 UTC
Thank you!
Comment 12 commit-hook freebsd_committer freebsd_triage 2015-03-24 18:16:18 UTC
A commit references this bug:

Author: bdrewery
Date: Tue Mar 24 18:15:18 UTC 2015
New revision: 382149
URL: https://svnweb.freebsd.org/changeset/ports/382149

Log:
  USE_GITHUB: Tighten the GH_TAGNAME stripping of 'v' from r382120 to only do so
  for v[0-9] as Github does. If a tag is 'v.1' github will return that exact value.
  This also fixed named tags that are word starting with 'v'.

  PR:		198869
  With hat:	portmgr
  Reported by:	antoine

Changes:
  head/Mk/bsd.sites.mk
Comment 13 Johannes Jost Meixner freebsd_committer freebsd_triage 2015-03-26 09:28:54 UTC
*** Bug 198921 has been marked as a duplicate of this bug. ***