nixpkgs/pkgs/common-updater/scripts/list-git-tags
José Romildo Malaquias 827a6619eb common-updater-scripts: add scripts to help update packages
- updateScript:
  A nix expression that can be used in passThrough to update a package

- list-git-tags:
  A shell script to list available tags in a git repository

- list-archive-two-level-versions:

  A shell script to list available versions in a web site in two
  levels: there is a page listing the available major.minor versions,
  and for each of them there is another page listings the patch level
  versions major.minor.patch.

  It is suitable for Xfce packages for instance.

How the updater works:

1. collect the available versions from the source repository (using a
script given as argument)

2. print the collected versions (for debugging)

3. (optionally) apply some transformation to the collected versions to
make them compatible with the versions used in nixpkgs (for instance,
tags in the Xfce git repository may be prefixed with the package name,
and the prefix need to be removed)

4. sort the available versions in decreasing order

5. choose the first version that pass validation:
   - check if the version may be a development version

   - if the version IS unstable, skip it and give a warning about
   skipping a development version (for debugging)

   - if the version COULD BE unstable, take it and give a warning
   about taking a potential development version (for debugging)

   - if the version IS stable, take it

6. update the package version and checksum in its nix expression

7. print the git commands for adding the modified files and for
committing the changes
2020-04-15 09:45:25 -03:00

33 lines
732 B
Bash
Executable file

#! /bin/sh -x
# lists all available tags from a git repository
scriptName=list-git-tags # do not use the .wrapped name
usage() {
echo "Usage: $scriptName <repository url> [<package name> [<debug file path>]]"
}
repo="$1" # git repository url
pname="$2" # package name
file="$3" # file for writing debugging information
if [ -z "$repo" ]; then
echo "$scriptName: Missing git repository url"
usage
exit 1
fi
# print a debugging message
if [ -n "$file" ]; then
echo "# Listing tags for $pname at $repo" >> $file
fi
# list all tags from the remote repository
tags=$(git ls-remote --tags --refs "$repo")
# keep only the version part of the tag
tags=$(echo "$tags" | cut --delimiter=/ --field=3)
echo "$tags"