mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-02-04 02:20:25 +01:00
remove-old-stack-work-libs.hs: check hash length for more safety
This commit is contained in:
parent
6c6708be00
commit
c69a73c559
@ -21,22 +21,24 @@ main = do
|
|||||||
samePkgLibDir l1 l2 = pkgDirName l1 == pkgDirName l2
|
samePkgLibDir l1 l2 = pkgDirName l1 == pkgDirName l2
|
||||||
where
|
where
|
||||||
pkgDirName p =
|
pkgDirName p =
|
||||||
if countDashes p < 2
|
if length p < 26 || countDashes p < 2
|
||||||
then error $ p ++ " not in name-version-hash format"
|
then error $ p ++ " not in name-version-hash format"
|
||||||
else let nv_ = dropEnd 22 p in
|
else (removeDashSegment . removeHashSegment) p
|
||||||
if last nv_ == '-' then removeDashSegment $ init nv_
|
|
||||||
else error $ p ++ " not in name-version-hash format"
|
|
||||||
|
|
||||||
countDashes = length . filter (== '-')
|
countDashes = length . filter (== '-')
|
||||||
|
|
||||||
removeDashSegment = init . dropWhileEnd (/= '-')
|
removeDashSegment = init . dropWhileEnd (/= '-')
|
||||||
|
|
||||||
|
removeHashSegment p = let nv_ = dropEnd 22 p in
|
||||||
|
if last nv_ == '-' then init nv_
|
||||||
|
else error $ p ++ " has incorrect hash format"
|
||||||
|
|
||||||
samePkgDynLib d1 d2 = pkgDynName d1 == pkgDynName d2
|
samePkgDynLib d1 d2 = pkgDynName d1 == pkgDynName d2
|
||||||
where
|
where
|
||||||
pkgDynName p =
|
pkgDynName p =
|
||||||
if countDashes p < 3
|
if length p < 43 || countDashes p < 3
|
||||||
then error $ p ++ " not in libHSname-version-hash-ghc*.so format"
|
then error $ p ++ " not in libHSname-version-hash-ghc*.so format"
|
||||||
else (removeDashSegment . removeDashSegment . removeDashSegment) p
|
else (removeDashSegment . removeHashSegment . removeDashSegment) p
|
||||||
|
|
||||||
removeOlder remover files = do
|
removeOlder remover files = do
|
||||||
-- keep 2 latest builds
|
-- keep 2 latest builds
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user