···11911191 <replaceable>file</replaceable>.</para></listitem>
11921192 </varlistentry>
1193119311941194- <varlistentry xml:id='fun-baseHash'>
11951195- <term>
11961196- <function>baseHash</function>
11971197- <replaceable>path</replaceable>
11981198- <replaceable>suffix</replaceable>
11991199- </term>
11941194+11951195+ <varlistentry xml:id='fun-stripHash'>
11961196+ <term><function>stripHash</function>
11971197+ <replaceable>path</replaceable></term>
12001198 <listitem><para>Strips the directory and hash part of a store
12011199 path, storing the name part in the environment variable
12021202- <literal>strippedName</literal>. If <literal>suffix</literal> is also
12031203- provided, the suffix will also be removed. For example:</para>
12001200+ <literal>strippedName</literal>. For example:
1204120112051202<programlisting>
12061206-baseHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
12031203+stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
12071204# prints coreutils-8.24
12051205+echo $strippedName
12081206</programlisting>
1209120712081208+ If you wish to store the result in another variable, then the
12091209+ following idiom may be useful:
12101210+12101211<programlisting>
12111211-baseHash "/nix/store/0016702zbydafsr20n9l1dcw7x2bf6jj-arraysugar-0.1.0.gem" .gem
12121212-# prints arraysugar-0.1.0
12121212+name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
12131213+someVar=$(stripHash $name; echo $strippedName)
12131214</programlisting>
12141214- </listitem>
1215121512161216+ </para></listitem>
12161217 </varlistentry>
1217121812181218- <varlistentry xml:id='fun-stripHash'>
12191219- <term><function>stripHash</function>
12201220- <replaceable>path</replaceable></term>
12211221- <listitem><para>Deprecated. Use baseHash instead.</para></listitem>
12221222- </varlistentry>
1223121912241220</variablelist>
12251221
···1212 if test "$(echo $i | cut -c1-2)" = "=>"; then
1313 subDir=$(echo $i | cut -c3-)
1414 else
1515- dst=$out/$subDir/$(baseHash $i | sed 's/\.in//')
1515+ dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
1616 doSub $i $dst
1717 chmod +x $dst # !!!
1818 fi
···2323 if test "$(echo $i | cut -c1-2)" = "=>"; then
2424 subDir=$(echo $i | cut -c3-)
2525 else
2626- dst=$out/$subDir/$(baseHash $i | sed 's/\.in//')
2626+ dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
2727 doSub $i $dst
2828 fi
2929done
+2-1
pkgs/build-support/vm/default.nix
···531531532532 # Hacky: RPM looks for <basename>.spec inside the tarball, so
533533 # strip off the hash.
534534- srcName=$(baseHash "$src")
534534+ stripHash "$src"
535535+ srcName="$strippedName"
535536 cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
536537537538 export HOME=/tmp/home
···484484}
485485486486487487-# DEPRECATED, use baseHash - 2016-06-23
487487+# Utility function: return the base name of the given path, with the
488488+# prefix `HASH-' removed, if present.
488489stripHash() {
489490 strippedName=$(basename $1);
490491 if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
···492493 fi
493494}
494495495495-# Print NAME with any leading directory components and hash removed.
496496-# If specified, also remove a trailing SUFFIX.
497497-#
498498-# Usage: baseHash NAME [SUFFIX]
499499-# Usage: baseName -a [-s SUFFIX] NAME...
500500-baseHash() {
501501- basename "$@" | sed -s 's/^[a-z0-9]\{32\}-//g'
502502-}
503496504497unpackCmdHooks+=(_defaultUnpack)
505498_defaultUnpack() {