mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Implemented filesystem endpoint with support for hardlinks, symlinks and copy.
This commit is contained in:
@@ -11,6 +11,23 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// MD5ChecksumForFile computes just the MD5 hash and not all the others
|
||||
func MD5ChecksumForFile(path string) (string, error) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
hash := md5.New()
|
||||
_, err = io.Copy(hash, file)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%x", hash.Sum(nil)), nil
|
||||
}
|
||||
|
||||
// ChecksumInfo represents checksums for a single file
|
||||
type ChecksumInfo struct {
|
||||
Size int64
|
||||
|
||||
@@ -31,3 +31,10 @@ func (s *ChecksumSuite) TestChecksumsForFile(c *C) {
|
||||
c.Check(info.SHA1, Equals, "1743f8408261b4f1eff88e0fca15a7077223fa79")
|
||||
c.Check(info.SHA256, Equals, "f2775692fd3b70bd0faa4054b7afa92d427bf994cd8629741710c4864ee4dc95")
|
||||
}
|
||||
|
||||
func (s *ChecksumSuite) TestMD5ChecksumForFile(c *C) {
|
||||
md5sum, err := MD5ChecksumForFile(s.tempfile.Name())
|
||||
|
||||
c.Assert(err, IsNil)
|
||||
c.Check(md5sum, Equals, "43470766afbfdca292440eecdceb80fb")
|
||||
}
|
||||
|
||||
@@ -8,23 +8,31 @@ import (
|
||||
|
||||
// ConfigStructure is structure of main configuration
|
||||
type ConfigStructure struct {
|
||||
RootDir string `json:"rootDir"`
|
||||
DownloadConcurrency int `json:"downloadConcurrency"`
|
||||
DownloadLimit int64 `json:"downloadSpeedLimit"`
|
||||
Architectures []string `json:"architectures"`
|
||||
DepFollowSuggests bool `json:"dependencyFollowSuggests"`
|
||||
DepFollowRecommends bool `json:"dependencyFollowRecommends"`
|
||||
DepFollowAllVariants bool `json:"dependencyFollowAllVariants"`
|
||||
DepFollowSource bool `json:"dependencyFollowSource"`
|
||||
DepVerboseResolve bool `json:"dependencyVerboseResolve"`
|
||||
GpgDisableSign bool `json:"gpgDisableSign"`
|
||||
GpgDisableVerify bool `json:"gpgDisableVerify"`
|
||||
DownloadSourcePackages bool `json:"downloadSourcePackages"`
|
||||
PpaDistributorID string `json:"ppaDistributorID"`
|
||||
PpaCodename string `json:"ppaCodename"`
|
||||
SkipContentsPublishing bool `json:"skipContentsPublishing"`
|
||||
S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints"`
|
||||
SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"`
|
||||
RootDir string `json:"rootDir"`
|
||||
DownloadConcurrency int `json:"downloadConcurrency"`
|
||||
DownloadLimit int64 `json:"downloadSpeedLimit"`
|
||||
Architectures []string `json:"architectures"`
|
||||
DepFollowSuggests bool `json:"dependencyFollowSuggests"`
|
||||
DepFollowRecommends bool `json:"dependencyFollowRecommends"`
|
||||
DepFollowAllVariants bool `json:"dependencyFollowAllVariants"`
|
||||
DepFollowSource bool `json:"dependencyFollowSource"`
|
||||
DepVerboseResolve bool `json:"dependencyVerboseResolve"`
|
||||
GpgDisableSign bool `json:"gpgDisableSign"`
|
||||
GpgDisableVerify bool `json:"gpgDisableVerify"`
|
||||
DownloadSourcePackages bool `json:"downloadSourcePackages"`
|
||||
PpaDistributorID string `json:"ppaDistributorID"`
|
||||
PpaCodename string `json:"ppaCodename"`
|
||||
SkipContentsPublishing bool `json:"skipContentsPublishing"`
|
||||
FileSystemPublishRoots map[string]FileSystemPublishRoot `json:"FileSystemPublishEndpoints"`
|
||||
S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints"`
|
||||
SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"`
|
||||
}
|
||||
|
||||
// FileSystemPublishRoot describes single filesystem publishing entry point
|
||||
type FileSystemPublishRoot struct {
|
||||
RootDir string `json:"rootDir"`
|
||||
LinkMethod string `json:"linkMethod"`
|
||||
VerifyMethod string `json:"verifyMethod"`
|
||||
}
|
||||
|
||||
// S3PublishRoot describes single S3 publishing entry point
|
||||
@@ -75,6 +83,7 @@ var Config = ConfigStructure{
|
||||
DownloadSourcePackages: false,
|
||||
PpaDistributorID: "ubuntu",
|
||||
PpaCodename: "",
|
||||
FileSystemPublishRoots: map[string]FileSystemPublishRoot{},
|
||||
S3PublishRoots: map[string]S3PublishRoot{},
|
||||
SwiftPublishRoots: map[string]SwiftPublishRoot{},
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
|
||||
|
||||
s.config.RootDir = "/tmp/aptly"
|
||||
s.config.DownloadConcurrency = 5
|
||||
|
||||
s.config.FileSystemPublishRoots = map[string]FileSystemPublishRoot{"test": {
|
||||
RootDir: "/opt/aptly-publish"}}
|
||||
|
||||
s.config.S3PublishRoots = map[string]S3PublishRoot{"test": {
|
||||
Region: "us-east-1",
|
||||
Bucket: "repo"}}
|
||||
@@ -64,6 +68,13 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
|
||||
" \"ppaDistributorID\": \"\",\n"+
|
||||
" \"ppaCodename\": \"\",\n"+
|
||||
" \"skipContentsPublishing\": false,\n"+
|
||||
" \"FileSystemPublishEndpoints\": {\n"+
|
||||
" \"test\": {\n"+
|
||||
" \"rootDir\": \"/opt/aptly-publish\",\n"+
|
||||
" \"linkMethod\": \"\",\n"+
|
||||
" \"verifyMethod\": \"\"\n"+
|
||||
" }\n"+
|
||||
" },\n"+
|
||||
" \"S3PublishEndpoints\": {\n"+
|
||||
" \"test\": {\n"+
|
||||
" \"region\": \"us-east-1\",\n"+
|
||||
|
||||
Reference in New Issue
Block a user