Warning: there may be occasional oddness due to css and blog edits. **KNOWN ISSUE: possible hidden text**

Sunday, March 28, 2021

Tool without fanfare

Due to our fairly recent VCS change and impending portsnap retirement, it is somewhat surprising that gitup was released to seemingly very little or no fanfare.  It might be used to solve the issue of svn being replaced by git for obtaining source, and both portsnap and svn for maintaining one's local ports tree.  It also is apparently even smaller or less dependency encumbered than git@tiny which should be a rather large positive for the average consumer as well as being quite simple to configure and use.

Firstly, the configuration file provided with the port when installed might need to be updated or modified to suit your needs.

# $FreeBSD$
#
# Default configuration options for gitup.conf.
# github.com/freebsd/freebsd-ports
#
# ${repo} can be replaced by doc, ports and src. (*)
#
# https://git.freebsd.org/${repo}.git
# ssh://anongit@git.freebsd.org/${repo}.git
# (*) In subversion, base is used for FreeBSD src repository (src).
{
        "defaults" : {
                "host"                  : "github.com",
                "port"                  : "443",
                "verbosity"             : "1",
                "work_directory"        : "/var/db/gitup",
        },

        "ports" : {
                "repository"            : "/freebsd/freebsd-ports.git",
                "branch"                : "main",
                "target"                : "/usr/ports",
                "ignores"               : [
                        "distfiles",
                        "packages",
                ],
        },

        "quarterly" : {
                "host"                  : "git.freebsd.org",
                "repository"            : "/freebsd/freebsd-ports.git",
                "branch"                : "quarterly",
                "target"                : "/usr/ports",
                "ignores"               : [
                        "distfiles",
                        "packages",
                ],
        },

        "release" : {
                "repository"            : "/src.git",
                "branch"                : "releng/12.2",
                "target"                : "/usr/src",
                "ignores"               : [
                        "sys/arm64/conf",
                        "sys/i386/conf",
                        "sys/pc98/conf",
                        "sys/powerpc/conf",
                        "sys/riscv/conf",
                        "sys/sparc64/conf",
                ],
        },

        "stable" : {
                "repository"            : "/src.git",
                "branch"                : "stable/13",
                "target"                : "/usr/src",
                "ignores"               : [
                        "sys/arm64/conf",
                        "sys/i386/conf",
                        "sys/pc98/conf",
                        "sys/powerpc/conf",
                        "sys/riscv/conf",
                        "sys/sparc64/conf",
                ],
        },
}

This is because, as we can see above, the defined aliases are no longer appropriate.  The present pending release is 13.0, and current is now 14, while stable is also 13.x, so this should be an easy adjustment.

There does not seem to be an option to simply show what the configured sections are but if one tries to initiate gitup with a bit of nonsense, the message will tell you and so now we can see how the above configuration works.

gitup blargh
gitup:
Cannot find a matching section in the command line arguments.  These are the configured sections:
         * ports
         * quarterly
         * release
         * stable
         * current
: Invalid argument

The short manpage gives further insight and tells of how it can be used to repair a repo and other things.

NAME
     gitup – A minimalist, dependency-free program to clone/pull Git
     repositories.

SYNOPSIS
     gitup section [-ckrV] [-C configuration file] [-h commit checksum]
           [-t tag] [-u pack file] [-v verbosity] [-w commit checksum]

DESCRIPTION
     gitup is a minimalist, dependency-free program used to clone or
     synchronize a local copy of a Git repository.  It is not intended to be a
     full-featured replacement for the devel/git port, but rather, is intended
     to provide a convenient way for users to update FreeBSD source files
     without having to install devel/git (and all of its related dependencies)
     and without the substantial disk overhead that normally accompany local
     Git repositories.

     gitup currently only supports anonymous, encrypted transfers via the
     "Smart HTTP" protocol.

OPTIONS
     Configuration options are stored in /usr/local/etc/gitup.conf and are
     grouped into commonly used sections (additional custom sections can be
     added to this file).  The following command line options can be used to
     override the default and/or section values:

     -C          The location of the configuration file to use.

     -c          Force gitup to clone the repository.

     -h          The "have" commit checksum of the repository to use.  Only
                 needed when importing a pack file generated by the official
                 Git client.

     -k          Save a copy of the pack data.

     -r          Repair the local repository, replacing any files that are
                 missing or have been modified.

     -t          Fetch the commit referenced by the specified tag.

     -u          Skip the download of the pack data and use the specified file
                 instead.

     -v          How verbose the output should be (0 = no output, 1 = show
                 only names of the updated files, 2 = also show commands sent
                 to the server and additional debugging information).

     -V          Display the version number and exit.

     -w          The "want" commit checksum of the repository to retrieve.

