Add flag to disable/enable support for legacy pool paths

Legacy pool paths are enabled by default, but for new aptly installations
(when aptly config is first generated), it would be disabled explicitly.
This commit is contained in:
Andrey Smirnov
2017-04-26 23:37:31 +03:00
parent 2308632683
commit 186bb2dff0
14 changed files with 24 additions and 16 deletions

View File

@@ -101,6 +101,9 @@ func (context *AptlyContext) config() *utils.ConfigStructure {
if err != nil {
fmt.Fprintf(os.Stderr, "Config file not found, creating default config at %s\n\n", configLocations[0])
// as this is fresh aptly installation, we don't need to support legacy pool locations
utils.Config.SkipLegacyPool = true
utils.SaveConfig(configLocations[0], &utils.Config)
}
}
@@ -302,7 +305,7 @@ func (context *AptlyContext) PackagePool() aptly.PackagePool {
defer context.Unlock()
if context.packagePool == nil {
context.packagePool = files.NewPackagePool(context.config().RootDir)
context.packagePool = files.NewPackagePool(context.config().RootDir, !context.config().SkipLegacyPool)
}
return context.packagePool

View File

@@ -32,7 +32,7 @@ func (s *PackageFilesSuite) SetUpTest(c *C) {
}
func (s *PackageFilesSuite) TestVerify(c *C) {
packagePool := files.NewPackagePool(c.MkDir())
packagePool := files.NewPackagePool(c.MkDir(), false)
result, err := s.files[0].Verify(packagePool, s.cs)
c.Check(err, IsNil)

View File

@@ -362,7 +362,7 @@ func (s *PackageSuite) TestPoolDirectory(c *C) {
}
func (s *PackageSuite) TestLinkFromPool(c *C) {
packagePool := files.NewPackagePool(c.MkDir())
packagePool := files.NewPackagePool(c.MkDir(), false)
cs := files.NewMockChecksumStorage()
publishedStorage := files.NewPublishedStorage(c.MkDir(), "", "")
p := NewPackageFromControlFile(s.stanza)
@@ -384,7 +384,7 @@ func (s *PackageSuite) TestLinkFromPool(c *C) {
}
func (s *PackageSuite) TestFilepathList(c *C) {
packagePool := files.NewPackagePool(c.MkDir())
packagePool := files.NewPackagePool(c.MkDir(), true)
p := NewPackageFromControlFile(s.stanza)
list, err := p.FilepathList(packagePool)
@@ -393,7 +393,7 @@ func (s *PackageSuite) TestFilepathList(c *C) {
}
func (s *PackageSuite) TestDownloadList(c *C) {
packagePool := files.NewPackagePool(c.MkDir())
packagePool := files.NewPackagePool(c.MkDir(), false)
cs := files.NewMockChecksumStorage()
p := NewPackageFromControlFile(s.stanza)
p.Files()[0].Checksums.Size = 5
@@ -418,7 +418,7 @@ func (s *PackageSuite) TestDownloadList(c *C) {
func (s *PackageSuite) TestVerifyFiles(c *C) {
p := NewPackageFromControlFile(s.stanza)
packagePool := files.NewPackagePool(c.MkDir())
packagePool := files.NewPackagePool(c.MkDir(), false)
cs := files.NewMockChecksumStorage()
tmpFilepath := filepath.Join(c.MkDir(), "file")

View File

@@ -97,7 +97,7 @@ func (s *PublishedRepoSuite) SetUpTest(c *C) {
s.provider = &FakeStorageProvider{map[string]aptly.PublishedStorage{
"": s.publishedStorage,
"files:other": s.publishedStorage2}}
s.packagePool = files.NewPackagePool(s.root)
s.packagePool = files.NewPackagePool(s.root, false)
s.cs = files.NewMockChecksumStorage()
tmpFilepath := filepath.Join(c.MkDir(), "file")

View File

@@ -93,7 +93,7 @@ func (s *RemoteRepoSuite) SetUpTest(c *C) {
s.progress = console.NewProgress()
s.db, _ = database.OpenDB(c.MkDir())
s.collectionFactory = NewCollectionFactory(s.db)
s.packagePool = files.NewPackagePool(c.MkDir())
s.packagePool = files.NewPackagePool(c.MkDir(), false)
s.cs = files.NewMockChecksumStorage()
s.SetUpPackages()
s.progress.Start()

View File

@@ -30,7 +30,7 @@ var (
)
// NewPackagePool creates new instance of PackagePool which specified root
func NewPackagePool(root string) *PackagePool {
func NewPackagePool(root string, supportLegacyPaths bool) *PackagePool {
rootPath := filepath.Join(root, "pool")
rootPath, err := filepath.Abs(rootPath)
if err != nil {
@@ -39,7 +39,7 @@ func NewPackagePool(root string) *PackagePool {
return &PackagePool{
rootPath: rootPath,
supportLegacyPaths: true,
supportLegacyPaths: supportLegacyPaths,
}
}

View File

@@ -24,7 +24,7 @@ type PackagePoolSuite struct {
var _ = Suite(&PackagePoolSuite{})
func (s *PackagePoolSuite) SetUpTest(c *C) {
s.pool = NewPackagePool(c.MkDir())
s.pool = NewPackagePool(c.MkDir(), true)
s.checksum = utils.ChecksumInfo{
MD5: "0035d7822b2f8f0ec4013f270fd650c2",
}

View File

@@ -171,7 +171,7 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
},
}
pool := NewPackagePool(s.root)
pool := NewPackagePool(s.root, false)
for _, t := range tests {
tmpPath := filepath.Join(c.MkDir(), t.sourcePath)

View File

@@ -216,7 +216,7 @@ func (s *PublishedStorageSuite) TestRenameFile(c *C) {
func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
root := c.MkDir()
pool := files.NewPackagePool(root)
pool := files.NewPackagePool(root, false)
cs := files.NewMockChecksumStorage()
tmpFile1 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")

View File

@@ -144,7 +144,7 @@ func (s *PublishedStorageSuite) TestRenameFile(c *C) {
func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
root := c.MkDir()
pool := files.NewPackagePool(root)
pool := files.NewPackagePool(root, false)
cs := files.NewMockChecksumStorage()
tmpFile1 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")

View File

@@ -1,5 +1,5 @@
{
"rootDir": "${HOME}/.aptly",
"rootDir": "/Users/smira/.aptly",
"downloadConcurrency": 4,
"downloadSpeedLimit": 0,
"architectures": [],
@@ -11,6 +11,7 @@
"gpgDisableSign": false,
"gpgDisableVerify": false,
"downloadSourcePackages": false,
"skipLegacyPool": false,
"ppaDistributorID": "ubuntu",
"ppaCodename": "",
"skipContentsPublishing": false,

View File

@@ -1,5 +1,5 @@
{
"rootDir": "${HOME}/.aptly",
"rootDir": "/Users/smira/.aptly",
"downloadConcurrency": 4,
"downloadSpeedLimit": 0,
"architectures": [],
@@ -11,6 +11,7 @@
"gpgDisableSign": false,
"gpgDisableVerify": false,
"downloadSourcePackages": false,
"skipLegacyPool": true,
"ppaDistributorID": "ubuntu",
"ppaCodename": "",
"skipContentsPublishing": false,

View File

@@ -20,6 +20,7 @@ type ConfigStructure struct {
GpgDisableSign bool `json:"gpgDisableSign"`
GpgDisableVerify bool `json:"gpgDisableVerify"`
DownloadSourcePackages bool `json:"downloadSourcePackages"`
SkipLegacyPool bool `json:"skipLegacyPool"`
PpaDistributorID string `json:"ppaDistributorID"`
PpaCodename string `json:"ppaCodename"`
SkipContentsPublishing bool `json:"skipContentsPublishing"`
@@ -81,6 +82,7 @@ var Config = ConfigStructure{
GpgDisableSign: false,
GpgDisableVerify: false,
DownloadSourcePackages: false,
SkipLegacyPool: false,
PpaDistributorID: "ubuntu",
PpaCodename: "",
FileSystemPublishRoots: map[string]FileSystemPublishRoot{},

View File

@@ -65,6 +65,7 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
" \"gpgDisableSign\": false,\n"+
" \"gpgDisableVerify\": false,\n"+
" \"downloadSourcePackages\": false,\n"+
" \"skipLegacyPool\": false,\n"+
" \"ppaDistributorID\": \"\",\n"+
" \"ppaCodename\": \"\",\n"+
" \"skipContentsPublishing\": false,\n"+