···1191 <replaceable>file</replaceable>.</para></listitem>
1192 </varlistentry>
11931194- <varlistentry xml:id='fun-baseHash'>
1195- <term>
1196- <function>baseHash</function>
1197- <replaceable>path</replaceable>
1198- <replaceable>suffix</replaceable>
1199- </term>
1200 <listitem><para>Strips the directory and hash part of a store
1201 path, storing the name part in the environment variable
1202- <literal>strippedName</literal>. If <literal>suffix</literal> is also
1203- provided, the suffix will also be removed. For example:</para>
12041205<programlisting>
1206-baseHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
1207# prints coreutils-8.24
01208</programlisting>
12090001210<programlisting>
1211-baseHash "/nix/store/0016702zbydafsr20n9l1dcw7x2bf6jj-arraysugar-0.1.0.gem" .gem
1212-# prints arraysugar-0.1.0
1213</programlisting>
1214- </listitem>
121501216 </varlistentry>
12171218- <varlistentry xml:id='fun-stripHash'>
1219- <term><function>stripHash</function>
1220- <replaceable>path</replaceable></term>
1221- <listitem><para>Deprecated. Use baseHash instead.</para></listitem>
1222- </varlistentry>
12231224</variablelist>
1225
···1191 <replaceable>file</replaceable>.</para></listitem>
1192 </varlistentry>
11931194+1195+ <varlistentry xml:id='fun-stripHash'>
1196+ <term><function>stripHash</function>
1197+ <replaceable>path</replaceable></term>
001198 <listitem><para>Strips the directory and hash part of a store
1199 path, storing the name part in the environment variable
1200+ <literal>strippedName</literal>. For example:
012011202<programlisting>
1203+stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
1204# prints coreutils-8.24
1205+echo $strippedName
1206</programlisting>
12071208+ If you wish to store the result in another variable, then the
1209+ following idiom may be useful:
1210+1211<programlisting>
1212+name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
1213+someVar=$(stripHash $name; echo $strippedName)
1214</programlisting>
012151216+ </para></listitem>
1217 </varlistentry>
12180000012191220</variablelist>
1221
···12 if test "$(echo $i | cut -c1-2)" = "=>"; then
13 subDir=$(echo $i | cut -c3-)
14 else
15- dst=$out/$subDir/$(baseHash $i | sed 's/\.in//')
16 doSub $i $dst
17 chmod +x $dst # !!!
18 fi
···23 if test "$(echo $i | cut -c1-2)" = "=>"; then
24 subDir=$(echo $i | cut -c3-)
25 else
26- dst=$out/$subDir/$(baseHash $i | sed 's/\.in//')
27 doSub $i $dst
28 fi
29done
···12 if test "$(echo $i | cut -c1-2)" = "=>"; then
13 subDir=$(echo $i | cut -c3-)
14 else
15+ dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
16 doSub $i $dst
17 chmod +x $dst # !!!
18 fi
···23 if test "$(echo $i | cut -c1-2)" = "=>"; then
24 subDir=$(echo $i | cut -c3-)
25 else
26+ dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
27 doSub $i $dst
28 fi
29done
+2-1
pkgs/build-support/vm/default.nix
···531532 # Hacky: RPM looks for <basename>.spec inside the tarball, so
533 # strip off the hash.
534- srcName=$(baseHash "$src")
0535 cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
536537 export HOME=/tmp/home
···531532 # Hacky: RPM looks for <basename>.spec inside the tarball, so
533 # strip off the hash.
534+ stripHash "$src"
535+ srcName="$strippedName"
536 cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
537538 export HOME=/tmp/home
···484}
485486487-# DEPRECATED, use baseHash - 2016-06-23
0488stripHash() {
489 strippedName=$(basename $1);
490 if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
···492 fi
493}
494495-# Print NAME with any leading directory components and hash removed.
496-# If specified, also remove a trailing SUFFIX.
497-#
498-# Usage: baseHash NAME [SUFFIX]
499-# Usage: baseName -a [-s SUFFIX] NAME...
500-baseHash() {
501- basename "$@" | sed -s 's/^[a-z0-9]\{32\}-//g'
502-}
503504unpackCmdHooks+=(_defaultUnpack)
505_defaultUnpack() {
···484}
485486487+# Utility function: return the base name of the given path, with the
488+# prefix `HASH-' removed, if present.
489stripHash() {
490 strippedName=$(basename $1);
491 if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
···493 fi
494}
49500000000496497unpackCmdHooks+=(_defaultUnpack)
498_defaultUnpack() {