Revert "stdenv: introduce baseHash() to replace stripHash()"
Introduced by mistake This reverts commit e71a5cb87841f0af4a2279517b77a9a07ba394c0.
This commit is contained in:
parent
893ab31159
commit
4f5918cd2e
@ -1191,35 +1191,31 @@ echo @foo@
|
|||||||
<replaceable>file</replaceable>.</para></listitem>
|
<replaceable>file</replaceable>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry xml:id='fun-baseHash'>
|
|
||||||
<term>
|
|
||||||
<function>baseHash</function>
|
|
||||||
<replaceable>path</replaceable>
|
|
||||||
<replaceable>suffix</replaceable>
|
|
||||||
</term>
|
|
||||||
<listitem><para>Strips the directory and hash part of a store
|
|
||||||
path, storing the name part in the environment variable
|
|
||||||
<literal>strippedName</literal>. If <literal>suffix</literal> is also
|
|
||||||
provided, the suffix will also be removed. For example:</para>
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
baseHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
|
|
||||||
# prints coreutils-8.24
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
baseHash "/nix/store/0016702zbydafsr20n9l1dcw7x2bf6jj-arraysugar-0.1.0.gem" .gem
|
|
||||||
# prints arraysugar-0.1.0
|
|
||||||
</programlisting>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry xml:id='fun-stripHash'>
|
<varlistentry xml:id='fun-stripHash'>
|
||||||
<term><function>stripHash</function>
|
<term><function>stripHash</function>
|
||||||
<replaceable>path</replaceable></term>
|
<replaceable>path</replaceable></term>
|
||||||
<listitem><para>Deprecated. Use baseHash instead.</para></listitem>
|
<listitem><para>Strips the directory and hash part of a store
|
||||||
|
path, storing the name part in the environment variable
|
||||||
|
<literal>strippedName</literal>. For example:
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
|
||||||
|
# prints coreutils-8.24
|
||||||
|
echo $strippedName
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
If you wish to store the result in another variable, then the
|
||||||
|
following idiom may be useful:
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
|
||||||
|
someVar=$(stripHash $name; echo $strippedName)
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ for i in $scripts; do
|
|||||||
if test "$(echo $i | cut -c1-2)" = "=>"; then
|
if test "$(echo $i | cut -c1-2)" = "=>"; then
|
||||||
subDir=$(echo $i | cut -c3-)
|
subDir=$(echo $i | cut -c3-)
|
||||||
else
|
else
|
||||||
dst=$out/$subDir/$(baseHash $i | sed 's/\.in//')
|
dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
|
||||||
doSub $i $dst
|
doSub $i $dst
|
||||||
chmod +x $dst # !!!
|
chmod +x $dst # !!!
|
||||||
fi
|
fi
|
||||||
@ -23,7 +23,7 @@ for i in $substFiles; do
|
|||||||
if test "$(echo $i | cut -c1-2)" = "=>"; then
|
if test "$(echo $i | cut -c1-2)" = "=>"; then
|
||||||
subDir=$(echo $i | cut -c3-)
|
subDir=$(echo $i | cut -c3-)
|
||||||
else
|
else
|
||||||
dst=$out/$subDir/$(baseHash $i | sed 's/\.in//')
|
dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
|
||||||
doSub $i $dst
|
doSub $i $dst
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -531,7 +531,8 @@ rec {
|
|||||||
|
|
||||||
# Hacky: RPM looks for <basename>.spec inside the tarball, so
|
# Hacky: RPM looks for <basename>.spec inside the tarball, so
|
||||||
# strip off the hash.
|
# strip off the hash.
|
||||||
srcName=$(baseHash "$src")
|
stripHash "$src"
|
||||||
|
srcName="$strippedName"
|
||||||
cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
|
cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
|
||||||
|
|
||||||
export HOME=/tmp/home
|
export HOME=/tmp/home
|
||||||
|
@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
|
|||||||
sourceRoot = "./";
|
sourceRoot = "./";
|
||||||
|
|
||||||
unpackCmd = ''
|
unpackCmd = ''
|
||||||
ttfName=$(baseHash $curSrc)
|
ttfName=$(basename $(stripHash $curSrc; echo $strippedName))
|
||||||
cp $curSrc ./$ttfName
|
cp $curSrc ./$ttfName
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -3,4 +3,5 @@ source $stdenv/setup
|
|||||||
mkdir -p $out/xml/dtd/docbook-ebnf
|
mkdir -p $out/xml/dtd/docbook-ebnf
|
||||||
cd $out/xml/dtd/docbook-ebnf
|
cd $out/xml/dtd/docbook-ebnf
|
||||||
cp -p $dtd dbebnf.dtd
|
cp -p $dtd dbebnf.dtd
|
||||||
cp -p $catalog $(baseHash $catalog)
|
stripHash $catalog
|
||||||
|
cp -p $catalog $strippedName
|
||||||
|
@ -484,7 +484,8 @@ dumpVars() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# DEPRECATED, use baseHash - 2016-06-23
|
# Utility function: return the base name of the given path, with the
|
||||||
|
# prefix `HASH-' removed, if present.
|
||||||
stripHash() {
|
stripHash() {
|
||||||
strippedName=$(basename $1);
|
strippedName=$(basename $1);
|
||||||
if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
|
if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
|
||||||
@ -492,14 +493,6 @@ stripHash() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print NAME with any leading directory components and hash removed.
|
|
||||||
# If specified, also remove a trailing SUFFIX.
|
|
||||||
#
|
|
||||||
# Usage: baseHash NAME [SUFFIX]
|
|
||||||
# Usage: baseName -a [-s SUFFIX] NAME...
|
|
||||||
baseHash() {
|
|
||||||
basename "$@" | sed -s 's/^[a-z0-9]\{32\}-//g'
|
|
||||||
}
|
|
||||||
|
|
||||||
unpackCmdHooks+=(_defaultUnpack)
|
unpackCmdHooks+=(_defaultUnpack)
|
||||||
_defaultUnpack() {
|
_defaultUnpack() {
|
||||||
|
@ -4,6 +4,6 @@ mkdir -p $out
|
|||||||
|
|
||||||
for ((i = 1; i <= $nrFrames; i++)); do
|
for ((i = 1; i <= $nrFrames; i++)); do
|
||||||
echo "producing frame $i...";
|
echo "producing frame $i...";
|
||||||
targetName=$out/$(baseHash $dotGraph .dot)-f-$i.dot
|
targetName=$out/$(basename $(stripHash $dotGraph; echo $strippedName) .dot)-f-$i.dot
|
||||||
cpp -DFRAME=$i < $dotGraph > $targetName
|
cpp -DFRAME=$i < $dotGraph > $targetName
|
||||||
done
|
done
|
||||||
|
@ -185,7 +185,7 @@ rec {
|
|||||||
if test -d $postscript; then
|
if test -d $postscript; then
|
||||||
input=$(ls $postscript/*.ps)
|
input=$(ls $postscript/*.ps)
|
||||||
else
|
else
|
||||||
input=$(baseHash $postscript)
|
input=$(stripHash $postscript; echo $strippedName)
|
||||||
ln -s $postscript $input
|
ln -s $postscript $input
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ mkdir -p $out
|
|||||||
|
|
||||||
dot2pdf() {
|
dot2pdf() {
|
||||||
sourceFile=$1
|
sourceFile=$1
|
||||||
targetName=$out/$(baseHash $sourceFile .dot).pdf
|
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .dot).pdf
|
||||||
echo "converting $sourceFile to $targetName..."
|
echo "converting $sourceFile to $targetName..."
|
||||||
export FONTCONFIG_FILE=$fontsConf
|
export FONTCONFIG_FILE=$fontsConf
|
||||||
dot -Tpdf $sourceFile > $targetName
|
dot -Tpdf $sourceFile > $targetName
|
||||||
|
@ -4,7 +4,7 @@ mkdir -p $out
|
|||||||
|
|
||||||
dot2ps() {
|
dot2ps() {
|
||||||
sourceFile=$1
|
sourceFile=$1
|
||||||
targetName=$out/$(baseHash $sourceFile .dot).ps
|
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .dot).ps
|
||||||
echo "converting $sourceFile to $targetName..."
|
echo "converting $sourceFile to $targetName..."
|
||||||
dot -Tps $sourceFile > $targetName
|
dot -Tps $sourceFile > $targetName
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ cd $startDir
|
|||||||
|
|
||||||
lhstex() {
|
lhstex() {
|
||||||
sourceFile=$1
|
sourceFile=$1
|
||||||
targetName=$out/$(baseHash $sourceFile .lhs).tex
|
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .lhs).tex
|
||||||
echo "converting $sourceFile to $targetName..."
|
echo "converting $sourceFile to $targetName..."
|
||||||
lhs2TeX -o "$targetName" $flags "$sourceFile"
|
lhs2TeX -o "$targetName" $flags "$sourceFile"
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ for i in $extraFiles; do
|
|||||||
if test -d $i; then
|
if test -d $i; then
|
||||||
ln -s $i/* .
|
ln -s $i/* .
|
||||||
else
|
else
|
||||||
ln -s $i $(baseHash $i)
|
ln -s $i $(stripHash $i; echo $strippedName)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
rootName=$(baseHash "$rootFile")
|
rootName=$(basename $(stripHash "$rootFile"; echo $strippedName))
|
||||||
|
|
||||||
rootNameBase=$(echo "$rootName" | sed 's/\..*//')
|
rootNameBase=$(echo "$rootName" | sed 's/\..*//')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user