Revert "Drop dependency on external basename tool"

This reverts commit 73e049c4931cd798cdf662b5c2b6b41c400d87b2.