installing an older version of a port in the github era -- an answer

Fred Wright fw at fwright.net
Thu Dec 29 00:53:02 CET 2016


On Mon, 26 Dec 2016, Ken Cunningham wrote:

> So, this turns out to be a lot easier than I originally thought it
> would be, and probably is no more difficult than svn was. This may not
> be the most efficient way of doing it, but it's fairly easy to
> understand, and it works for me.
>
> Here are (perhaps too many) steps regarding how to do it.

I'd agree with the "too many" part. :-)

> Start with a local macports repository cloned from the original. To do
> this, I created a macports-ports fork using the web gui, into my local
> git account. Then created a local repository on disk by cloning that
> into /opt/macports-ports.

I guess there's nothing necessarily wrong with putting it under /opt,
though it's not where I'd choose to put it.

> cd /opt
> sudo git clone https://github.com/YOURNAME/macports-ports.git

Don't clone with sudo.  Then everything is owned by root, and you're
forced to use sudo for a bunch of other things.

> That gives you the full history of macports-ports back in time. Then use
>
> port info PORT
>
> to find the path to your port,  eg in this example case devel/libuv

It's unfortunate that there isn't a command to give you a simple
category/port relative path.

> now examine the commit history of that path to see where you want to
> go back in time to:
> sudo git log -p pathto/port

No need to use pickaxe - just use:

$ git log [options] -- pathto/port

It's typically useful to specify --oneline here.  Perhaps via the
following helper script:

MacPro:~ fw$ cat bin/git-log1
#!/bin/sh
git log --oneline "$@"
MacPro:~ fw$

That makes "git log1" a synonym for "git log --oneline".

> eg
>
> sudo git log -p devel/libuv
>
> you will see all the commits that touched this path. Keep scrolling
> until you find what you want, for example this commit looks like what
> I'm after here, which bumped the release to 1.9.1 -- so we'll go for
> that version:
[...]

If you want to see mappings from commit IDs to versions, you can do
something like the following:

MacPro:macports-ports fw$ for c in $(git log --format=%h -- devel/libuv); do echo -n "$c: "; git show $c:devel/libuv/Portfile | grep '^ *version'; done
ab66372e08:     version         20161115
3e85f8bf12:     version         20161115
c8fb1bf4f9:     version         20161115
50c2dc10f3:     version         20161025
799733665c:     version         20160923
7a4cf076fe:     version         20160917
daf59a148f:     version         20160914
5f3cbc9c2d:     version         20160830
e6e7a9d39d: version             1.8.0
0be7c6468c: version             1.7.5

> Copy that commit hash.
>
> now quit git log, and then make a new branch with that commit as the
> marker in time, for example:
[...]

You don't need to make a branch if you just want to temporarily obtain the
content.  Just:

$ git checkout commit_id -- pathto/port

At this point "git status" will show the relevant file(s) as modified and
staged in the index.

[...]
> yep - that's it. if there were any files in the files directory, you'd
> have those at that point in time too.

> move out of the port directory, and copy those into a local repo (like
> this one /opt/peggedports that I use for this):

Or you can create (or select) a branch in the current repo to hold them,
and just commit the old content there.  If you don't want to commit the
old content, you can undo the checkout with

$ git reset HEAD pathto/port
$ git checkout -- pathto/port

Or if your working directory and index were clean to start with, just:

$ git reset --hard

Fred Wright


More information about the macports-dev mailing list