* Add a test for nix-channel.
* Refactor the nix-channel unpacker a bit.
This commit is contained in:
parent
dadbb51d96
commit
39d45a6b09
13 changed files with 103 additions and 75 deletions
|
|
@ -1,11 +1,11 @@
|
|||
SUBDIRS = channels
|
||||
|
||||
all-local: config.nix
|
||||
|
||||
files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL_DATA) config.nix $(srcdir)/nar.nix $(srcdir)/buildenv.nix $(srcdir)/buildenv.pl $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL_DATA) config.nix $(files) $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
|
||||
include ../substitute.mk
|
||||
|
||||
EXTRA_DIST = config.nix.in nar.nix buildenv.nix buildenv.pl
|
||||
EXTRA_DIST = config.nix.in $(files)
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
all-local: unpack.sh
|
||||
|
||||
install-exec-local:
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
||||
$(INSTALL_DATA) $(srcdir)/unpack.nix $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
||||
$(INSTALL_PROGRAM) unpack.sh $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
||||
|
||||
include ../../substitute.mk
|
||||
|
||||
EXTRA_DIST = unpack.nix unpack.sh.in
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{system, inputs}:
|
||||
|
||||
derivation {
|
||||
name = "channels";
|
||||
builder = ./unpack.sh;
|
||||
inherit system inputs;
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#! @shell@ -e
|
||||
|
||||
# Cygwin compatibility hack: bunzip2 expects cygwin.dll in $PATH.
|
||||
export PATH=@coreutils@
|
||||
|
||||
@coreutils@/mkdir $out
|
||||
@coreutils@/mkdir $out/tmp
|
||||
cd $out/tmp
|
||||
|
||||
inputs=($inputs)
|
||||
for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
||||
channelName=${inputs[n]}
|
||||
channelTarball=${inputs[n+1]}
|
||||
|
||||
echo "unpacking channel $channelName"
|
||||
|
||||
@bzip2@ -d < $channelTarball | @tar@ xf -
|
||||
|
||||
if test -e */channel-name; then
|
||||
channelName="$(@coreutils@/cat */channel-name)"
|
||||
fi
|
||||
|
||||
nr=1
|
||||
attrName=$(echo $channelName | @tr@ -- '- ' '__')
|
||||
dirName=$attrName
|
||||
while test -e ../$dirName; do
|
||||
nr=$((nr+1))
|
||||
dirName=$attrName-$nr
|
||||
done
|
||||
|
||||
@coreutils@/mv * ../$dirName # !!! hacky
|
||||
done
|
||||
|
||||
cd ..
|
||||
@coreutils@/rmdir tmp
|
||||
11
corepkgs/unpack-channel.nix
Normal file
11
corepkgs/unpack-channel.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
with import <nix/config.nix>;
|
||||
|
||||
{ system, inputs }:
|
||||
|
||||
derivation {
|
||||
name = "channels";
|
||||
builder = shell;
|
||||
args = [ "-e" ./unpack-channel.sh ];
|
||||
inherit system inputs bzip2 tar tr;
|
||||
PATH = "${nixBinDir}:${coreutils}";
|
||||
}
|
||||
30
corepkgs/unpack-channel.sh
Normal file
30
corepkgs/unpack-channel.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
mkdir $out
|
||||
mkdir $out/tmp
|
||||
cd $out/tmp
|
||||
|
||||
inputs=($inputs)
|
||||
for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
||||
channelName=${inputs[n]}
|
||||
channelTarball=${inputs[n+1]}
|
||||
|
||||
echo "unpacking channel $channelName"
|
||||
|
||||
$bzip2 -d < $channelTarball | $tar xf -
|
||||
|
||||
if test -e */channel-name; then
|
||||
channelName="$(cat */channel-name)"
|
||||
fi
|
||||
|
||||
nr=1
|
||||
attrName=$(echo $channelName | $tr -- '- ' '__')
|
||||
dirName=$attrName
|
||||
while test -e ../$dirName; do
|
||||
nr=$((nr+1))
|
||||
dirName=$attrName-$nr
|
||||
done
|
||||
|
||||
mv * ../$dirName # !!! hacky
|
||||
done
|
||||
|
||||
cd ..
|
||||
rmdir tmp
|
||||
Loading…
Add table
Add a link
Reference in a new issue