FILES
     /usr/local/etc/gitup.conf  Default location of the gitup configuration
                                file.

     /var/db/gitup              Default location where gitup stores its lists
                                of known files.  The files stored here are
                                used during subsequent runs to reconstruct the
                                local repository state and confirm that the
                                local tree is intact.

CAVEATS
     Because gitup neither uses nor updates the .git directory, it is not a
     drop-in replacement for the official Git client.  gitup should only be
     used on repositories originally cloned with the official Git client if
     there is no intention to ever use the official Git client on that local
     repository again.

     To keep its footprint as small as possible, gitup does not retain pack
     files downloaded from the repository (unless explicitly instructed to do
     so) and does not use a saved pack file (unless explicitly instructed to
     do so).  gitup relies on the known remote files lists stored in
     /var/db/gitup and the current state of the local repository to
     reconstruct data that would normally be stored in the pack file.
     Discrepancies in the local repository will be flagged as errors and gitup
     will attempt to any restore any missing or modified files from the
     server, returning the local repository to a clean state.

     Extra care should be given when specifying a commit to pull as gitup only
     performs shallow clones and does not have access to a repository's full
     commit history.  If a commit is passed in via the -w command line
     argument and that commit exists on a different branch, the Git server
     will neither object nor inform gitup of the branch change and will send a
     pack file that will convert the local repository.  If the change of
     branches is intentional, the relevant section in
     /usr/local/etc/gitup.conf will need to be manually updated.

EXAMPLES
     Using the configuration options for commonly used repositories/branches
     stored in /usr/local/etc/gitup.conf, to clone/pull a copy of the most
     recent revision of stable/12:

           gitup stable

     To retrieve a copy of freebsd-ports at commit
     0123456789abcdef0123456789abcdef01234567:

           gitup ports -w 0123456789abcdef0123456789abcdef01234567

SEE ALSO
     gitup.conf(5)

AUTHORS
     John Mehr  is the author of gitup and this man page.


What I like most about this tool is that by default it avoids repairs to the ports tree where I may have made modifications to Makefiles or hidden patch files or any other similar adjustments.  This way I can keep a slightly modified local ports tree which I can use to build individual ports (such as minetest) which I then explicitly blacklist for the poudriere repo pkg builds.  This requires that any pkg built and part of the poudriere repo is removed or a pkg upgrade will still see it.

The initial run, regardless of whether the repair option is used or a clean fresh ports tree is constructed by it, offers no feedback from this tool that it is doing anything and the processes or file transfers involved take quite a bit of time. I did enable maximum verbosity but that did not help, I would strongly recommend to the author that a spinning cursor or some other indication that the tool is doing something be added so that we know that our configuration is correct and we know everything is okay.  I am fine with things taking time to function (in this case about 14 minutes), to produce results, but silence is a killer as it makes me wonder and may cause me to end a process which is less than a second away from finally doing something visible.  The level of verbosity does not affect the 14 minutes of silence, only the output that follows it.  If this is used as part of an unattended script, I would recommend watching for results once outside of the script to be certain it acts as it should before hiding everything, or you may never know if anything is wrong such as an error in the configuration file.

FYI:

When the branch gets changed, which it has twice recently, first it shifted to main, and now its back to master once more, you may end up with an error should you have verbosity enabled for that repo. If you use poudriere, the message may appear similar to below, simply change it to what you might find is used at github/freebsd.

# Host: github.com
# Port: 443
# Repository: /freebsd/freebsd-ports.git
# Target: /usr/ports
# Have: 4010f7bbc03638d71781ce091bf40a0907fa12fe
# Want: 4010f7bbc03638d71781ce091bf40a0907fa12fe
# Branch: main
[00:00:00] Updating portstree "default" with git...fatal: couldn't find remote ref refs/heads/master

The solution for poudriere seems to be a bit overkill, but it is as follows below.

Delete the "default" ports tree:

poudriere ports -d

Re-create the "default" ports tree using branch=main by method=git. poudriere ports -c -B main -m git

No comments:

Post a Comment

Thank you for your interest!

Frequently viewed this week