forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stack unpack: Ignore pax headers (fix commercialhaskell#2361)
* Stop trying to reset permissions on pax header entries. * Add changelog entry. * Output warnings for unexpected entries. * Add testcases. The interface of untar is designed for unit testing.
- Loading branch information
1 parent
6e6c41e
commit 6af46db
Showing
8 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Use ./createFiles.sh to regenerate the test tarballs in this directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
|
||
module Stack.Untar.UntarSpec where | ||
|
||
import Data.List (sort) | ||
import System.FilePath ((</>)) | ||
import System.Directory (removeDirectoryRecursive) | ||
import Stack.Fetch (untar) | ||
import Test.Hspec | ||
|
||
spec :: Spec | ||
spec = do | ||
describe "Untarring ignores strange entries" $ | ||
mapM_ testTarFile tarFiles | ||
where | ||
-- XXX tests are run in the project root folder, but data files are next to | ||
-- this source data. | ||
currentFolder = "src" </> "test" </> "Stack" </> "Untar" | ||
|
||
-- Pairs test tarball names + list of unexpected entries contained: for each | ||
-- entry, a tar pathname + description. | ||
tarFiles = [ ("test1", []) | ||
, ("test2", [ ("test2" </> "bar", "named pipe") | ||
, ("test2" </> "devB", "block device") | ||
, ("test2" </> "devC", "character device")])] | ||
|
||
testTarFile (name, expected) = | ||
it ("works on test " ++ name) $ | ||
getEntries name `shouldReturn` sort expected | ||
|
||
getEntries name = do | ||
let tarFP = currentFolder </> name ++ ".tar.gz" | ||
expectedTarFolder = name | ||
dest = currentFolder | ||
|
||
entries <- untar tarFP expectedTarFolder dest | ||
removeDirectoryRecursive $ currentFolder </> expectedTarFolder | ||
return $ sort entries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
# This allows recreating | ||
|
||
# Name for GNU tar. | ||
TAR=tar | ||
CHOWN=chown | ||
# Needed on my OS X install with HomeBrew. | ||
#TAR=gtar | ||
#CHOWN=gchown | ||
|
||
mkdir -p test1 test2 | ||
touch test1/foo | ||
mkfifo test2/bar | ||
sudo mknod test2/devB b 1 0 | ||
sudo mknod test2/devC c 3 2 | ||
sudo $CHOWN --reference=test2 test2/* | ||
|
||
for i in 1 2; do | ||
$TAR czf test$i.tar.gz --format=posix test$i | ||
done | ||
for i in 1 2; do | ||
gtar czf test$i.tar.gz --format=posix test$i | ||
done | ||
|
||
rm -rf test1 test2 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters