Support repository directory in the clone function
This commit is contained in:
parent
fd649b66f5
commit
258604f22d
@ -36,6 +36,8 @@ main = do
|
||||
commit packagePath version >> pure Nothing
|
||||
ExistsCommand urlPath -> pure . Text.pack . show
|
||||
<$> remoteFileExists urlPath
|
||||
ArchiveCommand repo nameVersion tarball tagPrefix ->
|
||||
cloneAndArchive repo nameVersion tarball tagPrefix >> pure Nothing
|
||||
chooseTransformFunction (Just "php") = phpTransform
|
||||
chooseTransformFunction (Just "rdiff-backup") = Text.stripPrefix "v"
|
||||
chooseTransformFunction _ = stripPrefix "v"
|
||||
|
@ -26,6 +26,7 @@ data SlackBuilderCommand
|
||||
| SlackBuildCommand Text Text
|
||||
| CommitCommand Text Text
|
||||
| ExistsCommand Text
|
||||
| ArchiveCommand Text Text String Text
|
||||
deriving (Eq, Show)
|
||||
|
||||
data PackagistArguments = PackagistArguments
|
||||
@ -67,6 +68,7 @@ slackBuilderCommand = subparser
|
||||
<> command "slackbuild" (info slackBuildCommand mempty)
|
||||
<> command "commit" (info commitCommand mempty)
|
||||
<> command "exists" (info existsCommand mempty)
|
||||
<> command "archive" (info archiveCommand mempty)
|
||||
where
|
||||
slackBuildCommand = SlackBuildCommand
|
||||
<$> argument str (metavar "PATH")
|
||||
@ -75,3 +77,8 @@ slackBuilderCommand = subparser
|
||||
<$> argument str (metavar "PATH")
|
||||
<*> argument str (metavar "VERSION")
|
||||
existsCommand = ExistsCommand <$> argument str (metavar "PATH")
|
||||
archiveCommand = ArchiveCommand
|
||||
<$> argument str (metavar "REPO")
|
||||
<*> argument str (metavar "NAME_VERSION")
|
||||
<*> argument str (metavar "TARBALL")
|
||||
<*> argument str (metavar "TAG_PREFIX")
|
||||
|
@ -12,6 +12,7 @@ data Settings = Settings
|
||||
, repository :: !FilePath
|
||||
, branch :: Text
|
||||
, downloadURL :: Text
|
||||
, remotePath :: Text
|
||||
} deriving (Eq, Show)
|
||||
|
||||
settingsCodec :: Toml.TomlCodec Settings
|
||||
@ -20,3 +21,4 @@ settingsCodec = Settings
|
||||
<*> Toml.string "repository" .= repository
|
||||
<*> Toml.text "branch" .= branch
|
||||
<*> Toml.text "download_url" .= downloadURL
|
||||
<*> Toml.text "remote_path" .= remotePath
|
||||
|
@ -1,5 +1,6 @@
|
||||
module SlackBuilder.Download
|
||||
( commit
|
||||
( cloneAndArchive
|
||||
, commit
|
||||
, hostedSources
|
||||
, remoteFileExists
|
||||
, updateSlackBuildVersion
|
||||
@ -83,3 +84,42 @@ remoteFileExists url = hostedSources url
|
||||
{ httpConfigCheckResponse = const $ const $ const Nothing
|
||||
}
|
||||
go uri = req HEAD uri NoReqBody ignoreResponse mempty
|
||||
|
||||
uploadCommand :: Text -> Text -> SlackBuilderT ()
|
||||
uploadCommand localPath remotePath' = do
|
||||
remoteRoot <- SlackBuilderT $ asks remotePath
|
||||
liftIO $ callProcess "scp" $ Text.unpack <$>
|
||||
[ "slackbuilds/" <> localPath
|
||||
, remoteRoot <> remotePath'
|
||||
]
|
||||
|
||||
cloneAndArchive :: Text -> Text -> FilePath -> Text -> SlackBuilderT ()
|
||||
cloneAndArchive repo nameVersion tarball tagPrefix = do
|
||||
let (_, version) = Text.breakOnEnd "-" nameVersion
|
||||
nameVersion' = Text.unpack nameVersion
|
||||
|
||||
repository' <- SlackBuilderT $ asks repository
|
||||
liftIO $ callProcess "rm" ["-rf", nameVersion']
|
||||
|
||||
liftIO $ callProcess "git" ["clone", Text.unpack repo, nameVersion']
|
||||
liftIO $ callProcess "git"
|
||||
[ "-C"
|
||||
, nameVersion'
|
||||
, "checkout"
|
||||
, Text.unpack $ tagPrefix <> version
|
||||
]
|
||||
liftIO $ callProcess "git"
|
||||
[ "-C"
|
||||
, nameVersion'
|
||||
, "submodule"
|
||||
, "update"
|
||||
, "--init"
|
||||
, "--recursive"
|
||||
]
|
||||
|
||||
liftIO $ callProcess "tar"
|
||||
[ "Jcvf"
|
||||
, repository' </> tarball
|
||||
, nameVersion'
|
||||
]
|
||||
liftIO $ callProcess "rm" ["-rf", nameVersion']
|
||||
|
@ -2,3 +2,4 @@ gh_token = ""
|
||||
repository = "./slackbuilds"
|
||||
branch = "user/nick/updates"
|
||||
download_url = "https://example.com/some/path"
|
||||
remote_path = "example.com:/srv/httpd/some/path"
|
||||
|
@ -109,16 +109,7 @@ module SlackBuilder
|
||||
end
|
||||
|
||||
private_class_method def self.clone_and_archive(repo, name_version, tarball, tag_prefix = 'v')
|
||||
_, _, version = name_version.rpartition '-'
|
||||
|
||||
rm_rf name_version
|
||||
|
||||
sh 'git', 'clone', repo, name_version
|
||||
sh 'git', '-C', name_version, 'checkout', "#{tag_prefix}#{version}"
|
||||
sh 'git', '-C', name_version, 'submodule', 'update', '--init', '--recursive'
|
||||
|
||||
sh 'tar', 'Jcvf', "slackbuilds/#{tarball}", name_version
|
||||
rm_rf name_version
|
||||
sh './bin/slackbuilder', 'archive', repo, name_version, tarball, tag_prefix
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user