summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2014-12-18 01:24:40 +0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2014-12-18 01:24:40 +0000
commitd7edec4888fae4bd4611d94e89b1af234fdacbc4 (patch)
tree920345b1bf2712ec2371b3c496cf547161e15cf8
parentf0c21ab3f74127c8614500d6f8aa9cf7ccb36842 (diff)
downloadnixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.tar
nixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.tar.gz
nixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.tar.bz2
nixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.tar.lz
nixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.tar.xz
nixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.tar.zst
nixpkgs-d7edec4888fae4bd4611d94e89b1af234fdacbc4.zip
Add other source of channels, and distinguish between local and remote channels.
-rwxr-xr-xmaintainers/scripts/update-channel-branches.sh49
1 files changed, 45 insertions, 4 deletions
diff --git a/maintainers/scripts/update-channel-branches.sh b/maintainers/scripts/update-channel-branches.sh
index 0157fe1db10..d7fbcb75690 100755
--- a/maintainers/scripts/update-channel-branches.sh
+++ b/maintainers/scripts/update-channel-branches.sh
@@ -9,10 +9,51 @@ for channelName in : $(curl -s $NIXOS_CHANNELS | sed -n '/folder/ { s,.*href=",,
     # Do not follow redirections, such that we can extract the
     # short-changeset from the name of the directory where we are
     # redirected to.
-    sha1=$(curl -s --max-redirs 0 $NIXOS_CHANNELS$channelName | sed -n '/has moved/ { s,.*\.\([a-z0-9A-Z]*\)".*,\1,; p; }')
+    sha1=$(curl -sI $NIXOS_CHANNELS$channelName | sed -n '/Location/ { s,.*\.\([a-f0-9]*\)[ \r]*$,\1,; p; }')
     test -z "$sha1" -o -z "$channelName" && continue;
 
-    # Update the local channels/* branches to be in-sync with the
-    # channel references.
-    git update-ref refs/heads/channels/$channelName $sha1
+    # Update the local refs/heads/channels/remotes/* branches to be
+    # in-sync with the channel references.
+    git update-ref refs/heads/channels/remotes/$channelName $sha1
+done
+
+if currentSystem=$(nixos-version 2>/dev/null); then
+    channelName=current-system
+
+    # If the system is entirely build from a custom nixpkgs version,
+    # then the version is not annotated in git version. This sed
+    # expression is basically matching that the expressions end with
+    # ".<sha1> (Name)" to extract the sha1.
+    sha1=$(echo $currentSystem | sed -n 's,^.*\.\([a-f0-9]*\) *(.*)$,\1,; T skip; p; :skip;')
+    if test -n "$sha1"; then
+
+        # Update the local refs/heads/channels/locals/* branches to be
+        # in-sync with the channel references.
+        git update-ref refs/heads/channels/locals/$channelName $sha1
+    fi
+fi
+
+for revFile in : $(find -L ~/.nix-defexpr/ -maxdepth 4 -name svn-revision); do
+    test "$revFile" = : && continue;
+
+    # Deconstruct a path such as, into:
+    #   /home/luke/.nix-defexpr/channels_root/nixos/nixpkgs/svn-revision
+    #     user=root  repo=nixos    channelName=root/nixos
+    #
+    #   /home/luke/.nix-defexpr/channels/nixpkgs/svn-revision
+    #     user=luke  repo=nixpkgs  channelName=luke/nixpkgs
+    user=${revFile#*.nix-defexpr/channels}
+    repo=${user#*/}
+    repo=${repo%%/*}
+    user=${user%%/*}
+    user=${user#_}
+    test -z "$user" && user=$USER
+    channelName="$user/$repo"
+
+    sha1=$(cat $revFile | sed -n 's,^.*\.\([a-f0-9]*\)$,\1,; T skip; p; :skip;')
+    test -z "$sha1" -o -z "$channelName" && continue;
+
+    # Update the local refs/heads/channels/locals/* branches to be
+    # in-sync with the channel references.
+    git update-ref refs/heads/channels/locals/$channelName $sha1
 done