mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
Compare commits
131 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d31144b9ae | |||
| c7a3a10846 | |||
| 2be0b7859d | |||
| 65528fc357 | |||
| 5a713534c6 | |||
| f89e322ece | |||
| cd6075ba94 | |||
| 77033df27b | |||
| b8c5303fdb | |||
| eaab66da58 | |||
| 2a8aff9746 | |||
| 797b2dd996 | |||
| e65fff058c | |||
| 548dcdb242 | |||
| 9a65bbe12c | |||
| 72d741a9b7 | |||
| 2f5bf96fc9 | |||
| 4d3b42eb11 | |||
| 5b85522400 | |||
| 5f96abc271 | |||
| 0e6ee35942 | |||
| 14798b2063 | |||
| cef4fefc40 | |||
| 181806a9a2 | |||
| 99a205c716 | |||
| dd78c026c1 | |||
| 20516dbbc2 | |||
| ba80f377a9 | |||
| dc7bbf35eb | |||
| b3b0dbb217 | |||
| d76259496d | |||
| aa3a2ab595 | |||
| 0f1fd1bca6 | |||
| 581876df9a | |||
| d0101be955 | |||
| caa5433787 | |||
| 9125745416 | |||
| b893c0a7ca | |||
| 02ac416561 | |||
| 00bb0ca8f3 | |||
| 2d0baef3b1 | |||
| 3ea803e3bb | |||
| 2fa9d7402f | |||
| 3c04c56639 | |||
| 7cd4b7a908 | |||
| 9242ea4d72 | |||
| 58790dadc6 | |||
| 182fbdef50 | |||
| 4fb57f65fb | |||
| 12e2982362 | |||
| 60fb415150 | |||
| 75c4d6da3b | |||
| 1aa88701fb | |||
| 43ddcd27cb | |||
| 9cb2a302f8 | |||
| d836334767 | |||
| 565fcf4390 | |||
| b7490fe909 | |||
| b2bf4f7884 | |||
| e504fdcd54 | |||
| 3efa1052fa | |||
| 2e488608ca | |||
| 674a0e84be | |||
| f5e1e194b3 | |||
| b4f3573d11 | |||
| 4718625388 | |||
| d6b4b795a5 | |||
| 2bd0b786ea | |||
| 092a7ed8f3 | |||
| 438e206b3d | |||
| 7498fd8fc8 | |||
| e07912770e | |||
| bb2db7e500 | |||
| c94e048198 | |||
| 3b4c06d28d | |||
| 15618c8ea8 | |||
| a037615962 | |||
| 5d301fb1b7 | |||
| 8a4d866810 | |||
| b98abcc049 | |||
| 10e0966edc | |||
| 340d1fdd7c | |||
| 14d4a2706c | |||
| 308ea83cc0 | |||
| 9c018ce636 | |||
| 359cda9d99 | |||
| e682639b20 | |||
| afd2c5fcea | |||
| 5a1d006850 | |||
| 67c26368ee | |||
| 1885cbd6a2 | |||
| 79d68ec3a7 | |||
| f43801cb96 | |||
| 46c2182ade | |||
| 5ef45bddda | |||
| 0d94f29c27 | |||
| 04b7543dea | |||
| 9051f13ce6 | |||
| 1b704db5c0 | |||
| 2d66a4ca0a | |||
| 182c21e38c | |||
| 9a767b7631 | |||
| 3756db2491 | |||
| ff8e4a8659 | |||
| aec6c2f2e2 | |||
| d611d0d829 | |||
| b4deedda01 | |||
| 0f14143141 | |||
| e5198178a5 | |||
| 1c44b4f787 | |||
| 6d2f265980 | |||
| 325d391007 | |||
| 91a3dc9e94 | |||
| 31f4af5722 | |||
| e0aaa8bb80 | |||
| 50035d5bc4 | |||
| 985f1a17b5 | |||
| 72ac1bc33c | |||
| f0d6b1c29f | |||
| bd5fc8ae62 | |||
| 9ca81ff3bc | |||
| d9607cf88c | |||
| 4f56f34d82 | |||
| e2956a84ce | |||
| 00a9eb72d8 | |||
| cbc8051c5c | |||
| a27b489ba2 | |||
| 790d85881b | |||
| d6a3917141 | |||
| 35e2253944 | |||
| a584b2e058 |
+1
-2
@@ -22,8 +22,7 @@ _testmain.go
|
|||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
coverage.html
|
coverage.txt
|
||||||
coverage*.out
|
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
|||||||
+23
-14
@@ -3,13 +3,7 @@ sudo: required
|
|||||||
|
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go_import_path: github.com/aptly-dev/aptly
|
||||||
- 1.6.x
|
|
||||||
- 1.7.x
|
|
||||||
- 1.8.x
|
|
||||||
- master
|
|
||||||
|
|
||||||
go_import_path: github.com/smira/aptly
|
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@@ -19,9 +13,26 @@ addons:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- secure: "YSwtFrMqh4oUvdSQTXBXMHHLWeQgyNEL23ChIZwU0nuDGIcQZ65kipu0PzefedtUbK4ieC065YCUi4UDDh6gPotB/Wu1pnYg3dyQ7rFvhaVYAAUEpajAdXZhlx+7+J8a4FZMeC/kqiahxoRgLbthF9019ouIqhGB9zHKI6/yZwc="
|
- secure: "EcCzJsqQ3HnIkprBPS1YHErsETcb7KQFBYEzVDE7RYDApWeapLq+r/twMtWMd/fkGeLzr3kWSg7nhSadeHMLYeMl9j+U7ncC5CWG5NMBOj/jowlb9cMCCDlmzMoZLAgR6jm1cJyrWCLsWVlv+D0ZiB0fx4xaBZP/gIr9g6nEwC8="
|
||||||
- secure: "V7OjWrfQ8UbktgT036jYQPb/7GJT3Ol9LObDr8FYlzsQ+F1uj2wLac6ePuxcOS4FwWOJinWGM1h+JiFkbxbyFqfRNJ0jj0O2p93QyDojxFVOn1mXqqvV66KFqAWR2Vzkny/gDvj8LTvdB1cgAIm2FNOkQc6E1BFnyWS2sN9ea5E="
|
|
||||||
- secure: "OxiVNmre2JzUszwPNNilKDgIqtfX2gnRSsVz6nuySB1uO2yQsOQmKWJ9cVYgH2IB5H8eWXKOhexcSE28kz6TPLRuEcU9fnqKY3uEkdwm7rJfz9lf+7C4bJEUdA1OIzJppjnWUiXxD7CEPL1DlnMZM24eDQYqa/4WKACAgkK53gE="
|
- secure: "OxiVNmre2JzUszwPNNilKDgIqtfX2gnRSsVz6nuySB1uO2yQsOQmKWJ9cVYgH2IB5H8eWXKOhexcSE28kz6TPLRuEcU9fnqKY3uEkdwm7rJfz9lf+7C4bJEUdA1OIzJppjnWUiXxD7CEPL1DlnMZM24eDQYqa/4WKACAgkK53gE="
|
||||||
|
- NO_FTP_ACCESS: "yes"
|
||||||
|
- BOTO_CONFIG: /dev/null
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- go: master
|
||||||
|
env: RUN_LONG_TESTS=no
|
||||||
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- go: 1.8.x
|
||||||
|
env: RUN_LONG_TESTS=no
|
||||||
|
- go: 1.9.x
|
||||||
|
env: RUN_LONG_TESTS=yes
|
||||||
|
- go: 1.10.x
|
||||||
|
env: RUN_LONG_TESTS=yes
|
||||||
|
- go: master
|
||||||
|
env: RUN_LONG_TESTS=no
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- virtualenv system/env
|
- virtualenv system/env
|
||||||
- . system/env/bin/activate
|
- . system/env/bin/activate
|
||||||
@@ -29,14 +40,12 @@ before_install:
|
|||||||
- pip install -U pip setuptools
|
- pip install -U pip setuptools
|
||||||
- pip install -r system/requirements.txt
|
- pip install -r system/requirements.txt
|
||||||
- make version
|
- make version
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- make prepare
|
- make prepare
|
||||||
|
|
||||||
script: make travis
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- go: master
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks:
|
webhooks:
|
||||||
|
|||||||
@@ -28,3 +28,8 @@ List of contributors, in chronological order:
|
|||||||
* Charles Hsu (https://github.com/charz)
|
* Charles Hsu (https://github.com/charz)
|
||||||
* Clemens Rabe (https://github.com/seeraven)
|
* Clemens Rabe (https://github.com/seeraven)
|
||||||
* TJ Merritt (https://github.com/tjmerritt)
|
* TJ Merritt (https://github.com/tjmerritt)
|
||||||
|
* Matt Martyn (https://github.com/MMartyn)
|
||||||
|
* Ludovico Cavedon (https://github.com/cavedon)
|
||||||
|
* Petr Jediny (https://github.com/pjediny)
|
||||||
|
* Maximilian Stein (https://github.com/steinymity)
|
||||||
|
* Strajan Sebastian (https://github.com/strajansebastian)
|
||||||
|
|||||||
+10
-9
@@ -15,7 +15,7 @@ Please report unacceptable behavior to [team@aptly.info](mailto:team@aptly.info)
|
|||||||
|
|
||||||
### List of Repositories
|
### List of Repositories
|
||||||
|
|
||||||
* [smira/aptly](https://github.com/smira/aptly) - aptly source code, functional tests, man page
|
* [aptly-dev/aptly](https://github.com/aptly-dev/aptly) - aptly source code, functional tests, man page
|
||||||
* [apty-dev/aptly-dev.github.io](https://github.com/aptly-dev/aptly-dev.github.io) - aptly website (https://www.aptly.info/)
|
* [apty-dev/aptly-dev.github.io](https://github.com/aptly-dev/aptly-dev.github.io) - aptly website (https://www.aptly.info/)
|
||||||
* [aptly-dev/aptly-fixture-db](https://github.com/aptly-dev/aptly-fixture-db) & [aptly-dev/aptly-fixture-pool](https://github.com/aptly-dev/aptly-fixture-pool) provide
|
* [aptly-dev/aptly-fixture-db](https://github.com/aptly-dev/aptly-fixture-db) & [aptly-dev/aptly-fixture-pool](https://github.com/aptly-dev/aptly-fixture-pool) provide
|
||||||
fixtures for aptly functional tests
|
fixtures for aptly functional tests
|
||||||
@@ -24,15 +24,15 @@ Please report unacceptable behavior to [team@aptly.info](mailto:team@aptly.info)
|
|||||||
|
|
||||||
### Reporting Bugs
|
### Reporting Bugs
|
||||||
|
|
||||||
1. Please search for similar bug report in [issue tracker](https://github.com/smira/aptly/issues)
|
1. Please search for similar bug report in [issue tracker](https://github.com/aptly-dev/aptly/issues)
|
||||||
2. Please verify that bug is not fixed in latest aptly nightly ([download information](https://www.aptly.info/download/))
|
2. Please verify that bug is not fixed in latest aptly nightly ([download information](https://www.aptly.info/download/))
|
||||||
3. Steps to reproduce increases chances for bug to be fixed quickly. If possible, submit PR with new functional test which fails.
|
3. Steps to reproduce increases chances for bug to be fixed quickly. If possible, submit PR with new functional test which fails.
|
||||||
4. If bug is reproducible with specific package, please provide link to package file.
|
4. If bug is reproducible with specific package, please provide link to package file.
|
||||||
5. Open issue at [GitHub](https://github.com/smira/aptly/issues)
|
5. Open issue at [GitHub](https://github.com/aptly-dev/aptly/issues)
|
||||||
|
|
||||||
### Suggesting Enhancements
|
### Suggesting Enhancements
|
||||||
|
|
||||||
1. Please search [issue tracker](https://github.com/smira/aptly/issues) for similar feature requests.
|
1. Please search [issue tracker](https://github.com/aptly-dev/aptly/issues) for similar feature requests.
|
||||||
2. Describe why enhancement is important to you.
|
2. Describe why enhancement is important to you.
|
||||||
3. Include any additional details or implementation details.
|
3. Include any additional details or implementation details.
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ There are two kinds of documentation:
|
|||||||
|
|
||||||
Core content is mostly the same, but website contains more information, tutorials, examples.
|
Core content is mostly the same, but website contains more information, tutorials, examples.
|
||||||
|
|
||||||
If you want to update `man` page, please open PR to [main aptly repo](https://github.com/smira/aptly),
|
If you want to update `man` page, please open PR to [main aptly repo](https://github.com/aptly-dev/aptly),
|
||||||
details in [man page](#man-page) section.
|
details in [man page](#man-page) section.
|
||||||
|
|
||||||
If you want to update website, please follow steps below:
|
If you want to update website, please follow steps below:
|
||||||
@@ -88,7 +88,7 @@ As Go is using repository path in import paths, it's better to clone aptly repo
|
|||||||
|
|
||||||
mkdir -p ~/go/src/github.com/smira
|
mkdir -p ~/go/src/github.com/smira
|
||||||
cd ~/go/src/github.com/smira
|
cd ~/go/src/github.com/smira
|
||||||
git clone git@github.com:smira/aptly.git
|
git clone git@github.com:aptly-dev/aptly.git
|
||||||
cd aptly
|
cd aptly
|
||||||
|
|
||||||
For main repo under your GitHub user and add it as another Git remote:
|
For main repo under your GitHub user and add it as another Git remote:
|
||||||
@@ -206,12 +206,13 @@ template [man/aptly.1.ronn.tmpl](man/aptly.1.ronn.tmpl) is changed or any comman
|
|||||||
final rendered man page [man/aptly.1](man/aptly.1). In the end of the build, new man page is displayed for visual
|
final rendered man page [man/aptly.1](man/aptly.1). In the end of the build, new man page is displayed for visual
|
||||||
verification.
|
verification.
|
||||||
|
|
||||||
Man page is built with small helper [_man/gen.go](man/gen.go) which pulls in template, command-line help from [cmd/](cmd/) folder
|
Man page is built with small helper [\_man/gen.go](man/gen.go) which pulls in template, command-line help from [cmd/](cmd/) folder
|
||||||
and runs that through [forked copy](https://github.com/smira/ronn) of [ronn](https://github.com/rtomayko/ronn).
|
and runs that through [forked copy](https://github.com/smira/ronn) of [ronn](https://github.com/rtomayko/ronn).
|
||||||
|
|
||||||
### Bash Completion
|
### Bash and Zsh Completion
|
||||||
|
|
||||||
Bash completion for aptly resides in the same repo under in [bash_completion.d/aptly](bash_completion.d/aptly). It's all hand-crafted.
|
Bash and Zsh completion for aptly reside in the same repo under in [completion.d/aptly](completion.d/aptly) and
|
||||||
|
[completion.d/\_aptly](completion.d/_aptly), respectively. It's all hand-crafted.
|
||||||
When new option or command is introduced, bash completion should be updated to reflect that change.
|
When new option or command is introduced, bash completion should be updated to reflect that change.
|
||||||
|
|
||||||
When aptly package is being built, it automatically pulls bash completion and man page into the package.
|
When aptly package is being built, it automatically pulls bash completion and man page into the package.
|
||||||
|
|||||||
Generated
+122
-23
@@ -1,4 +1,5 @@
|
|||||||
memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||||
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/AlekSi/pointer"
|
name = "github.com/AlekSi/pointer"
|
||||||
@@ -14,15 +15,49 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/awalterschulze/gographviz"
|
name = "github.com/awalterschulze/gographviz"
|
||||||
packages = [".","ast","parser","scanner","token"]
|
packages = [
|
||||||
|
".",
|
||||||
|
"ast",
|
||||||
|
"parser",
|
||||||
|
"scanner",
|
||||||
|
"token"
|
||||||
|
]
|
||||||
revision = "761fd5fbb34e4c2c138c280395b65b48e4ff5a53"
|
revision = "761fd5fbb34e4c2c138c280395b65b48e4ff5a53"
|
||||||
version = "v1.0"
|
version = "v1.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/aws/aws-sdk-go"
|
name = "github.com/aws/aws-sdk-go"
|
||||||
packages = ["aws","aws/awserr","aws/awsutil","aws/client","aws/client/metadata","aws/corehandlers","aws/credentials","aws/credentials/ec2rolecreds","aws/credentials/endpointcreds","aws/credentials/stscreds","aws/defaults","aws/ec2metadata","aws/endpoints","aws/request","aws/session","aws/signer/v4","private/protocol","private/protocol/query","private/protocol/query/queryutil","private/protocol/rest","private/protocol/restxml","private/protocol/xml/xmlutil","service/s3","service/sts"]
|
packages = [
|
||||||
revision = "2db5849d2939d93075d911138309a83235032bea"
|
"aws",
|
||||||
version = "v1.8.0"
|
"aws/awserr",
|
||||||
|
"aws/awsutil",
|
||||||
|
"aws/client",
|
||||||
|
"aws/client/metadata",
|
||||||
|
"aws/corehandlers",
|
||||||
|
"aws/credentials",
|
||||||
|
"aws/credentials/ec2rolecreds",
|
||||||
|
"aws/credentials/endpointcreds",
|
||||||
|
"aws/credentials/stscreds",
|
||||||
|
"aws/defaults",
|
||||||
|
"aws/ec2metadata",
|
||||||
|
"aws/endpoints",
|
||||||
|
"aws/request",
|
||||||
|
"aws/session",
|
||||||
|
"aws/signer/v4",
|
||||||
|
"internal/sdkio",
|
||||||
|
"internal/sdkrand",
|
||||||
|
"internal/shareddefaults",
|
||||||
|
"private/protocol",
|
||||||
|
"private/protocol/query",
|
||||||
|
"private/protocol/query/queryutil",
|
||||||
|
"private/protocol/rest",
|
||||||
|
"private/protocol/restxml",
|
||||||
|
"private/protocol/xml/xmlutil",
|
||||||
|
"service/s3",
|
||||||
|
"service/sts"
|
||||||
|
]
|
||||||
|
revision = "a72204b9bf8d48230ee0fe8995613b394c66f2da"
|
||||||
|
version = "v1.13.31"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/cheggaaa/pb"
|
name = "github.com/cheggaaa/pb"
|
||||||
@@ -30,10 +65,21 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
revision = "cdf719fac0dd208251aa828e687c2d5802053b51"
|
revision = "cdf719fac0dd208251aa828e687c2d5802053b51"
|
||||||
version = "v1.0.10"
|
version = "v1.0.10"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/gin-contrib/sse"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/gin-gonic/gin"
|
name = "github.com/gin-gonic/gin"
|
||||||
packages = [".","binding","render"]
|
packages = [
|
||||||
revision = "b1758d3bfa09e61ddbc1c9a627e936eec6a170de"
|
".",
|
||||||
|
"binding",
|
||||||
|
"render"
|
||||||
|
]
|
||||||
|
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
|
||||||
|
version = "v1.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/go-ini/ini"
|
name = "github.com/go-ini/ini"
|
||||||
@@ -41,6 +87,12 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
revision = "1730955e3146956d6a087861380f9b4667ed5071"
|
revision = "1730955e3146956d6a087861380f9b4667ed5071"
|
||||||
version = "v1.26.0"
|
version = "v1.26.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/golang/protobuf"
|
||||||
|
packages = ["proto"]
|
||||||
|
revision = "130e6b02ab059e7b717a096f397c5b60111cae74"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/golang/snappy"
|
name = "github.com/golang/snappy"
|
||||||
@@ -48,28 +100,27 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
revision = "553a641470496b2327abcac10b36396bd98e45c9"
|
revision = "553a641470496b2327abcac10b36396bd98e45c9"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/h2non/filetype"
|
name = "github.com/h2non/filetype"
|
||||||
packages = ["matchers"]
|
packages = ["matchers"]
|
||||||
revision = "0df83c38d14ff5f653d419d480eaac286ccbc823"
|
revision = "cc14fdc9ca0e4c2bafad7458f6ff79fd3947cfbb"
|
||||||
|
version = "v1.0.5"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/jlaffaye/ftp"
|
name = "github.com/jlaffaye/ftp"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "7b85eb4638a2c0473acefcfb929a98f879c15c86"
|
revision = "2403248fa8cc9f7909862627aa7337f13f8e0bf1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/jmespath/go-jmespath"
|
name = "github.com/jmespath/go-jmespath"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "3433f3ea46d9f8019119e7dd41274e112a2359a9"
|
revision = "0b12d6b5"
|
||||||
version = "0.2.2"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/julienschmidt/httprouter"
|
name = "github.com/mattn/go-isatty"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "8c199fb6259ffc1af525cc3ad52ee60ba8359669"
|
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||||
version = "v1.1"
|
version = "v0.0.3"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/mattn/go-runewidth"
|
name = "github.com/mattn/go-runewidth"
|
||||||
@@ -98,7 +149,10 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/ncw/swift"
|
name = "github.com/ncw/swift"
|
||||||
packages = [".","swifttest"]
|
packages = [
|
||||||
|
".",
|
||||||
|
"swifttest"
|
||||||
|
]
|
||||||
revision = "8e9b10220613abdbc2896808ee6b43e411a4fa6c"
|
revision = "8e9b10220613abdbc2896808ee6b43e411a4fa6c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
@@ -117,7 +171,7 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/smira/flag"
|
name = "github.com/smira/flag"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "357ed3e599ffcbd4aeaa828e1d10da2df3ea5107"
|
revision = "695ea5e84e76dea7c8656e43c384e54b32aa1b2a"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
@@ -152,8 +206,21 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/syndtr/goleveldb"
|
name = "github.com/syndtr/goleveldb"
|
||||||
packages = ["leveldb","leveldb/cache","leveldb/comparer","leveldb/errors","leveldb/filter","leveldb/iterator","leveldb/journal","leveldb/memdb","leveldb/opt","leveldb/storage","leveldb/table","leveldb/util"]
|
packages = [
|
||||||
revision = "3c5717caf1475fd25964109a0fc640bd150fce43"
|
"leveldb",
|
||||||
|
"leveldb/cache",
|
||||||
|
"leveldb/comparer",
|
||||||
|
"leveldb/errors",
|
||||||
|
"leveldb/filter",
|
||||||
|
"leveldb/iterator",
|
||||||
|
"leveldb/journal",
|
||||||
|
"leveldb/memdb",
|
||||||
|
"leveldb/opt",
|
||||||
|
"leveldb/storage",
|
||||||
|
"leveldb/table",
|
||||||
|
"leveldb/util"
|
||||||
|
]
|
||||||
|
revision = "714f901b98fdb3aa954b4193d8cbd64a28d80cad"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/ugorji/go"
|
name = "github.com/ugorji/go"
|
||||||
@@ -169,14 +236,27 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = ["cast5","openpgp","openpgp/armor","openpgp/clearsign","openpgp/elgamal","openpgp/errors","openpgp/packet","openpgp/s2k","ssh/terminal"]
|
packages = [
|
||||||
revision = "459e26527287adbc2adcc5d0d49abff9a5f315a7"
|
"cast5",
|
||||||
|
"openpgp",
|
||||||
|
"openpgp/armor",
|
||||||
|
"openpgp/clearsign",
|
||||||
|
"openpgp/elgamal",
|
||||||
|
"openpgp/errors",
|
||||||
|
"openpgp/packet",
|
||||||
|
"openpgp/s2k",
|
||||||
|
"ssh/terminal"
|
||||||
|
]
|
||||||
|
revision = "b2aa35443fbc700ab74c586ae79b81c171851023"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
packages = ["unix"]
|
packages = [
|
||||||
revision = "99f16d856c9836c42d24e7ab64ea72916925fa97"
|
"unix",
|
||||||
|
"windows"
|
||||||
|
]
|
||||||
|
revision = "1d206c9fa8975fb4cf00df1dc8bf3283dc24ba0e"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "v1"
|
branch = "v1"
|
||||||
@@ -184,8 +264,27 @@ memo = "becdf010a814559719c990c1bd645c737cee332ad52004c440605c13de100d45"
|
|||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec"
|
revision = "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "gopkg.in/go-playground/validator.v8"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "5f1438d3fca68893a817e4a66806cea46a9e4ebf"
|
||||||
|
version = "v8.18.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/h2non/filetype.v1"
|
name = "gopkg.in/h2non/filetype.v1"
|
||||||
packages = ["types"]
|
packages = ["types"]
|
||||||
revision = "3093b8ebec6efb56ac813238b8beab4ed4eaac6a"
|
revision = "3093b8ebec6efb56ac813238b8beab4ed4eaac6a"
|
||||||
version = "v1.0.1"
|
version = "v1.0.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "v2"
|
||||||
|
name = "gopkg.in/yaml.v2"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
|
||||||
|
|
||||||
|
[solve-meta]
|
||||||
|
analyzer-name = "dep"
|
||||||
|
analyzer-version = 1
|
||||||
|
inputs-digest = "5ab2b384766e62be84d3941971a1d8e99c637f80a2cb1482b3d9704c668b549f"
|
||||||
|
solver-name = "gps-cdcl"
|
||||||
|
solver-version = 1
|
||||||
|
|||||||
+7
-11
@@ -1,32 +1,28 @@
|
|||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
name = "github.com/gin-gonic/gin"
|
|
||||||
revision = "b1758d3bfa09e61ddbc1c9a627e936eec6a170de"
|
|
||||||
|
|
||||||
[[dependencies]]
|
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/mkrautz/goar"
|
name = "github.com/mkrautz/goar"
|
||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/smira/go-uuid"
|
name = "github.com/smira/go-uuid"
|
||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/smira/go-xz"
|
name = "github.com/smira/go-xz"
|
||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
name = "github.com/ugorji/go"
|
name = "github.com/ugorji/go"
|
||||||
revision = "71c2886f5a673a35f909803f38ece5810165097b"
|
revision = "71c2886f5a673a35f909803f38ece5810165097b"
|
||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
|
|
||||||
[[dependencies]]
|
[[override]]
|
||||||
branch = "v1"
|
branch = "v1"
|
||||||
name = "gopkg.in/check.v1"
|
name = "gopkg.in/check.v1"
|
||||||
|
|||||||
@@ -4,19 +4,13 @@ PACKAGES=context database deb files gpg http query swift s3 utils
|
|||||||
PYTHON?=python
|
PYTHON?=python
|
||||||
TESTS?=
|
TESTS?=
|
||||||
BINPATH?=$(GOPATH)/bin
|
BINPATH?=$(GOPATH)/bin
|
||||||
|
RUN_LONG_TESTS?=yes
|
||||||
|
|
||||||
ifeq ($(GOVERSION), devel)
|
GO_1_10_AND_HIGHER=$(shell (printf '%s\n' go1.10 $(GOVERSION) | sort -cV >/dev/null 2>&1) && echo "yes")
|
||||||
TRAVIS_TARGET=coveralls
|
|
||||||
else
|
|
||||||
TRAVIS_TARGET=test
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: test check system-test
|
all: test check system-test
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
go get -u github.com/mattn/goveralls
|
|
||||||
go get -u github.com/axw/gocov/gocov
|
|
||||||
go get -u golang.org/x/tools/cmd/cover
|
|
||||||
go get -u github.com/alecthomas/gometalinter
|
go get -u github.com/alecthomas/gometalinter
|
||||||
gometalinter --install
|
gometalinter --install
|
||||||
|
|
||||||
@@ -24,45 +18,39 @@ dev:
|
|||||||
go get -u github.com/golang/dep/...
|
go get -u github.com/golang/dep/...
|
||||||
go get -u github.com/laher/goxc
|
go get -u github.com/laher/goxc
|
||||||
|
|
||||||
coverage.out:
|
|
||||||
rm -f coverage.*.out
|
|
||||||
for i in $(PACKAGES); do go test -coverprofile=coverage.$$i.out -covermode=count ./$$i; done
|
|
||||||
echo "mode: count" > coverage.out
|
|
||||||
grep -v -h "mode: count" coverage.*.out >> coverage.out
|
|
||||||
rm -f coverage.*.out
|
|
||||||
|
|
||||||
coverage: coverage.out
|
|
||||||
go tool cover -html=coverage.out
|
|
||||||
rm -f coverage.out
|
|
||||||
|
|
||||||
check: system/env
|
check: system/env
|
||||||
|
ifeq ($(RUN_LONG_TESTS), yes)
|
||||||
if [ -x travis_wait ]; then \
|
if [ -x travis_wait ]; then \
|
||||||
travis_wait gometalinter --config=linter.json ./...; \
|
travis_wait gometalinter --config=linter.json ./...; \
|
||||||
else \
|
else \
|
||||||
gometalinter --config=linter.json ./...; \
|
gometalinter --config=linter.json ./...; \
|
||||||
fi
|
fi
|
||||||
. system/env/bin/activate && flake8 --max-line-length=200 --exclude=system/env/ system/
|
. system/env/bin/activate && flake8 --max-line-length=200 --exclude=system/env/ system/
|
||||||
|
endif
|
||||||
|
|
||||||
install:
|
install:
|
||||||
go install -v -ldflags "-X main.Version=$(VERSION)"
|
go install -v -ldflags "-X main.Version=$(VERSION)"
|
||||||
|
|
||||||
system/env: system/requirements.txt
|
system/env: system/requirements.txt
|
||||||
|
ifeq ($(RUN_LONG_TESTS), yes)
|
||||||
rm -rf system/env
|
rm -rf system/env
|
||||||
virtualenv system/env
|
virtualenv system/env
|
||||||
system/env/bin/pip install -r system/requirements.txt
|
system/env/bin/pip install -r system/requirements.txt
|
||||||
|
endif
|
||||||
|
|
||||||
system-test: install system/env
|
system-test: install system/env
|
||||||
|
ifeq ($(RUN_LONG_TESTS), yes)
|
||||||
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
|
if [ ! -e ~/aptly-fixture-db ]; then git clone https://github.com/aptly-dev/aptly-fixture-db.git ~/aptly-fixture-db/; fi
|
||||||
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
|
if [ ! -e ~/aptly-fixture-pool ]; then git clone https://github.com/aptly-dev/aptly-fixture-pool.git ~/aptly-fixture-pool/; fi
|
||||||
. system/env/bin/activate && APTLY_VERSION=$(VERSION) PATH=$(BINPATH)/:$(PATH) $(PYTHON) system/run.py --long $(TESTS)
|
PATH=$(BINPATH)/:$(PATH) && . system/env/bin/activate && APTLY_VERSION=$(VERSION) $(PYTHON) system/run.py --long $(TESTS)
|
||||||
|
endif
|
||||||
travis: $(TRAVIS_TARGET) check system-test
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
ifeq ($(GO_1_10_AND_HIGHER), yes)
|
||||||
|
go test -v ./... -gocheck.v=true -race -coverprofile=coverage.txt -covermode=atomic
|
||||||
|
else
|
||||||
go test -v `go list ./... | grep -v vendor/` -gocheck.v=true
|
go test -v `go list ./... | grep -v vendor/` -gocheck.v=true
|
||||||
|
endif
|
||||||
coveralls: coverage.out
|
|
||||||
$(BINPATH)/goveralls -service travis-ci.org -coverprofile=coverage.out -repotoken=$(COVERALLS_TOKEN)
|
|
||||||
|
|
||||||
mem.png: mem.dat mem.gp
|
mem.png: mem.dat mem.gp
|
||||||
gnuplot mem.gp
|
gnuplot mem.gp
|
||||||
@@ -70,9 +58,10 @@ mem.png: mem.dat mem.gp
|
|||||||
|
|
||||||
goxc:
|
goxc:
|
||||||
rm -rf root/
|
rm -rf root/
|
||||||
mkdir -p root/usr/share/man/man1/ root/etc/bash_completion.d
|
mkdir -p root/usr/share/man/man1/ root/etc/bash_completion.d/ root/usr/share/zsh/vendor-completions/
|
||||||
cp man/aptly.1 root/usr/share/man/man1
|
cp man/aptly.1 root/usr/share/man/man1
|
||||||
cp bash_completion.d/aptly root/etc/bash_completion.d
|
cp completion.d/aptly root/etc/bash_completion.d/
|
||||||
|
cp completion.d/_aptly root/usr/share/zsh/vendor-completions/
|
||||||
gzip root/usr/share/man/man1/aptly.1
|
gzip root/usr/share/man/man1/aptly.1
|
||||||
goxc -pv=$(VERSION) -max-processors=4 $(GOXC_OPTS)
|
goxc -pv=$(VERSION) -max-processors=4 $(GOXC_OPTS)
|
||||||
|
|
||||||
@@ -82,4 +71,4 @@ man:
|
|||||||
version:
|
version:
|
||||||
@echo $(VERSION)
|
@echo $(VERSION)
|
||||||
|
|
||||||
.PHONY: coverage.out man version
|
.PHONY: man version
|
||||||
|
|||||||
+16
-12
@@ -2,17 +2,17 @@
|
|||||||
aptly
|
aptly
|
||||||
=====
|
=====
|
||||||
|
|
||||||
.. image:: https://api.travis-ci.org/smira/aptly.svg?branch=master
|
.. image:: https://api.travis-ci.org/aptly-dev/aptly.svg?branch=master
|
||||||
:target: https://travis-ci.org/smira/aptly
|
:target: https://travis-ci.org/aptly-dev/aptly
|
||||||
|
|
||||||
.. image:: https://coveralls.io/repos/smira/aptly/badge.svg?branch=master
|
.. image:: https://codecov.io/gh/aptly-dev/aptly/branch/master/graph/badge.svg
|
||||||
:target: https://coveralls.io/r/smira/aptly?branch=master
|
:target: https://codecov.io/gh/aptly-dev/aptly
|
||||||
|
|
||||||
.. image:: https://badges.gitter.im/Join Chat.svg
|
.. image:: https://badges.gitter.im/Join Chat.svg
|
||||||
:target: https://gitter.im/smira/aptly?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
:target: https://gitter.im/aptly-dev/aptly?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
||||||
|
|
||||||
.. image:: http://goreportcard.com/badge/smira/aptly
|
.. image:: http://goreportcard.com/badge/aptly-dev/aptly
|
||||||
:target: http://goreportcard.com/report/smira/aptly
|
:target: http://goreportcard.com/report/aptly-dev/aptly
|
||||||
|
|
||||||
Aptly is a swiss army knife for Debian repository management.
|
Aptly is a swiss army knife for Debian repository management.
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ To install aptly on Debian/Ubuntu, add new repository to ``/etc/apt/sources.list
|
|||||||
|
|
||||||
And import key that is used to sign the release::
|
And import key that is used to sign the release::
|
||||||
|
|
||||||
$ apt-key adv --keyserver keys.gnupg.net --recv-keys 9E3E53F19C7DE460
|
$ apt-key adv --keyserver pool.sks-keyservers.net --recv-keys ED75B5A4483DA07C
|
||||||
|
|
||||||
After that you can install aptly as any other software package::
|
After that you can install aptly as any other software package::
|
||||||
|
|
||||||
@@ -64,11 +64,11 @@ If you would like to use nightly builds (unstable), please use following reposit
|
|||||||
|
|
||||||
Binary executables (depends almost only on libc) are available for download from `Bintray <http://dl.bintray.com/smira/aptly/>`_.
|
Binary executables (depends almost only on libc) are available for download from `Bintray <http://dl.bintray.com/smira/aptly/>`_.
|
||||||
|
|
||||||
If you have Go environment set up, you can build aptly from source by running (go 1.6+ required)::
|
If you have Go environment set up, you can build aptly from source by running (go 1.8+ required)::
|
||||||
|
|
||||||
mkdir -p $GOPATH/src/github.com/smira/aptly
|
mkdir -p $GOPATH/src/github.com/aptly-dev/aptly
|
||||||
git clone https://github.com/smira/aptly $GOPATH/src/github.com/smira/aptly
|
git clone https://github.com/aptly-dev/aptly $GOPATH/src/github.com/aptly-dev/aptly
|
||||||
cd $GOPATH/src/github.com/smira/aptly
|
cd $GOPATH/src/github.com/aptly-dev/aptly
|
||||||
make install
|
make install
|
||||||
|
|
||||||
Binary would be installed to ```$GOPATH/bin/aptly``.
|
Binary would be installed to ```$GOPATH/bin/aptly``.
|
||||||
@@ -109,6 +109,10 @@ CLI for aptly API:
|
|||||||
- `Ruby aptly CLI/library <https://github.com/sepulworld/aptly_cli>`_ by Zane Williamson
|
- `Ruby aptly CLI/library <https://github.com/sepulworld/aptly_cli>`_ by Zane Williamson
|
||||||
- `Python aptly CLI (good for CI) <https://github.com/TimSusa/aptly_api_cli>`_ by Tim Susa
|
- `Python aptly CLI (good for CI) <https://github.com/TimSusa/aptly_api_cli>`_ by Tim Susa
|
||||||
|
|
||||||
|
GUI for aptly API:
|
||||||
|
|
||||||
|
- `Python aptly GUI (via pyqt5) <https://github.com/chnyda/python-aptly-gui>`_ by Cedric Hnyda
|
||||||
|
|
||||||
Scala sbt:
|
Scala sbt:
|
||||||
|
|
||||||
- `sbt aptly plugin <https://github.com/amalakar/sbt-aptly>`_ by Arup Malakar
|
- `sbt aptly plugin <https://github.com/amalakar/sbt-aptly>`_ by Arup Malakar
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/smira/aptly/cmd"
|
"github.com/aptly-dev/aptly/cmd"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+7
-7
@@ -6,10 +6,10 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
|
"github.com/aptly-dev/aptly/deb"
|
||||||
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/smira/aptly/aptly"
|
|
||||||
"github.com/smira/aptly/deb"
|
|
||||||
"github.com/smira/aptly/query"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Lock order acquisition (canonical):
|
// Lock order acquisition (canonical):
|
||||||
@@ -112,7 +112,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList) {
|
|||||||
|
|
||||||
list, err := deb.NewPackageListFromRefList(reflist, context.CollectionFactory().PackageCollection(), nil)
|
list, err := deb.NewPackageListFromRefList(reflist, context.CollectionFactory().PackageCollection(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList) {
|
|||||||
if queryS != "" {
|
if queryS != "" {
|
||||||
q, err := query.Parse(c.Request.URL.Query().Get("q"))
|
q, err := query.Parse(c.Request.URL.Query().Get("q"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList) {
|
|||||||
sort.Strings(architecturesList)
|
sort.Strings(architecturesList)
|
||||||
|
|
||||||
if len(architecturesList) == 0 {
|
if len(architecturesList) == 0 {
|
||||||
c.Fail(400, fmt.Errorf("unable to determine list of architectures, please specify explicitly"))
|
c.AbortWithError(400, fmt.Errorf("unable to determine list of architectures, please specify explicitly"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ func showPackages(c *gin.Context, reflist *deb.PackageRefList) {
|
|||||||
list, err = list.Filter([]deb.PackageQuery{q}, withDeps,
|
list, err = list.Filter([]deb.PackageQuery{q}, withDeps,
|
||||||
nil, context.DependencyOptions(), architecturesList)
|
nil, context.DependencyOptions(), architecturesList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to search: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to search: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -24,7 +24,7 @@ func verifyPath(path string) bool {
|
|||||||
|
|
||||||
func verifyDir(c *gin.Context) bool {
|
func verifyDir(c *gin.Context) bool {
|
||||||
if !verifyPath(c.Params.ByName("dir")) {
|
if !verifyPath(c.Params.ByName("dir")) {
|
||||||
c.Fail(400, fmt.Errorf("wrong dir"))
|
c.AbortWithError(400, fmt.Errorf("wrong dir"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ func apiFilesListDirs(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +70,13 @@ func apiFilesUpload(c *gin.Context) {
|
|||||||
err := os.MkdirAll(path, 0777)
|
err := os.MkdirAll(path, 0777)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.Request.ParseMultipartForm(10 * 1024 * 1024)
|
err = c.Request.ParseMultipartForm(10 * 1024 * 1024)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ func apiFilesUpload(c *gin.Context) {
|
|||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
src, err := file.Open()
|
src, err := file.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer src.Close()
|
defer src.Close()
|
||||||
@@ -94,14 +94,14 @@ func apiFilesUpload(c *gin.Context) {
|
|||||||
destPath := filepath.Join(path, filepath.Base(file.Filename))
|
destPath := filepath.Join(path, filepath.Base(file.Filename))
|
||||||
dst, err := os.Create(destPath)
|
dst, err := os.Create(destPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer dst.Close()
|
defer dst.Close()
|
||||||
|
|
||||||
_, err = io.Copy(dst, src)
|
_, err = io.Copy(dst, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,9 +138,9 @@ func apiFilesListFiles(c *gin.Context) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
} else {
|
} else {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ func apiFilesDeleteDir(c *gin.Context) {
|
|||||||
|
|
||||||
err := os.RemoveAll(filepath.Join(context.UploadPath(), c.Params.ByName("dir")))
|
err := os.RemoveAll(filepath.Join(context.UploadPath(), c.Params.ByName("dir")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,14 +170,14 @@ func apiFilesDeleteFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !verifyPath(c.Params.ByName("name")) {
|
if !verifyPath(c.Params.ByName("name")) {
|
||||||
c.Fail(400, fmt.Errorf("wrong file"))
|
c.AbortWithError(400, fmt.Errorf("wrong file"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := os.Remove(filepath.Join(context.UploadPath(), c.Params.ByName("dir"), c.Params.ByName("name")))
|
err := os.Remove(filepath.Join(context.UploadPath(), c.Params.ByName("dir"), c.Params.ByName("name")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err1, ok := err.(*os.PathError); !ok || !os.IsNotExist(err1.Err) {
|
if err1, ok := err.(*os.PathError); !ok || !os.IsNotExist(err1.Err) {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -8,8 +8,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/smira/aptly/deb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GET /api/graph.:ext?layout=[vertical|horizontal(default)]
|
// GET /api/graph.:ext?layout=[vertical|horizontal(default)]
|
||||||
@@ -24,14 +24,14 @@ func apiGraph(c *gin.Context) {
|
|||||||
|
|
||||||
factory := context.CollectionFactory()
|
factory := context.CollectionFactory()
|
||||||
|
|
||||||
factory.RemoteRepoCollection().RLock()
|
factory.RemoteRepoCollection().Lock()
|
||||||
defer factory.RemoteRepoCollection().RUnlock()
|
defer factory.RemoteRepoCollection().Unlock()
|
||||||
factory.LocalRepoCollection().RLock()
|
factory.LocalRepoCollection().Lock()
|
||||||
defer factory.LocalRepoCollection().RUnlock()
|
defer factory.LocalRepoCollection().Unlock()
|
||||||
factory.SnapshotCollection().RLock()
|
factory.SnapshotCollection().Lock()
|
||||||
defer factory.SnapshotCollection().RUnlock()
|
defer factory.SnapshotCollection().Unlock()
|
||||||
factory.PublishedRepoCollection().RLock()
|
factory.PublishedRepoCollection().Lock()
|
||||||
defer factory.PublishedRepoCollection().RUnlock()
|
defer factory.PublishedRepoCollection().Unlock()
|
||||||
|
|
||||||
graph, err := deb.BuildGraph(factory, layout)
|
graph, err := deb.BuildGraph(factory, layout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -53,25 +53,25 @@ func apiGraph(c *gin.Context) {
|
|||||||
|
|
||||||
stdin, err := command.StdinPipe()
|
stdin, err := command.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = io.Copy(stdin, buf)
|
_, err = io.Copy(stdin, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = stdin.Close()
|
err = stdin.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err = command.Output()
|
output, err = command.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to execute dot: %s (is graphviz package installed?)", err))
|
c.AbortWithError(500, fmt.Errorf("unable to execute dot: %s (is graphviz package installed?)", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
|||||||
func apiPackagesShow(c *gin.Context) {
|
func apiPackagesShow(c *gin.Context) {
|
||||||
p, err := context.CollectionFactory().PackageCollection().ByKey([]byte(c.Params.ByName("key")))
|
p, err := context.CollectionFactory().PackageCollection().ByKey([]byte(c.Params.ByName("key")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+60
-46
@@ -4,10 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/deb"
|
||||||
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/smira/aptly/deb"
|
|
||||||
"github.com/smira/aptly/pgp"
|
|
||||||
"github.com/smira/aptly/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SigningOptions is a shared between publish API GPG options structure
|
// SigningOptions is a shared between publish API GPG options structure
|
||||||
@@ -60,8 +60,8 @@ func apiPublishList(c *gin.Context) {
|
|||||||
defer snapshotCollection.RUnlock()
|
defer snapshotCollection.RUnlock()
|
||||||
|
|
||||||
collection := context.CollectionFactory().PublishedRepoCollection()
|
collection := context.CollectionFactory().PublishedRepoCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
result := make([]*deb.PublishedRepo, 0, collection.Len())
|
result := make([]*deb.PublishedRepo, 0, collection.Len())
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ func apiPublishList(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,20 +104,21 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
SkipContents *bool
|
SkipContents *bool
|
||||||
Architectures []string
|
Architectures []string
|
||||||
Signing SigningOptions
|
Signing SigningOptions
|
||||||
|
AcquireByHash *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
signer, err := getSigner(&b.Signing)
|
signer, err := getSigner(&b.Signing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to initialize GPG signer: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to initialize GPG signer: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(b.Sources) == 0 {
|
if len(b.Sources) == 0 {
|
||||||
c.Fail(400, fmt.Errorf("unable to publish: soures are empty"))
|
c.AbortWithError(400, fmt.Errorf("unable to publish: soures are empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,21 +129,21 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
var snapshot *deb.Snapshot
|
var snapshot *deb.Snapshot
|
||||||
|
|
||||||
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
||||||
snapshotCollection.RLock()
|
snapshotCollection.Lock()
|
||||||
defer snapshotCollection.RUnlock()
|
defer snapshotCollection.Unlock()
|
||||||
|
|
||||||
for _, source := range b.Sources {
|
for _, source := range b.Sources {
|
||||||
components = append(components, source.Component)
|
components = append(components, source.Component)
|
||||||
|
|
||||||
snapshot, err = snapshotCollection.ByName(source.Name)
|
snapshot, err = snapshotCollection.ByName(source.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, fmt.Errorf("unable to publish: %s", err))
|
c.AbortWithError(404, fmt.Errorf("unable to publish: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snapshotCollection.LoadComplete(snapshot)
|
err = snapshotCollection.LoadComplete(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to publish: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to publish: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,27 +153,27 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
var localRepo *deb.LocalRepo
|
var localRepo *deb.LocalRepo
|
||||||
|
|
||||||
localCollection := context.CollectionFactory().LocalRepoCollection()
|
localCollection := context.CollectionFactory().LocalRepoCollection()
|
||||||
localCollection.RLock()
|
localCollection.Lock()
|
||||||
defer localCollection.RUnlock()
|
defer localCollection.Unlock()
|
||||||
|
|
||||||
for _, source := range b.Sources {
|
for _, source := range b.Sources {
|
||||||
components = append(components, source.Component)
|
components = append(components, source.Component)
|
||||||
|
|
||||||
localRepo, err = localCollection.ByName(source.Name)
|
localRepo, err = localCollection.ByName(source.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, fmt.Errorf("unable to publish: %s", err))
|
c.AbortWithError(404, fmt.Errorf("unable to publish: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = localCollection.LoadComplete(localRepo)
|
err = localCollection.LoadComplete(localRepo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to publish: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to publish: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
sources = append(sources, localRepo)
|
sources = append(sources, localRepo)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.Fail(400, fmt.Errorf("unknown SourceKind"))
|
c.AbortWithError(400, fmt.Errorf("unknown SourceKind"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
|
|
||||||
published, err := deb.NewPublishedRepo(storage, prefix, b.Distribution, b.Architectures, components, sources, context.CollectionFactory())
|
published, err := deb.NewPublishedRepo(storage, prefix, b.Distribution, b.Architectures, components, sources, context.CollectionFactory())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to publish: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to publish: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if b.Origin != "" {
|
if b.Origin != "" {
|
||||||
@@ -201,22 +202,26 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
|
|||||||
published.SkipContents = *b.SkipContents
|
published.SkipContents = *b.SkipContents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if b.AcquireByHash != nil {
|
||||||
|
published.AcquireByHash = *b.AcquireByHash
|
||||||
|
}
|
||||||
|
|
||||||
duplicate := collection.CheckDuplicate(published)
|
duplicate := collection.CheckDuplicate(published)
|
||||||
if duplicate != nil {
|
if duplicate != nil {
|
||||||
context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory())
|
context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory())
|
||||||
c.Fail(400, fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate))
|
c.AbortWithError(400, fmt.Errorf("prefix/distribution already used by another published repo: %s", duplicate))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite)
|
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to publish: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to publish: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.Add(published)
|
err = collection.Add(published)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to save to DB: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to save to DB: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,30 +238,32 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
ForceOverwrite bool
|
ForceOverwrite bool
|
||||||
Signing SigningOptions
|
Signing SigningOptions
|
||||||
SkipContents *bool
|
SkipContents *bool
|
||||||
|
SkipCleanup *bool
|
||||||
Snapshots []struct {
|
Snapshots []struct {
|
||||||
Component string `binding:"required"`
|
Component string `binding:"required"`
|
||||||
Name string `binding:"required"`
|
Name string `binding:"required"`
|
||||||
}
|
}
|
||||||
|
AcquireByHash *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
signer, err := getSigner(&b.Signing)
|
signer, err := getSigner(&b.Signing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to initialize GPG signer: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to initialize GPG signer: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// published.LoadComplete would touch local repo collection
|
// published.LoadComplete would touch local repo collection
|
||||||
localRepoCollection := context.CollectionFactory().LocalRepoCollection()
|
localRepoCollection := context.CollectionFactory().LocalRepoCollection()
|
||||||
localRepoCollection.RLock()
|
localRepoCollection.Lock()
|
||||||
defer localRepoCollection.RUnlock()
|
defer localRepoCollection.Unlock()
|
||||||
|
|
||||||
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
||||||
snapshotCollection.RLock()
|
snapshotCollection.Lock()
|
||||||
defer snapshotCollection.RUnlock()
|
defer snapshotCollection.Unlock()
|
||||||
|
|
||||||
collection := context.CollectionFactory().PublishedRepoCollection()
|
collection := context.CollectionFactory().PublishedRepoCollection()
|
||||||
collection.Lock()
|
collection.Lock()
|
||||||
@@ -264,12 +271,12 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
|
|
||||||
published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
|
published, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, fmt.Errorf("unable to update: %s", err))
|
c.AbortWithError(404, fmt.Errorf("unable to update: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = collection.LoadComplete(published, context.CollectionFactory())
|
err = collection.LoadComplete(published, context.CollectionFactory())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to update: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to update: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +284,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
|
|
||||||
if published.SourceKind == deb.SourceLocalRepo {
|
if published.SourceKind == deb.SourceLocalRepo {
|
||||||
if len(b.Snapshots) > 0 {
|
if len(b.Snapshots) > 0 {
|
||||||
c.Fail(400, fmt.Errorf("snapshots shouldn't be given when updating local repo"))
|
c.AbortWithError(400, fmt.Errorf("snapshots shouldn't be given when updating local repo"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updatedComponents = published.Components()
|
updatedComponents = published.Components()
|
||||||
@@ -288,19 +295,19 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
publishedComponents := published.Components()
|
publishedComponents := published.Components()
|
||||||
for _, snapshotInfo := range b.Snapshots {
|
for _, snapshotInfo := range b.Snapshots {
|
||||||
if !utils.StrSliceHasItem(publishedComponents, snapshotInfo.Component) {
|
if !utils.StrSliceHasItem(publishedComponents, snapshotInfo.Component) {
|
||||||
c.Fail(404, fmt.Errorf("component %s is not in published repository", snapshotInfo.Component))
|
c.AbortWithError(404, fmt.Errorf("component %s is not in published repository", snapshotInfo.Component))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot, err2 := snapshotCollection.ByName(snapshotInfo.Name)
|
snapshot, err2 := snapshotCollection.ByName(snapshotInfo.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err2)
|
c.AbortWithError(404, err2)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err2 = snapshotCollection.LoadComplete(snapshot)
|
err2 = snapshotCollection.LoadComplete(snapshot)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
c.Fail(500, err2)
|
c.AbortWithError(500, err2)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +315,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
updatedComponents = append(updatedComponents, snapshotInfo.Component)
|
updatedComponents = append(updatedComponents, snapshotInfo.Component)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.Fail(500, fmt.Errorf("unknown published repository type"))
|
c.AbortWithError(500, fmt.Errorf("unknown published repository type"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,23 +323,29 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
published.SkipContents = *b.SkipContents
|
published.SkipContents = *b.SkipContents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if b.AcquireByHash != nil {
|
||||||
|
published.AcquireByHash = *b.AcquireByHash
|
||||||
|
}
|
||||||
|
|
||||||
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite)
|
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to update: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to update: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.Update(published)
|
err = collection.Update(published)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to save to DB: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to save to DB: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.CleanupPrefixComponentFiles(published.Prefix, updatedComponents,
|
if b.SkipCleanup == nil || !*b.SkipCleanup {
|
||||||
context.GetPublishedStorage(storage), context.CollectionFactory(), nil)
|
err = collection.CleanupPrefixComponentFiles(published.Prefix, updatedComponents,
|
||||||
if err != nil {
|
context.GetPublishedStorage(storage), context.CollectionFactory(), nil)
|
||||||
c.Fail(500, fmt.Errorf("unable to update: %s", err))
|
if err != nil {
|
||||||
return
|
c.AbortWithError(500, fmt.Errorf("unable to update: %s", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(200, published)
|
c.JSON(200, published)
|
||||||
@@ -341,6 +354,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
|
|||||||
// DELETE /publish/:prefix/:distribution
|
// DELETE /publish/:prefix/:distribution
|
||||||
func apiPublishDrop(c *gin.Context) {
|
func apiPublishDrop(c *gin.Context) {
|
||||||
force := c.Request.URL.Query().Get("force") == "1"
|
force := c.Request.URL.Query().Get("force") == "1"
|
||||||
|
skipCleanup := c.Request.URL.Query().Get("SkipCleanup") == "1"
|
||||||
|
|
||||||
param := parseEscapedPath(c.Params.ByName("prefix"))
|
param := parseEscapedPath(c.Params.ByName("prefix"))
|
||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
@@ -348,17 +362,17 @@ func apiPublishDrop(c *gin.Context) {
|
|||||||
|
|
||||||
// published.LoadComplete would touch local repo collection
|
// published.LoadComplete would touch local repo collection
|
||||||
localRepoCollection := context.CollectionFactory().LocalRepoCollection()
|
localRepoCollection := context.CollectionFactory().LocalRepoCollection()
|
||||||
localRepoCollection.RLock()
|
localRepoCollection.Lock()
|
||||||
defer localRepoCollection.RUnlock()
|
defer localRepoCollection.Unlock()
|
||||||
|
|
||||||
collection := context.CollectionFactory().PublishedRepoCollection()
|
collection := context.CollectionFactory().PublishedRepoCollection()
|
||||||
collection.Lock()
|
collection.Lock()
|
||||||
defer collection.Unlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
err := collection.Remove(context, storage, prefix, distribution,
|
err := collection.Remove(context, storage, prefix, distribution,
|
||||||
context.CollectionFactory(), context.Progress(), force)
|
context.CollectionFactory(), context.Progress(), force, skipCleanup)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to drop: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to drop: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+36
-33
@@ -5,11 +5,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
|
"github.com/aptly-dev/aptly/database"
|
||||||
|
"github.com/aptly-dev/aptly/deb"
|
||||||
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/smira/aptly/aptly"
|
|
||||||
"github.com/smira/aptly/database"
|
|
||||||
"github.com/smira/aptly/deb"
|
|
||||||
"github.com/smira/aptly/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GET /api/repos
|
// GET /api/repos
|
||||||
@@ -37,7 +37,7 @@ func apiReposCreate(c *gin.Context) {
|
|||||||
DefaultComponent string
|
DefaultComponent string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ func apiReposCreate(c *gin.Context) {
|
|||||||
|
|
||||||
err := context.CollectionFactory().LocalRepoCollection().Add(repo)
|
err := context.CollectionFactory().LocalRepoCollection().Add(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ func apiReposEdit(c *gin.Context) {
|
|||||||
DefaultComponent *string
|
DefaultComponent *string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ func apiReposEdit(c *gin.Context) {
|
|||||||
|
|
||||||
repo, err := collection.ByName(c.Params.ByName("name"))
|
repo, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ func apiReposEdit(c *gin.Context) {
|
|||||||
|
|
||||||
err = collection.Update(repo)
|
err = collection.Update(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ func apiReposShow(c *gin.Context) {
|
|||||||
|
|
||||||
repo, err := collection.ByName(c.Params.ByName("name"))
|
repo, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,27 +132,27 @@ func apiReposDrop(c *gin.Context) {
|
|||||||
|
|
||||||
repo, err := collection.ByName(c.Params.ByName("name"))
|
repo, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
published := publishedCollection.ByLocalRepo(repo)
|
published := publishedCollection.ByLocalRepo(repo)
|
||||||
if len(published) > 0 {
|
if len(published) > 0 {
|
||||||
c.Fail(409, fmt.Errorf("unable to drop, local repo is published"))
|
c.AbortWithError(409, fmt.Errorf("unable to drop, local repo is published"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !force {
|
if !force {
|
||||||
snapshots := snapshotCollection.ByLocalRepoSource(repo)
|
snapshots := snapshotCollection.ByLocalRepoSource(repo)
|
||||||
if len(snapshots) > 0 {
|
if len(snapshots) > 0 {
|
||||||
c.Fail(409, fmt.Errorf("unable to drop, local repo has snapshots, use ?force=1 to override"))
|
c.AbortWithError(409, fmt.Errorf("unable to drop, local repo has snapshots, use ?force=1 to override"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.Drop(repo)
|
err = collection.Drop(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,18 +162,18 @@ func apiReposDrop(c *gin.Context) {
|
|||||||
// GET /api/repos/:name/packages
|
// GET /api/repos/:name/packages
|
||||||
func apiReposPackagesShow(c *gin.Context) {
|
func apiReposPackagesShow(c *gin.Context) {
|
||||||
collection := context.CollectionFactory().LocalRepoCollection()
|
collection := context.CollectionFactory().LocalRepoCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
repo, err := collection.ByName(c.Params.ByName("name"))
|
repo, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(repo)
|
err = collection.LoadComplete(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ func apiReposPackagesAddDelete(c *gin.Context, cb func(list *deb.PackageList, p
|
|||||||
PackageRefs []string
|
PackageRefs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,19 +196,19 @@ func apiReposPackagesAddDelete(c *gin.Context, cb func(list *deb.PackageList, p
|
|||||||
|
|
||||||
repo, err := collection.ByName(c.Params.ByName("name"))
|
repo, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(repo)
|
err = collection.LoadComplete(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
list, err := deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), nil)
|
list, err := deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,15 +219,15 @@ func apiReposPackagesAddDelete(c *gin.Context, cb func(list *deb.PackageList, p
|
|||||||
p, err = context.CollectionFactory().PackageCollection().ByKey([]byte(ref))
|
p, err = context.CollectionFactory().PackageCollection().ByKey([]byte(ref))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == database.ErrNotFound {
|
if err == database.ErrNotFound {
|
||||||
c.Fail(404, fmt.Errorf("package %s: %s", ref, err))
|
c.AbortWithError(404, fmt.Errorf("package %s: %s", ref, err))
|
||||||
} else {
|
} else {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = cb(list, p)
|
err = cb(list, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ func apiReposPackagesAddDelete(c *gin.Context, cb func(list *deb.PackageList, p
|
|||||||
|
|
||||||
err = context.CollectionFactory().LocalRepoCollection().Update(repo)
|
err = context.CollectionFactory().LocalRepoCollection().Update(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to save: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to save: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
|
|
||||||
fileParam := c.Params.ByName("file")
|
fileParam := c.Params.ByName("file")
|
||||||
if fileParam != "" && !verifyPath(fileParam) {
|
if fileParam != "" && !verifyPath(fileParam) {
|
||||||
c.Fail(400, fmt.Errorf("wrong file"))
|
c.AbortWithError(400, fmt.Errorf("wrong file"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,13 +286,13 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
|
|
||||||
repo, err := collection.ByName(c.Params.ByName("name"))
|
repo, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(repo)
|
err = collection.LoadComplete(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +301,7 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
sources []string
|
sources []string
|
||||||
packageFiles, failedFiles []string
|
packageFiles, failedFiles []string
|
||||||
|
otherFiles []string
|
||||||
processedFiles, failedFiles2 []string
|
processedFiles, failedFiles2 []string
|
||||||
reporter = &aptly.RecordingResultReporter{
|
reporter = &aptly.RecordingResultReporter{
|
||||||
Warnings: []string{},
|
Warnings: []string{},
|
||||||
@@ -316,11 +317,11 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
sources = []string{filepath.Join(context.UploadPath(), c.Params.ByName("dir"), c.Params.ByName("file"))}
|
sources = []string{filepath.Join(context.UploadPath(), c.Params.ByName("dir"), c.Params.ByName("file"))}
|
||||||
}
|
}
|
||||||
|
|
||||||
packageFiles, failedFiles = deb.CollectPackageFiles(sources, reporter)
|
packageFiles, otherFiles, failedFiles = deb.CollectPackageFiles(sources, reporter)
|
||||||
|
|
||||||
list, err = deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), nil)
|
list, err = deb.NewPackageListFromRefList(repo.RefList(), context.CollectionFactory().PackageCollection(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to load packages: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to load packages: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,8 +329,10 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
context.CollectionFactory().PackageCollection(), reporter, nil, context.CollectionFactory().ChecksumCollection())
|
context.CollectionFactory().PackageCollection(), reporter, nil, context.CollectionFactory().ChecksumCollection())
|
||||||
failedFiles = append(failedFiles, failedFiles2...)
|
failedFiles = append(failedFiles, failedFiles2...)
|
||||||
|
|
||||||
|
processedFiles = append(processedFiles, otherFiles...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to import package files: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to import package files: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +340,7 @@ func apiReposPackageFromDir(c *gin.Context) {
|
|||||||
|
|
||||||
err = context.CollectionFactory().LocalRepoCollection().Update(repo)
|
err = context.CollectionFactory().LocalRepoCollection().Update(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, fmt.Errorf("unable to save: %s", err))
|
c.AbortWithError(500, fmt.Errorf("unable to save: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -3,8 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
ctx "github.com/aptly-dev/aptly/context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
ctx "github.com/smira/aptly/context"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var context *ctx.AptlyContext
|
var context *ctx.AptlyContext
|
||||||
@@ -32,7 +32,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
|||||||
|
|
||||||
err = <-errCh
|
err = <-errCh
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ func Router(c *ctx.AptlyContext) http.Handler {
|
|||||||
requests <- dbRequest{releasedb, errCh}
|
requests <- dbRequest{releasedb, errCh}
|
||||||
err = <-errCh
|
err = <-errCh
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
+47
-47
@@ -3,9 +3,9 @@ package api
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/database"
|
||||||
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/smira/aptly/database"
|
|
||||||
"github.com/smira/aptly/deb"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GET /api/snapshots
|
// GET /api/snapshots
|
||||||
@@ -42,13 +42,13 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
collection := context.CollectionFactory().RemoteRepoCollection()
|
collection := context.CollectionFactory().RemoteRepoCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
||||||
snapshotCollection.Lock()
|
snapshotCollection.Lock()
|
||||||
@@ -56,25 +56,25 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) {
|
|||||||
|
|
||||||
repo, err = collection.ByName(c.Params.ByName("name"))
|
repo, err = collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.CheckLock()
|
err = repo.CheckLock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(409, err)
|
c.AbortWithError(409, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(repo)
|
err = collection.LoadComplete(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot, err = deb.NewSnapshotFromRepository(b.Name, repo)
|
snapshot, err = deb.NewSnapshotFromRepository(b.Name, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ func apiSnapshotsCreateFromMirror(c *gin.Context) {
|
|||||||
|
|
||||||
err = snapshotCollection.Add(snapshot)
|
err = snapshotCollection.Add(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ func apiSnapshotsCreate(c *gin.Context) {
|
|||||||
PackageRefs []string
|
PackageRefs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,13 +124,13 @@ func apiSnapshotsCreate(c *gin.Context) {
|
|||||||
for i := range b.SourceSnapshots {
|
for i := range b.SourceSnapshots {
|
||||||
sources[i], err = snapshotCollection.ByName(b.SourceSnapshots[i])
|
sources[i], err = snapshotCollection.ByName(b.SourceSnapshots[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snapshotCollection.LoadComplete(sources[i])
|
err = snapshotCollection.LoadComplete(sources[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,15 +144,15 @@ func apiSnapshotsCreate(c *gin.Context) {
|
|||||||
p, err = context.CollectionFactory().PackageCollection().ByKey([]byte(ref))
|
p, err = context.CollectionFactory().PackageCollection().ByKey([]byte(ref))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == database.ErrNotFound {
|
if err == database.ErrNotFound {
|
||||||
c.Fail(404, fmt.Errorf("package %s: %s", ref, err))
|
c.AbortWithError(404, fmt.Errorf("package %s: %s", ref, err))
|
||||||
} else {
|
} else {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = list.Add(p)
|
err = list.Add(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ func apiSnapshotsCreate(c *gin.Context) {
|
|||||||
|
|
||||||
err = snapshotCollection.Add(snapshot)
|
err = snapshotCollection.Add(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,13 +181,13 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
collection := context.CollectionFactory().LocalRepoCollection()
|
collection := context.CollectionFactory().LocalRepoCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
snapshotCollection := context.CollectionFactory().SnapshotCollection()
|
||||||
snapshotCollection.Lock()
|
snapshotCollection.Lock()
|
||||||
@@ -195,19 +195,19 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) {
|
|||||||
|
|
||||||
repo, err = collection.ByName(c.Params.ByName("name"))
|
repo, err = collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(repo)
|
err = collection.LoadComplete(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot, err = deb.NewSnapshotFromLocalRepo(b.Name, repo)
|
snapshot, err = deb.NewSnapshotFromLocalRepo(b.Name, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ func apiSnapshotsCreateFromRepository(c *gin.Context) {
|
|||||||
|
|
||||||
err = snapshotCollection.Add(snapshot)
|
err = snapshotCollection.Add(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ func apiSnapshotsUpdate(c *gin.Context) {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
if c.Bind(&b) != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,13 +246,13 @@ func apiSnapshotsUpdate(c *gin.Context) {
|
|||||||
|
|
||||||
snapshot, err = collection.ByName(c.Params.ByName("name"))
|
snapshot, err = collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = collection.ByName(b.Name)
|
_, err = collection.ByName(b.Name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
c.Fail(409, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name))
|
c.AbortWithError(409, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ func apiSnapshotsUpdate(c *gin.Context) {
|
|||||||
|
|
||||||
err = context.CollectionFactory().SnapshotCollection().Update(snapshot)
|
err = context.CollectionFactory().SnapshotCollection().Update(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,18 +276,18 @@ func apiSnapshotsUpdate(c *gin.Context) {
|
|||||||
// GET /api/snapshots/:name
|
// GET /api/snapshots/:name
|
||||||
func apiSnapshotsShow(c *gin.Context) {
|
func apiSnapshotsShow(c *gin.Context) {
|
||||||
collection := context.CollectionFactory().SnapshotCollection()
|
collection := context.CollectionFactory().SnapshotCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
snapshot, err := collection.ByName(c.Params.ByName("name"))
|
snapshot, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(snapshot)
|
err = collection.LoadComplete(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,28 +309,28 @@ func apiSnapshotsDrop(c *gin.Context) {
|
|||||||
|
|
||||||
snapshot, err := snapshotCollection.ByName(name)
|
snapshot, err := snapshotCollection.ByName(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
published := publishedCollection.BySnapshot(snapshot)
|
published := publishedCollection.BySnapshot(snapshot)
|
||||||
|
|
||||||
if len(published) > 0 {
|
if len(published) > 0 {
|
||||||
c.Fail(409, fmt.Errorf("unable to drop: snapshot is published"))
|
c.AbortWithError(409, fmt.Errorf("unable to drop: snapshot is published"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !force {
|
if !force {
|
||||||
snapshots := snapshotCollection.BySnapshotSource(snapshot)
|
snapshots := snapshotCollection.BySnapshotSource(snapshot)
|
||||||
if len(snapshots) > 0 {
|
if len(snapshots) > 0 {
|
||||||
c.Fail(409, fmt.Errorf("won't delete snapshot that was used as source for other snapshots, use ?force=1 to override"))
|
c.AbortWithError(409, fmt.Errorf("won't delete snapshot that was used as source for other snapshots, use ?force=1 to override"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snapshotCollection.Drop(snapshot)
|
err = snapshotCollection.Drop(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,37 +342,37 @@ func apiSnapshotsDiff(c *gin.Context) {
|
|||||||
onlyMatching := c.Request.URL.Query().Get("onlyMatching") == "1"
|
onlyMatching := c.Request.URL.Query().Get("onlyMatching") == "1"
|
||||||
|
|
||||||
collection := context.CollectionFactory().SnapshotCollection()
|
collection := context.CollectionFactory().SnapshotCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
snapshotA, err := collection.ByName(c.Params.ByName("name"))
|
snapshotA, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshotB, err := collection.ByName(c.Params.ByName("withSnapshot"))
|
snapshotB, err := collection.ByName(c.Params.ByName("withSnapshot"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(snapshotA)
|
err = collection.LoadComplete(snapshotA)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(snapshotB)
|
err = collection.LoadComplete(snapshotB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate diff
|
// Calculate diff
|
||||||
diff, err := snapshotA.RefList().Diff(snapshotB.RefList(), context.CollectionFactory().PackageCollection())
|
diff, err := snapshotA.RefList().Diff(snapshotB.RefList(), context.CollectionFactory().PackageCollection())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,18 +392,18 @@ func apiSnapshotsDiff(c *gin.Context) {
|
|||||||
// GET /api/snapshots/:name/packages
|
// GET /api/snapshots/:name/packages
|
||||||
func apiSnapshotsSearchPackages(c *gin.Context) {
|
func apiSnapshotsSearchPackages(c *gin.Context) {
|
||||||
collection := context.CollectionFactory().SnapshotCollection()
|
collection := context.CollectionFactory().SnapshotCollection()
|
||||||
collection.RLock()
|
collection.Lock()
|
||||||
defer collection.RUnlock()
|
defer collection.Unlock()
|
||||||
|
|
||||||
snapshot, err := collection.ByName(c.Params.ByName("name"))
|
snapshot, err := collection.ByName(c.Params.ByName("name"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(404, err)
|
c.AbortWithError(404, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.LoadComplete(snapshot)
|
err = collection.LoadComplete(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fail(500, err)
|
c.AbortWithError(500, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=APT repository API
|
||||||
|
After=network.target
|
||||||
|
Documentation=man:aptly(1)
|
||||||
|
Documentation=https://www.aptly.info/doc/api/
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/aptly serve api -no-lock -listen=127.0.0.1:8081
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=APT repository server
|
||||||
|
After=network.target
|
||||||
|
Documentation=man:aptly(1)
|
||||||
|
Documentation=https://www.aptly.info/doc/commands/
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/aptly serve -listen=127.0.0.1:8080
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
+13
-4
@@ -3,10 +3,11 @@
|
|||||||
package aptly
|
package aptly
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReadSeekerCloser = ReadSeeker + Closer
|
// ReadSeekerCloser = ReadSeeker + Closer
|
||||||
@@ -23,7 +24,7 @@ type PackagePool interface {
|
|||||||
//
|
//
|
||||||
// if poolPath is empty, poolPath is generated automatically based on checksum info (if available)
|
// if poolPath is empty, poolPath is generated automatically based on checksum info (if available)
|
||||||
// in any case, if function returns true, it also fills back checksums with complete information about the file in the pool
|
// in any case, if function returns true, it also fills back checksums with complete information about the file in the pool
|
||||||
Verify(poolPath, basename string, checksums *utils.ChecksumInfo, checksumStorage ChecksumStorage) (bool, error)
|
Verify(poolPath, basename string, checksums *utils.ChecksumInfo, checksumStorage ChecksumStorage) (string, bool, error)
|
||||||
// Import copies file into package pool
|
// Import copies file into package pool
|
||||||
//
|
//
|
||||||
// - srcPath is full path to source file as it is now
|
// - srcPath is full path to source file as it is now
|
||||||
@@ -73,6 +74,14 @@ type PublishedStorage interface {
|
|||||||
Filelist(prefix string) ([]string, error)
|
Filelist(prefix string) ([]string, error)
|
||||||
// RenameFile renames (moves) file
|
// RenameFile renames (moves) file
|
||||||
RenameFile(oldName, newName string) error
|
RenameFile(oldName, newName string) error
|
||||||
|
// SymLink creates a symbolic link, which can be read with ReadLink
|
||||||
|
SymLink(src string, dst string) error
|
||||||
|
// HardLink creates a hardlink of a file
|
||||||
|
HardLink(src string, dst string) error
|
||||||
|
// FileExists returns true if path exists
|
||||||
|
FileExists(path string) (bool, error)
|
||||||
|
// ReadLink returns the symbolic link pointed to by path
|
||||||
|
ReadLink(path string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileSystemPublishedStorage is published storage on filesystem
|
// FileSystemPublishedStorage is published storage on filesystem
|
||||||
@@ -116,9 +125,9 @@ type Progress interface {
|
|||||||
// Downloader is parallel HTTP fetcher
|
// Downloader is parallel HTTP fetcher
|
||||||
type Downloader interface {
|
type Downloader interface {
|
||||||
// Download starts new download task
|
// Download starts new download task
|
||||||
Download(url string, destination string) error
|
Download(ctx context.Context, url string, destination string) error
|
||||||
// DownloadWithChecksum starts new download task with checksum verification
|
// DownloadWithChecksum starts new download task with checksum verification
|
||||||
DownloadWithChecksum(url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool, maxTries int) error
|
DownloadWithChecksum(ctx context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool, maxTries int) error
|
||||||
// GetProgress returns Progress object
|
// GetProgress returns Progress object
|
||||||
GetProgress() Progress
|
GetProgress() Progress
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -7,9 +7,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/smira/aptly/api"
|
"github.com/aptly-dev/aptly/api"
|
||||||
"github.com/smira/aptly/systemd/activation"
|
"github.com/aptly-dev/aptly/systemd/activation"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+6
-1
@@ -1,7 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
ctx "github.com/smira/aptly/context"
|
ctx "github.com/aptly-dev/aptly/context"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,3 +29,8 @@ func InitContext(flags *flag.FlagSet) error {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetContext gives access to the context
|
||||||
|
func GetContext() *ctx.AptlyContext {
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -12,8 +12,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+19
-2
@@ -3,7 +3,8 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -25,6 +26,7 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to edit: %s", err)
|
return fmt.Errorf("unable to edit: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchMirror := false
|
||||||
context.Flags().Visit(func(flag *flag.Flag) {
|
context.Flags().Visit(func(flag *flag.Flag) {
|
||||||
switch flag.Name {
|
switch flag.Name {
|
||||||
case "filter":
|
case "filter":
|
||||||
@@ -35,6 +37,9 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
|
|||||||
repo.DownloadSources = flag.Value.Get().(bool)
|
repo.DownloadSources = flag.Value.Get().(bool)
|
||||||
case "with-udebs":
|
case "with-udebs":
|
||||||
repo.DownloadUdebs = flag.Value.Get().(bool)
|
repo.DownloadUdebs = flag.Value.Get().(bool)
|
||||||
|
case "archive-url":
|
||||||
|
repo.SetArchiveRoot(flag.Value.String())
|
||||||
|
fetchMirror = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -51,8 +56,17 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
if context.GlobalFlags().Lookup("architectures").Value.String() != "" {
|
if context.GlobalFlags().Lookup("architectures").Value.String() != "" {
|
||||||
repo.Architectures = context.ArchitecturesList()
|
repo.Architectures = context.ArchitecturesList()
|
||||||
|
fetchMirror = true
|
||||||
|
}
|
||||||
|
|
||||||
err = repo.Fetch(context.Downloader(), nil)
|
if fetchMirror {
|
||||||
|
var verifier pgp.Verifier
|
||||||
|
verifier, err = getVerifier(context.Flags())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to initialize GPG verifier: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = repo.Fetch(context.Downloader(), verifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to edit: %s", err)
|
return fmt.Errorf("unable to edit: %s", err)
|
||||||
}
|
}
|
||||||
@@ -83,10 +97,13 @@ Example:
|
|||||||
Flag: *flag.NewFlagSet("aptly-mirror-edit", flag.ExitOnError),
|
Flag: *flag.NewFlagSet("aptly-mirror-edit", flag.ExitOnError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.Flag.String("archive-url", "", "archive url is the root of archive")
|
||||||
cmd.Flag.String("filter", "", "filter packages in mirror")
|
cmd.Flag.String("filter", "", "filter packages in mirror")
|
||||||
cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well")
|
cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well")
|
||||||
|
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
|
||||||
cmd.Flag.Bool("with-sources", false, "download source packages in addition to binary packages")
|
cmd.Flag.Bool("with-sources", false, "download source packages in addition to binary packages")
|
||||||
cmd.Flag.Bool("with-udebs", false, "download .udeb packages (Debian installer support)")
|
cmd.Flag.Bool("with-udebs", false, "download .udeb packages (Debian installer support)")
|
||||||
|
cmd.Flag.Var(&keyRingsFlag{}, "keyring", "gpg keyring to use when verifying Release file (could be specified multiple times)")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+26
-37
@@ -2,15 +2,13 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"os/signal"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -113,17 +111,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to update: %s", err)
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catch ^C
|
context.GoContextHandleSignals()
|
||||||
sigch := make(chan os.Signal)
|
|
||||||
signal.Notify(sigch, os.Interrupt)
|
|
||||||
defer signal.Stop(sigch)
|
|
||||||
|
|
||||||
abort := make(chan struct{})
|
|
||||||
go func() {
|
|
||||||
<-sigch
|
|
||||||
signal.Stop(sigch)
|
|
||||||
close(abort)
|
|
||||||
}()
|
|
||||||
|
|
||||||
count := len(queue)
|
count := len(queue)
|
||||||
context.Progress().Printf("Download queue: %d items (%s)\n", count, utils.HumanBytes(downloadSize))
|
context.Progress().Printf("Download queue: %d items (%s)\n", count, utils.HumanBytes(downloadSize))
|
||||||
@@ -148,7 +136,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
for idx := range queue {
|
for idx := range queue {
|
||||||
select {
|
select {
|
||||||
case downloadQueue <- idx:
|
case downloadQueue <- idx:
|
||||||
case <-abort:
|
case <-context.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,6 +169,7 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
// download file...
|
// download file...
|
||||||
e = context.Downloader().DownloadWithChecksum(
|
e = context.Downloader().DownloadWithChecksum(
|
||||||
|
context,
|
||||||
repo.PackageURL(task.File.DownloadURL()).String(),
|
repo.PackageURL(task.File.DownloadURL()).String(),
|
||||||
task.TempDownPath,
|
task.TempDownPath,
|
||||||
&task.File.Checksums,
|
&task.File.Checksums,
|
||||||
@@ -190,28 +179,20 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
pushError(e)
|
pushError(e)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case <-abort:
|
|
||||||
|
task.Done = true
|
||||||
|
case <-context.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all downloads to finish
|
// Wait for all download goroutines to finish
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
select {
|
|
||||||
case <-abort:
|
|
||||||
return fmt.Errorf("unable to update: interrupted")
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Progress().ShutdownBar()
|
context.Progress().ShutdownBar()
|
||||||
|
|
||||||
if len(errors) > 0 {
|
|
||||||
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
|
|
||||||
}
|
|
||||||
|
|
||||||
err = context.ReOpenDatabase()
|
err = context.ReOpenDatabase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to update: %s", err)
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
@@ -221,11 +202,15 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
context.Progress().InitBar(int64(len(queue)), false)
|
context.Progress().InitBar(int64(len(queue)), false)
|
||||||
|
|
||||||
for idx := range queue {
|
for idx := range queue {
|
||||||
|
|
||||||
context.Progress().AddBar(1)
|
context.Progress().AddBar(1)
|
||||||
|
|
||||||
task := &queue[idx]
|
task := &queue[idx]
|
||||||
|
|
||||||
|
if !task.Done {
|
||||||
|
// download not finished yet
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// and import it back to the pool
|
// and import it back to the pool
|
||||||
task.File.PoolPath, err = context.PackagePool().Import(task.TempDownPath, task.File.Filename, &task.File.Checksums, true, context.CollectionFactory().ChecksumCollection())
|
task.File.PoolPath, err = context.PackagePool().Import(task.TempDownPath, task.File.Filename, &task.File.Checksums, true, context.CollectionFactory().ChecksumCollection())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -237,16 +222,20 @@ func aptlyMirrorUpdate(cmd *commander.Command, args []string) error {
|
|||||||
additionalTask.File.PoolPath = task.File.PoolPath
|
additionalTask.File.PoolPath = task.File.PoolPath
|
||||||
additionalTask.File.Checksums = task.File.Checksums
|
additionalTask.File.Checksums = task.File.Checksums
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
|
||||||
case <-abort:
|
|
||||||
return fmt.Errorf("unable to update: interrupted")
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Progress().ShutdownBar()
|
context.Progress().ShutdownBar()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-context.Done():
|
||||||
|
return fmt.Errorf("unable to update: interrupted")
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(errors) > 0 {
|
||||||
|
return fmt.Errorf("unable to update: download errors:\n %s", strings.Join(errors, "\n "))
|
||||||
|
}
|
||||||
|
|
||||||
repo.FinalizeDownload(context.CollectionFactory(), context.Progress())
|
repo.FinalizeDownload(context.CollectionFactory(), context.Progress())
|
||||||
err = context.CollectionFactory().RemoteRepoCollection().Update(repo)
|
err = context.CollectionFactory().RemoteRepoCollection().Update(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-3
@@ -5,9 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+5
-2
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +24,9 @@ func aptlyPublishDrop(cmd *commander.Command, args []string) error {
|
|||||||
storage, prefix := deb.ParsePrefix(param)
|
storage, prefix := deb.ParsePrefix(param)
|
||||||
|
|
||||||
err = context.CollectionFactory().PublishedRepoCollection().Remove(context, storage, prefix, distribution,
|
err = context.CollectionFactory().PublishedRepoCollection().Remove(context, storage, prefix, distribution,
|
||||||
context.CollectionFactory(), context.Progress(), context.Flags().Lookup("force-drop").Value.Get().(bool))
|
context.CollectionFactory(), context.Progress(),
|
||||||
|
context.Flags().Lookup("force-drop").Value.Get().(bool),
|
||||||
|
context.Flags().Lookup("skip-cleanup").Value.Get().(bool))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to remove: %s", err)
|
return fmt.Errorf("unable to remove: %s", err)
|
||||||
}
|
}
|
||||||
@@ -50,6 +52,7 @@ Example:
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flag.Bool("force-drop", false, "remove published repository even if some files could not be cleaned up")
|
cmd.Flag.Bool("force-drop", false, "remove published repository even if some files could not be cleaned up")
|
||||||
|
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ Example:
|
|||||||
cmd.Flag.String("butautomaticupgrades", "", "set value for ButAutomaticUpgrades field")
|
cmd.Flag.String("butautomaticupgrades", "", "set value for ButAutomaticUpgrades field")
|
||||||
cmd.Flag.String("label", "", "label to publish")
|
cmd.Flag.String("label", "", "label to publish")
|
||||||
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
||||||
|
cmd.Flag.Bool("acquire-by-hash", false, "provide index files by hash")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -137,6 +137,10 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
|
|||||||
published.SkipContents = context.Flags().Lookup("skip-contents").Value.Get().(bool)
|
published.SkipContents = context.Flags().Lookup("skip-contents").Value.Get().(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if context.Flags().IsSet("acquire-by-hash") {
|
||||||
|
published.AcquireByHash = context.Flags().Lookup("acquire-by-hash").Value.Get().(bool)
|
||||||
|
}
|
||||||
|
|
||||||
duplicate := context.CollectionFactory().PublishedRepoCollection().CheckDuplicate(published)
|
duplicate := context.CollectionFactory().PublishedRepoCollection().CheckDuplicate(published)
|
||||||
if duplicate != nil {
|
if duplicate != nil {
|
||||||
context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory())
|
context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory())
|
||||||
@@ -227,6 +231,7 @@ Example:
|
|||||||
cmd.Flag.String("butautomaticupgrades", "", "overwrite value for ButAutomaticUpgrades field")
|
cmd.Flag.String("butautomaticupgrades", "", "overwrite value for ButAutomaticUpgrades field")
|
||||||
cmd.Flag.String("label", "", "label to publish")
|
cmd.Flag.String("label", "", "label to publish")
|
||||||
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
||||||
|
cmd.Flag.Bool("acquire-by-hash", false, "provide index files by hash")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -105,10 +105,13 @@ func aptlyPublishSwitch(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to save to DB: %s", err)
|
return fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = context.CollectionFactory().PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, components,
|
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
|
||||||
context.GetPublishedStorage(storage), context.CollectionFactory(), context.Progress())
|
if !skipCleanup {
|
||||||
if err != nil {
|
err = context.CollectionFactory().PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, components,
|
||||||
return fmt.Errorf("unable to update: %s", err)
|
context.GetPublishedStorage(storage), context.CollectionFactory(), context.Progress())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Progress().Printf("\nPublish for snapshot %s has been successfully switched to new snapshot.\n", published.String())
|
context.Progress().Printf("\nPublish for snapshot %s has been successfully switched to new snapshot.\n", published.String())
|
||||||
@@ -151,6 +154,7 @@ This command would switch published repository (with one component) named ppa/wh
|
|||||||
cmd.Flag.Bool("skip-contents", false, "don't generate Contents indexes")
|
cmd.Flag.Bool("skip-contents", false, "don't generate Contents indexes")
|
||||||
cmd.Flag.String("component", "", "component names to update (for multi-component publishing, separate components with commas)")
|
cmd.Flag.String("component", "", "component names to update (for multi-component publishing, separate components with commas)")
|
||||||
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
||||||
|
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -69,10 +69,13 @@ func aptlyPublishUpdate(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to save to DB: %s", err)
|
return fmt.Errorf("unable to save to DB: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = context.CollectionFactory().PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, components,
|
skipCleanup := context.Flags().Lookup("skip-cleanup").Value.Get().(bool)
|
||||||
context.GetPublishedStorage(storage), context.CollectionFactory(), context.Progress())
|
if !skipCleanup {
|
||||||
if err != nil {
|
err = context.CollectionFactory().PublishedRepoCollection().CleanupPrefixComponentFiles(published.Prefix, components,
|
||||||
return fmt.Errorf("unable to update: %s", err)
|
context.GetPublishedStorage(storage), context.CollectionFactory(), context.Progress())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to update: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Progress().Printf("\nPublish for local repo %s has been successfully updated.\n", published.String())
|
context.Progress().Printf("\nPublish for local repo %s has been successfully updated.\n", published.String())
|
||||||
@@ -109,6 +112,7 @@ Example:
|
|||||||
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
cmd.Flag.Bool("skip-signing", false, "don't sign Release files with GPG")
|
||||||
cmd.Flag.Bool("skip-contents", false, "don't generate Contents indexes")
|
cmd.Flag.Bool("skip-contents", false, "don't generate Contents indexes")
|
||||||
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
cmd.Flag.Bool("force-overwrite", false, "overwrite files in package pool in case of mismatch")
|
||||||
|
cmd.Flag.Bool("skip-cleanup", false, "don't remove unreferenced files in prefix/component")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-5
@@ -4,9 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -41,9 +41,9 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
forceReplace := context.Flags().Lookup("force-replace").Value.Get().(bool)
|
forceReplace := context.Flags().Lookup("force-replace").Value.Get().(bool)
|
||||||
|
|
||||||
var packageFiles, failedFiles []string
|
var packageFiles, otherFiles, failedFiles []string
|
||||||
|
|
||||||
packageFiles, failedFiles = deb.CollectPackageFiles(args[1:], &aptly.ConsoleResultReporter{Progress: context.Progress()})
|
packageFiles, otherFiles, failedFiles = deb.CollectPackageFiles(args[1:], &aptly.ConsoleResultReporter{Progress: context.Progress()})
|
||||||
|
|
||||||
var processedFiles, failedFiles2 []string
|
var processedFiles, failedFiles2 []string
|
||||||
|
|
||||||
@@ -55,6 +55,8 @@ func aptlyRepoAdd(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to import package files: %s", err)
|
return fmt.Errorf("unable to import package files: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processedFiles = append(processedFiles, otherFiles...)
|
||||||
|
|
||||||
repo.UpdateRefList(deb.NewPackageRefListFromPackageList(list))
|
repo.UpdateRefList(deb.NewPackageRefListFromPackageList(list))
|
||||||
|
|
||||||
err = context.CollectionFactory().LocalRepoCollection().Update(repo)
|
err = context.CollectionFactory().LocalRepoCollection().Update(repo)
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/AlekSi/pointer"
|
"github.com/AlekSi/pointer"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+9
-5
@@ -7,10 +7,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -138,7 +138,7 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
|
|||||||
return fmt.Errorf("unable to load packages: %s", err)
|
return fmt.Errorf("unable to load packages: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
packageFiles, _ := deb.CollectPackageFiles([]string{changes.TempDir}, reporter)
|
packageFiles, otherFiles, _ := deb.CollectPackageFiles([]string{changes.TempDir}, reporter)
|
||||||
|
|
||||||
var restriction deb.PackageQuery
|
var restriction deb.PackageQuery
|
||||||
|
|
||||||
@@ -179,6 +179,10 @@ func aptlyRepoInclude(cmd *commander.Command, args []string) error {
|
|||||||
processedFiles = append(processedFiles, filepath.Join(changes.BasePath, filepath.Base(file)))
|
processedFiles = append(processedFiles, filepath.Join(changes.BasePath, filepath.Base(file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, file := range otherFiles {
|
||||||
|
processedFiles = append(processedFiles, filepath.Join(changes.BasePath, filepath.Base(file)))
|
||||||
|
}
|
||||||
|
|
||||||
processedFiles = append(processedFiles, path)
|
processedFiles = append(processedFiles, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -3,8 +3,8 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
ctx "github.com/smira/aptly/context"
|
ctx "github.com/aptly-dev/aptly/context"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -8,9 +8,9 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/query"
|
"github.com/aptly-dev/aptly/query"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# aptly-zsh
|
||||||
|
zsh completion for aptly
|
||||||
|
|
||||||
|
The zsh completion function and this README were imported from
|
||||||
|
[steinymity's repository](https://github.com/steinymity/aptly-zsh).
|
||||||
|
|
||||||
|
[Aptly](https://www.aptly.info/) is a great tool to setup Debian APT repositories
|
||||||
|
and mirrors. However, it's sometimes hard to remember all the command line
|
||||||
|
syntax and names of all options. Therefore I wrote this zsh completion modules
|
||||||
|
for aptly.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the terms of the MIT license. See file `LICENSE`
|
||||||
|
for details.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Clone/copy the file `_aptly` to a place in your `$fpath` (show with
|
||||||
|
`echo $fpath`), or create a new directory and extend the fpath:
|
||||||
|
|
||||||
|
mkdir -p ~/.zsh/functions
|
||||||
|
fpath=(~/.zsh/functions $fpath)
|
||||||
|
editor ~/.zsh/functions/_aptly
|
||||||
|
|
||||||
|
To profit most from the provided help messages and completions, make sure that
|
||||||
|
your zsh is setup properly. I have tested with the grml-zsh configuration that
|
||||||
|
is [available on Github](https://github.com/grml/grml-etc-core/) and on the
|
||||||
|
[grml homepage](http://grml.org/zsh/).
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
The command line completion was developed based on the manpage of aptly 1.2.0
|
||||||
|
(currently in Debian Testing). However, most completions will work on older
|
||||||
|
versions (e.g., 0.9.7 in Debian Stable), too.
|
||||||
|
|
||||||
|
The completion function completes most arguments and options that can be passed
|
||||||
|
to aptly, including mirror/repository/snapshot/publish names. However, not all
|
||||||
|
arguments are handled yet. See the next section for known limitations.
|
||||||
|
|
||||||
|
## Known Bugs and Limitation
|
||||||
|
|
||||||
|
* Boolean options are always completed with an explicit value `true` or
|
||||||
|
`false`, although omitting the value is implicitly interpreted as `true`.
|
||||||
|
* The source and destination names of copy and move operations must not be the
|
||||||
|
same. This is currently not enforced.
|
||||||
|
* The package query and display format strings are currently not completed.
|
||||||
|
* Endpoints are not completed.
|
||||||
|
* In `publish snapshot` there is no connection between the number of
|
||||||
|
components passed to `-component` and the number of given snapshots to
|
||||||
|
publish. Furthermore, the help text for `endpoint:prefix` disappears
|
||||||
|
after its first possible location.
|
||||||
|
* In `publish switch` the distribution can be set independently of the
|
||||||
|
`endpoint:prefix` (i.e., all published distributions can be combined with
|
||||||
|
all published `endpoint:prefix`).
|
||||||
|
* Neither `publish switch` nor `publish update` check if publish was created
|
||||||
|
from a snapshot or directly from a local repo.
|
||||||
|
* Task commands are not completed. There are no commas added.
|
||||||
|
* `help` won't complete after a sub command (i.e., `aptly mirror list help`).
|
||||||
|
* Probably more, feel free to open issues, and submit patches/merge requests.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Maximilian Stein <m@steiny.biz>
|
||||||
|
2018-02-03
|
||||||
@@ -0,0 +1,617 @@
|
|||||||
|
#compdef aptly
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2018 Maximilian Stein <m@steiny.biz>
|
||||||
|
# Acknowledgement: Many texts where copied from aptly(1)
|
||||||
|
#
|
||||||
|
# This project is licensed under the terms of the MIT license.
|
||||||
|
# See file LICENSE for details.
|
||||||
|
################################################################################
|
||||||
|
# zsh completion script for Aptly (http://aptly.info/)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# see https://man.cx/aptly
|
||||||
|
|
||||||
|
local curcontext="$curcontext" state line cmd subcmd ret=1
|
||||||
|
|
||||||
|
local arch_list=(amd64 arm64 armel armhf i386 mips mipsel mips64el ppc64el s390x)
|
||||||
|
local bool="bool:{_wanted -V values expl 'bool' compadd true false}"
|
||||||
|
local dists=({wheezy,jessie,stretch}{,-updates,-backports,-backports-sloopy} buster sid experimental)
|
||||||
|
local components=(main contrib non-free)
|
||||||
|
local aptly_query="aptly package query: "
|
||||||
|
local aptly_format="aptly package display format: "
|
||||||
|
local aptly_uploaders="-uploaders-file=[uploaders.json to be used when including .changes into this repository]:uploaders file:_files -g '*.json'"
|
||||||
|
local keyring="*-keyring=[gpg keyring to use when verifying Release file (could be specified multiple times)]:keyring file:_files -g '*.gpg'"
|
||||||
|
|
||||||
|
# complete command
|
||||||
|
(( $+functions[_aptly-cmd] )) ||
|
||||||
|
_aptly-cmd() {
|
||||||
|
_values "aptly command category" \
|
||||||
|
"mirror[manage, update mirrors of remote repositories]" \
|
||||||
|
"repo[manage local package repositories, add, remove, move, copy packages]" \
|
||||||
|
"snapshot[create, merge, manage snapshots]" \
|
||||||
|
"package[perform operation on the whole collection of packages]" \
|
||||||
|
"publish[publish snapshot or local repository]" \
|
||||||
|
"db[cleanup database and package pool, recover database after failure]" \
|
||||||
|
"task[multi-command tasks]" \
|
||||||
|
"serve[quickly serve published repositories via HTTP]" \
|
||||||
|
"config[configuration management]" \
|
||||||
|
"graph[generate dependency graph]" \
|
||||||
|
"api[REST API service]"
|
||||||
|
ret=0
|
||||||
|
}
|
||||||
|
|
||||||
|
# complete subcommand
|
||||||
|
(( $+functions[_aptly-subcmd] )) ||
|
||||||
|
_aptly-subcmd() {
|
||||||
|
local cmd=$1
|
||||||
|
case $cmd in
|
||||||
|
mirror)
|
||||||
|
_values "mirror commands" \
|
||||||
|
"create[create new mirror of remote repository]" \
|
||||||
|
"list[show full list of mirrors]" \
|
||||||
|
"show[show details about a mirror]" \
|
||||||
|
"drop[delete a mirror]" \
|
||||||
|
"update[update a mirror]" \
|
||||||
|
"rename[change name of a mirror]" \
|
||||||
|
"edit[change settings of a mirror]" \
|
||||||
|
"search[search mirror for packages matching query]"
|
||||||
|
ret=0 ;;
|
||||||
|
repo)
|
||||||
|
_values "repo commands" \
|
||||||
|
"add[add packages to local repository]" \
|
||||||
|
"copy[copy packages between local repositories]" \
|
||||||
|
"create[create local repository]" \
|
||||||
|
"drop[delete local repository]" \
|
||||||
|
"edit[edit properties of local repository]" \
|
||||||
|
"import[import packages from mirror to local repository]" \
|
||||||
|
"list[list local repositories]" \
|
||||||
|
"move[move packages between local repositories]" \
|
||||||
|
"remove[remove packages from local repository]" \
|
||||||
|
"show[show details about local repository]" \
|
||||||
|
"rename[renames local repository]" \
|
||||||
|
"search[search repo for packages matching query]" \
|
||||||
|
"include[add packages to local repositories based on .changes files]"
|
||||||
|
ret=0 ;;
|
||||||
|
snapshot)
|
||||||
|
_values "snapshot commands" \
|
||||||
|
"create[create snapshot of mirror or local repository]" \
|
||||||
|
"list[list snapshots]" \
|
||||||
|
"show[show details about snapshot]" \
|
||||||
|
"verify[verify dependencies in snapshot]" \
|
||||||
|
"pull[pull packages from another snapshot]" \
|
||||||
|
"diff[show difference between two snapshots]" \
|
||||||
|
"merge[merge snapshots]" \
|
||||||
|
"drop[delete snapshot]" \
|
||||||
|
"rename[rename snapshot]" \
|
||||||
|
"search[search snapshot for packages matching query]" \
|
||||||
|
"filter[filter packages in snapshot producing another snapshot]"
|
||||||
|
ret=0 ;;
|
||||||
|
publish)
|
||||||
|
_values "publish commands" \
|
||||||
|
"drop[remove published repository]" \
|
||||||
|
"list[list published repositories]" \
|
||||||
|
"repo[publish local repository]" \
|
||||||
|
"snapshot[publish snapshot]" \
|
||||||
|
"switch[update published repository by switching to new snapshot]" \
|
||||||
|
"update[update published local repository]" \
|
||||||
|
"show[shows details of published repository]"
|
||||||
|
ret=0 ;;
|
||||||
|
package)
|
||||||
|
_values "package commands" \
|
||||||
|
"search[search for packages matching query]" \
|
||||||
|
"show[show details about packages matching query]"
|
||||||
|
ret=0 ;;
|
||||||
|
db)
|
||||||
|
_values "db commands" \
|
||||||
|
"cleanup[cleanup db and package pool]" \
|
||||||
|
"recover[recover db after crash]"
|
||||||
|
ret=0 ;;
|
||||||
|
serve)
|
||||||
|
# no subcommand here
|
||||||
|
_arguments '1:: :' \
|
||||||
|
'-listen=[host:port for HTTP listening]:host\:port: '
|
||||||
|
ret=0 ;;
|
||||||
|
api)
|
||||||
|
_values "api commands" \
|
||||||
|
"serve[start api http service]"
|
||||||
|
ret=0 ;;
|
||||||
|
graph)
|
||||||
|
# no subcommand here
|
||||||
|
_arguments '*:' \
|
||||||
|
'-format=[render graph to specified format]:image format:(png svg pdf)' \
|
||||||
|
'-layout=[create a more vertical or more horizontal graph layout]:layout:(horizontal vertical)' \
|
||||||
|
'-output=[specify output filename, default is to open result in viewer]:output file:_files'
|
||||||
|
ret=0 ;;
|
||||||
|
config)
|
||||||
|
_values "config commands" \
|
||||||
|
"show[show current aptly config]"
|
||||||
|
ret=0 ;;
|
||||||
|
task)
|
||||||
|
_values "task commands" \
|
||||||
|
"run[run aptly tasks]"
|
||||||
|
ret=0 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# complete parameters
|
||||||
|
(( $+functions[_aptly-param] )) ||
|
||||||
|
_aptly-param() {
|
||||||
|
local cmd=$1 subcmd=$2
|
||||||
|
|
||||||
|
local config=$opt_args[-config]
|
||||||
|
[[ -n $config ]] && config="-config=$config"
|
||||||
|
|
||||||
|
# get list of mirrors, or ' ' if none
|
||||||
|
get_mirrors() {
|
||||||
|
# retrieve list of mirrors
|
||||||
|
local mirrors=($(aptly $config mirror list -raw=true 2>/dev/null))
|
||||||
|
# a single space causes just the help text to be shown
|
||||||
|
[[ -z $mirrors ]] && mirrors=" " || mirrors="($mirrors)"
|
||||||
|
echo $mirrors
|
||||||
|
}
|
||||||
|
# get lists of repos or ' ' if none
|
||||||
|
get_repos() {
|
||||||
|
# retrieve repo list
|
||||||
|
local repos=($(aptly $config repo list -raw=true 2>/dev/null))
|
||||||
|
[[ -z $repos ]] && repos=" " || repos="($repos)"
|
||||||
|
echo $repos
|
||||||
|
}
|
||||||
|
# get list of snapshots or ' ' if none
|
||||||
|
get_snapshots() {
|
||||||
|
local snapshots=($(aptly $config snapshot list -raw=true 2>/dev/null))
|
||||||
|
[[ -z $snapshots ]] && snapshots=" " || snapshots="($snapshots)"
|
||||||
|
echo $snapshots
|
||||||
|
}
|
||||||
|
# get list of gpg keys or ' ' if none
|
||||||
|
get_gpg_key_ids() {
|
||||||
|
local gpg_keys=($(gpg --quiet --batch --keyid-format long --list-secret-keys --with-colons 2>/dev/null | grep '^sec' | cut -d ':' -f 5))
|
||||||
|
[[ -z $gpg_keys ]] && gpg_keys=" " || gpg_keys="($gpg_keys)"
|
||||||
|
echo $gpg_keys
|
||||||
|
}
|
||||||
|
|
||||||
|
ret=0
|
||||||
|
case $cmd in
|
||||||
|
mirror)
|
||||||
|
local mirrors=$(get_mirrors)
|
||||||
|
|
||||||
|
case $subcmd in
|
||||||
|
create)
|
||||||
|
_arguments \
|
||||||
|
"-filter=[filter packages in mirror]:$aptly_query" \
|
||||||
|
"-filter-with-deps=[when filtering, include dependencies of matching packages as well]:$bool" \
|
||||||
|
"-force-architecture=[(only with architecture list) skip check that requested architectures are listed in Release file]:$bool" \
|
||||||
|
"-force-components=[(only with component list) skip check that requested components are listed in Release file]:$bool" \
|
||||||
|
"-ignore-signatures=[disable verification of Release file signatures]:$bool" \
|
||||||
|
$keyring \
|
||||||
|
"-with-sources=[download source packages in addition to binary packages]:$bool" \
|
||||||
|
"-with-udebs=[download .udeb packages (Debian installer support)]:$bool" \
|
||||||
|
"(-)2:new mirror name: " ":archive url:_urls" ":distribution:($dists)" "*:components:_values -s ' ' components $components"
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"-raw=[display list in machine-readable format]:$bool"
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
_arguments \
|
||||||
|
"-with-packages=[show detailed list of packages and versions stored in the mirror]:$bool" \
|
||||||
|
"(-)2:mirror name:$mirrors"
|
||||||
|
;;
|
||||||
|
drop)
|
||||||
|
_arguments \
|
||||||
|
"-force=[force mirror deletion even if used by snapshots]:$bool" \
|
||||||
|
"(-)2:mirror name:$mirrors"
|
||||||
|
;;
|
||||||
|
update)
|
||||||
|
_arguments \
|
||||||
|
"-download-limit=[limit download speed (kB/s)]:kB/s: " \
|
||||||
|
"-force=[force update mirror even if it is locked by another process]:$bool" \
|
||||||
|
"-ignore-checksums=[ignore checksum mismatches while downloading package files and metadata]:$bool" \
|
||||||
|
"-ignore-signatures=[disable verification of Release file signatures]:$bool" \
|
||||||
|
$keyring \
|
||||||
|
"-max-tries=[max download tries till process fails with download error]:number: " \
|
||||||
|
"-skip-existing-packages=[do not check file existence for packages listed in the internal database of the mirror]:$bool" \
|
||||||
|
"(-)2:mirror name:$mirrors"
|
||||||
|
;;
|
||||||
|
rename)
|
||||||
|
_arguments \
|
||||||
|
"2:old mirror name:$mirrors" ":new mirror name: "
|
||||||
|
;;
|
||||||
|
edit)
|
||||||
|
_arguments \
|
||||||
|
"-filter=[filter packages in mirror]:$aptly_query" \
|
||||||
|
"-filter-with-deps=[when filtering, include dependencies of matching packages as well]:$bool" \
|
||||||
|
"-with-sources=[download source packages in addition to binary packages]:$bool" \
|
||||||
|
"-with-udebs=[download .udeb packages (Debian installer support)]:$bool" \
|
||||||
|
"(-)2:mirror name:$mirrors"
|
||||||
|
;;
|
||||||
|
search)
|
||||||
|
_arguments \
|
||||||
|
"-format=[custom format for result printing]:$aptly_format" \
|
||||||
|
"-with-deps=[include dependencies into search results]:$bool" \
|
||||||
|
"(-)2:mirror name:$mirrors" ":$aptly_query"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
repo)
|
||||||
|
|
||||||
|
|
||||||
|
local repos=$(get_repos)
|
||||||
|
|
||||||
|
local create_edit=("-comment=[any text that would be used to described local repository]:comment: "
|
||||||
|
"-component=[default component when publishing]:component:($components)"
|
||||||
|
"-distribution=[default distribution when publishing]:distribution:($dists)"
|
||||||
|
$aptly_uploaders
|
||||||
|
)
|
||||||
|
|
||||||
|
case $subcmd in
|
||||||
|
add)
|
||||||
|
_arguments \
|
||||||
|
"-force-replace=[when adding package that conflicts with existing package, remove existing package]:$bool" \
|
||||||
|
"-remove-files=[remove files that have been imported successfully into repository]:$bool" \
|
||||||
|
"(-)2:repo name:$repos" "*:package files:_files -g '*.{udeb,deb,dsc}'"
|
||||||
|
;;
|
||||||
|
copy)
|
||||||
|
_arguments \
|
||||||
|
"-dry-run=[don’t copy, just show what would be copied]:$bool" \
|
||||||
|
"-with-deps=[follow dependencies when processing package−spec]:$$bool" \
|
||||||
|
"(-)2:src repo name:$repos" ":dest repo name:$repos" "*:$aptly_query"
|
||||||
|
;;
|
||||||
|
create)
|
||||||
|
local snapshots=$(get_snapshots)
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
${create_edit[@]} \
|
||||||
|
"(-)2:new repo name: " \
|
||||||
|
"3:::('from')" "4:::('snapshot')" "5::snapshot:$snapshots"
|
||||||
|
;;
|
||||||
|
drop)
|
||||||
|
_arguments \
|
||||||
|
"-force=[force local repo deletion even if used by snapshots]:$bool" \
|
||||||
|
"(-)2:repo name:$repos"
|
||||||
|
;;
|
||||||
|
edit)
|
||||||
|
_arguments \
|
||||||
|
${create_edit[@]} \
|
||||||
|
"(-)2:repo name:$repos"
|
||||||
|
;;
|
||||||
|
import)
|
||||||
|
local mirrors=$(get_mirrors)
|
||||||
|
|
||||||
|
_arguments \
|
||||||
|
"-dry-run=[don’t import, just show what would be imported]:$bool" \
|
||||||
|
"-with-deps=[follow dependencies when processing package−spec]:$bool" \
|
||||||
|
"(-)2:src mirror name:$mirrors" ":dest repo name:$repos" "*:$aptly_query"
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"-raw=[display list in machine−readable format]:$bool"
|
||||||
|
;;
|
||||||
|
move)
|
||||||
|
_arguments \
|
||||||
|
"-dry-run=[don’t move, just show what would be moved]:$bool" \
|
||||||
|
"-with-deps=[follow dependencies when processing package−spec]:$bool" \
|
||||||
|
"(-)2:srv repo name:$repos" ":dest repo name:$repos" "*:$aptly_query"
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
_arguments \
|
||||||
|
"-dry-run=[don’t remove, just show what would be removed]:$bool" \
|
||||||
|
"(-)2:repo name:$repos" "*:$aptly_query"
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
_arguments \
|
||||||
|
"-with-packages=[show list of packages]:$bool" \
|
||||||
|
"(-)2:repo name:$repos"
|
||||||
|
;;
|
||||||
|
rename)
|
||||||
|
_arguments \
|
||||||
|
"2:old repo name:$repos" ":new repo name: "
|
||||||
|
;;
|
||||||
|
search)
|
||||||
|
_arguments \
|
||||||
|
"-format=[custom format for result printing]:$aptly_format" \
|
||||||
|
"-with-deps=[include dependencies into search results]:$bool" \
|
||||||
|
"(-)2:repo name:$repos" ":$aptly_query"
|
||||||
|
;;
|
||||||
|
include)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"-accept-unsigned=[accept unsigned .changes files]:$bool" \
|
||||||
|
"-force-replace=[when adding package that conflicts with existing package, remove existing package]:$bool" \
|
||||||
|
"-ignore-signatures=[disable verification of .changes file signature]:$bool" \
|
||||||
|
$keyring \
|
||||||
|
"-no-remove-files=[don’t remove files that have been imported successfully into repository]:$bool" \
|
||||||
|
"-repo=[which repo should files go to, defaults to Distribution field of .changes file]:repo name:$repos" \
|
||||||
|
$aptly_uploaders \
|
||||||
|
"(-)*:changes files/directories:_files -g '*.changes'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
snapshot)
|
||||||
|
local snapshots=$(get_snapshots)
|
||||||
|
|
||||||
|
case $subcmd in
|
||||||
|
create)
|
||||||
|
local mirrors=$(get_mirrors)
|
||||||
|
local repos=$(get_repos)
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'(-)2:new snapshot name: ' \
|
||||||
|
'3: :->src1' \
|
||||||
|
'4:: :->src2' '5:: :->src3'
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
src1)
|
||||||
|
_values 'snapshot src' 'from' 'empty' ;;
|
||||||
|
src2)
|
||||||
|
if [[ $line[3] == from ]]; then
|
||||||
|
_values 'snapshot src' 'mirror' 'repo'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
src3)
|
||||||
|
if [[ $line[3] == from ]]; then
|
||||||
|
case $line[4] in
|
||||||
|
mirror)
|
||||||
|
_arguments "5:mirror name:$mirrors" ;;
|
||||||
|
repo)
|
||||||
|
_arguments "5:repo name:$repos" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"-raw=[display list in machine−readable format]:$bool" \
|
||||||
|
"-sort=[display list in ’name’ or creation ’time’ order]:sort order:((name\:'alphabetical order' time\:'chronological order'))"
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
_arguments \
|
||||||
|
"-with-packages=[show list of packages]:$bool" \
|
||||||
|
"(-)2:snapshot name:$snapshots"
|
||||||
|
;;
|
||||||
|
verify)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"(-)2:snapshot name:$snapshots" "*::more snapshots:$snapshots"
|
||||||
|
;;
|
||||||
|
pull)
|
||||||
|
_arguments \
|
||||||
|
"-all-matches=[pull all the packages that satisfy the dependency version requirements]:$bool" \
|
||||||
|
"-dry-run=[don’t create destination snapshot, just show what would be pulled]:$bool" \
|
||||||
|
"-no-deps=[don’t process dependencies, just pull listed packages]:$bool" \
|
||||||
|
"-no-remove=[don’t remove other package versions when pulling package]:$bool" \
|
||||||
|
"(-)2:to snapshot name:$snapshots" "3:src snapshot name:$snapshots" "4:new dest snapshot name: " \
|
||||||
|
"*:$aptly_query"
|
||||||
|
;;
|
||||||
|
diff)
|
||||||
|
_arguments \
|
||||||
|
"-only-matching=[display diff only for matching packages (don’t display missing packages)]:$bool" \
|
||||||
|
"(-)2:snapshot name a:$snapshots" "3:snapshot name b:$snapshots"
|
||||||
|
;;
|
||||||
|
merge)
|
||||||
|
_arguments \
|
||||||
|
"-latest=[use only the latest version of each package]:$bool" \
|
||||||
|
"-no-remove=[don’t remove duplicate arch/name packages]:$bool" \
|
||||||
|
"(-)2:new dest snapshot name: " "*:source snapshot name(s):$snapshots"
|
||||||
|
;;
|
||||||
|
drop)
|
||||||
|
_arguments \
|
||||||
|
"-force=[remove snapshot even if it was used as source for other snapshots]:$bool" \
|
||||||
|
"(-)2:snapshot name:$snapshots"
|
||||||
|
;;
|
||||||
|
rename)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"2:old snapshot name:$snapshots" "3:new snapshot name: "
|
||||||
|
;;
|
||||||
|
search)
|
||||||
|
_arguments \
|
||||||
|
"-format=[custom format for result printing]:$aptly_format" \
|
||||||
|
"-with-deps=[include dependencies into search results]:$bool" \
|
||||||
|
"(-)2:snapshot name:$snapshots" ":$aptly_query"
|
||||||
|
;;
|
||||||
|
filter)
|
||||||
|
_arguments \
|
||||||
|
"-with-deps=[include dependent packages as well]:$bool" \
|
||||||
|
"(-)2:src snapshot name:$snapshots" "3:new dest snapshot name: " "*:$aptly_query"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
publish)
|
||||||
|
# read lines of output into
|
||||||
|
# format of each item: <ep:prefix> <distribution>
|
||||||
|
local -a publish_prefixes
|
||||||
|
local -a publish_dists
|
||||||
|
for line in ${(@f)"$(aptly $config publish list -raw=true 2>/dev/null)"}
|
||||||
|
{
|
||||||
|
publish_prefixes+=($line[(ws: :)1])
|
||||||
|
publish_dists+=($line[(ws: :)2])
|
||||||
|
}
|
||||||
|
publish_prefixes_uniq=(${(@u)publish_prefixes})
|
||||||
|
publish_dists_uniq=(${(@u)publish_dists})
|
||||||
|
[[ -z $publish_prefixes_uniq ]] && publish_prefixes_uniq=" " || publish_prefixes_uniq="($publish_prefixes_uniq)"
|
||||||
|
[[ -z $publish_dists_uniq ]] && publish_dists_uniq=" " || publish_dists_uniq="($publish_dists_uniq)"
|
||||||
|
|
||||||
|
local gpg_keys=$(get_gpg_key_ids)
|
||||||
|
|
||||||
|
# common options for publishing
|
||||||
|
# TODO: is the keyring parameter correct?
|
||||||
|
local publish_update_options=(
|
||||||
|
"-batch=[run GPG with detached tty]:$bool"
|
||||||
|
"-force-overwrite=[overwrite files in package pool in case of mismatch]:$bool"
|
||||||
|
"-gpg-key=[GPG key ID to use when signing the release]:gpg key id:$gpg_keys"
|
||||||
|
"-keyring=[GPG keyring to use (instead of default)]:keyring file:_files -g '*.gpg'"
|
||||||
|
"-passphrase=[GPG passhprase for the key (warning: could be insecure)]:passphrase: "
|
||||||
|
"-passphrase-file=[GPG passhprase−file for the key (warning: could be insecure)]:passphrase file:_files"
|
||||||
|
"-secret-keyring=[GPG secret keyring to use (instead of default)]:secret-keyring:_files"
|
||||||
|
"-skip-contents=[don’t generate Contents indexes]:$bool"
|
||||||
|
"-skip-signing=[don’t sign Release files with GPG]:$bool"
|
||||||
|
)
|
||||||
|
local components_options=(
|
||||||
|
"-component=[component name to publish (for multi−component publishing, separate components with commas)]:components:_values -s , components $components"
|
||||||
|
)
|
||||||
|
local publish_options=(
|
||||||
|
"-butautomaticupgrades=[set value for ButAutomaticUpgrades field]:$bool"
|
||||||
|
"-distribution=[distribution name to publish]:distribution:($dists)"
|
||||||
|
"-label=[label to publish]:label: "
|
||||||
|
"-notautomatic=[set value for NotAutomatic field]:notautomatic: "
|
||||||
|
"-origin=[origin name to publish]:origin: "
|
||||||
|
${components_options[@]}
|
||||||
|
)
|
||||||
|
|
||||||
|
local endpoint_prefix="[endpoint\:]prefix"
|
||||||
|
|
||||||
|
case $subcmd in
|
||||||
|
repo)
|
||||||
|
local repos=$(get_repos)
|
||||||
|
_arguments \
|
||||||
|
${publish_options[@]} \
|
||||||
|
${publish_update_options[@]} \
|
||||||
|
"(-)2:repo name:$repos" "3::$endpoint_prefix: "
|
||||||
|
;;
|
||||||
|
snapshot)
|
||||||
|
local snapshots=$(get_snapshots)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
${publish_options[@]} \
|
||||||
|
${publish_update_options[@]} \
|
||||||
|
"(-)*:snapshot name:$snapshots" "3::$endpoint_prefix: "
|
||||||
|
;;
|
||||||
|
switch)
|
||||||
|
local snapshots=$(get_snapshots)
|
||||||
|
_arguments \
|
||||||
|
${publish_update_options[@]} \
|
||||||
|
${components_options[@]} \
|
||||||
|
"(-)2:distribution:$publish_dists_uniq" "3::$endpoint_prefix:$publish_prefixes_uniq" \
|
||||||
|
"*:new snapshot name:$snapshots"
|
||||||
|
;;
|
||||||
|
update)
|
||||||
|
_arguments \
|
||||||
|
${publish_update_options[@]} \
|
||||||
|
"(-)2:distribution:$publish_dists_uniq" "3::$endpoint_prefix:$publish_prefixes_uniq"
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"(-)2:distribution:$publish_dists_uniq" "3::$endpoint_prefix:$publish_prefixes_uniq"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
package)
|
||||||
|
case $subcmd in
|
||||||
|
search)
|
||||||
|
_arguments \
|
||||||
|
"-format=[custom format for result printing]:$aptly_format" \
|
||||||
|
"(-)2:$aptly_query"
|
||||||
|
;;
|
||||||
|
show)
|
||||||
|
_arguments \
|
||||||
|
"-with-files=[display information about files from package pool]:$bool" \
|
||||||
|
"-with-references=[display information about mirrors, snapshots and local repos referencing this package]:$bool" \
|
||||||
|
"(-)2:$aptly_query"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
db)
|
||||||
|
case $subcmd in
|
||||||
|
cleanup)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"-dry-run=[don’t delete anything]:$bool" \
|
||||||
|
"-verbose=[be verbose when loading objects/removing them]:$bool"
|
||||||
|
;;
|
||||||
|
recover)
|
||||||
|
# nothing to complete...
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
serve)
|
||||||
|
# completed in _aptly-subcmd
|
||||||
|
;;
|
||||||
|
api)
|
||||||
|
case $subcmd in
|
||||||
|
serve)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"-listen=[host:port for HTTP listening or unix://path to listen on a Unix domain socket]:host\:port or unix\://path: " \
|
||||||
|
"-no-lock=[don’t lock the database]:$bool"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
graph)
|
||||||
|
# completed in _aptly-subcmd
|
||||||
|
;;
|
||||||
|
config)
|
||||||
|
case $subcmd in
|
||||||
|
show)
|
||||||
|
# nothing to do
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
task)
|
||||||
|
case $subcmd in
|
||||||
|
run)
|
||||||
|
_arguments '1:: :' \
|
||||||
|
"(2)-filename=[specifies the filename that contains the commands to run]:filename:_files" \
|
||||||
|
"(-filename)*::comma-separated command list: "
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# main completion
|
||||||
|
_arguments -C \
|
||||||
|
"-architectures=[list of architectures to consider (comma−separated), default to all available]:architectures:_values -s , architectures $arch_list" \
|
||||||
|
"-config=[location of configuration file]:file:_files -g '*.conf'" \
|
||||||
|
"-db-open-attempts=[number of attempts to open DB if it’s locked by other instance]:number:()" \
|
||||||
|
"-dep-follow-all-variants=[when processing dependencies, follow a & b if dependency is ’a|b’]:$bool" \
|
||||||
|
"-dep-follow-recommends=[when processing dependencies, follow Recommends]:$bool" \
|
||||||
|
"-dep-follow-source=[when processing dependencies, follow from binary to Source packages]:$bool" \
|
||||||
|
"-dep-follow-suggests=[when processing dependencies, follow Suggests]:$bool" \
|
||||||
|
"-dep-verbose-resolve=[when processing dependencies, print detailed logs]:$bool" \
|
||||||
|
"-gpg-provider=[PGP implementation]:gpg provider:((gpg\:'external gpg' internal\:'Go internal implementation'))" \
|
||||||
|
'(-)1: :->cmds' \
|
||||||
|
'2: :->subcmd' \
|
||||||
|
'*:: :->args' && ret=0
|
||||||
|
|
||||||
|
cmd=$line[1]
|
||||||
|
subcmd=$line[2]
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
cmds)
|
||||||
|
_aptly-cmd
|
||||||
|
_arguments '(-)1:: :((help\:integrated\ command\ help))'
|
||||||
|
;;
|
||||||
|
subcmd)
|
||||||
|
case $cmd in
|
||||||
|
help)
|
||||||
|
_aptly-cmd
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_aptly-subcmd $cmd
|
||||||
|
_arguments '(-)2:: :((help\:integrated\ command\ help))'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
args)
|
||||||
|
# help anywhere in line?
|
||||||
|
if [[ ${line[(i)help]} -le ${#line} ]]; then
|
||||||
|
if [[ ${#line} -le 3 ]]; then
|
||||||
|
if [[ $line[1] == help ]]; then
|
||||||
|
_aptly-subcmd $subcmd
|
||||||
|
elif [[ $line[2] == help ]]; then
|
||||||
|
_aptly-subcmd $cmd
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
_aptly-param $cmd $subcmd
|
||||||
|
# this somehow destroys parameter completion, so disable it for now
|
||||||
|
#_arguments '(-)3:: :((help\:integrated\ command\ help))'
|
||||||
|
fi
|
||||||
|
ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 4
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 4
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=4 ts=4 et
|
||||||
@@ -164,7 +164,7 @@ _aptly()
|
|||||||
"edit")
|
"edit")
|
||||||
if [[ $numargs -eq 0 ]]; then
|
if [[ $numargs -eq 0 ]]; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "-filter= -filter-with-deps -with-sources -with-udebs" -- ${cur}))
|
COMPREPLY=($(compgen -W "-archive-url= -filter= -filter-with-deps -ignore-signatures -keyring= -with-sources -with-udebs" -- ${cur}))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(__aptly_mirror_list)" -- ${cur}))
|
COMPREPLY=($(compgen -W "$(__aptly_mirror_list)" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
@@ -499,7 +499,7 @@ _aptly()
|
|||||||
"snapshot"|"repo")
|
"snapshot"|"repo")
|
||||||
if [[ $numargs -eq 0 ]]; then
|
if [[ $numargs -eq 0 ]]; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "-batch -force-overwrite -distribution= -component= -gpg-key= -keyring= -label= -origin= -notautomatic= -butautomaticupgrades= -passphrase= -passphrase-file= -secret-keyring= -skip-contents -skip-signing" -- ${cur}))
|
COMPREPLY=($(compgen -W "-acquire-by-hash -batch -butautomaticupgrades= -component= -distribution= -force-overwrite -gpg-key= -keyring= -label= -notautomatic= -origin= -passphrase= -passphrase-file= -secret-keyring= -skip-contents -skip-signing" -- ${cur}))
|
||||||
else
|
else
|
||||||
if [[ "$subcmd" == "snapshot" ]]; then
|
if [[ "$subcmd" == "snapshot" ]]; then
|
||||||
COMPREPLY=($(compgen -W "$(__aptly_snapshot_list)" -- ${cur}))
|
COMPREPLY=($(compgen -W "$(__aptly_snapshot_list)" -- ${cur}))
|
||||||
@@ -524,7 +524,7 @@ _aptly()
|
|||||||
"update")
|
"update")
|
||||||
if [[ $numargs -eq 0 ]]; then
|
if [[ $numargs -eq 0 ]]; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "-batch -force-overwrite -gpg-key= -keyring= -passphrase= -passphrase-file= -secret-keyring= -skip-contents -skip-signing" -- ${cur}))
|
COMPREPLY=($(compgen -W "-batch -force-overwrite -gpg-key= -keyring= -passphrase= -passphrase-file= -secret-keyring= -skip-cleanup -skip-contents -skip-signing" -- ${cur}))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(__aptly_published_distributions)" -- ${cur}))
|
COMPREPLY=($(compgen -W "$(__aptly_published_distributions)" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
@@ -539,7 +539,7 @@ _aptly()
|
|||||||
"switch")
|
"switch")
|
||||||
if [[ $numargs -eq 0 ]]; then
|
if [[ $numargs -eq 0 ]]; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "-batch -force-overwrite -component= -gpg-key= -keyring= -passphrase= -passphrase-file= -secret-keyring= -skip-contents -skip-signing" -- ${cur}))
|
COMPREPLY=($(compgen -W "-batch -force-overwrite -component= -gpg-key= -keyring= -passphrase= -passphrase-file= -secret-keyring= -skip-cleanup -skip-contents -skip-signing" -- ${cur}))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(__aptly_published_distributions)" -- ${cur}))
|
COMPREPLY=($(compgen -W "$(__aptly_published_distributions)" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
@@ -559,7 +559,7 @@ _aptly()
|
|||||||
"drop")
|
"drop")
|
||||||
if [[ $numargs -eq 0 ]]; then
|
if [[ $numargs -eq 0 ]]; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=($(compgen -W "-force-drop" -- ${cur}))
|
COMPREPLY=($(compgen -W "-force-drop -skip-cleanup" -- ${cur}))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "$(__aptly_published_distributions)" -- ${cur}))
|
COMPREPLY=($(compgen -W "$(__aptly_published_distributions)" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
+1
-1
@@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/cheggaaa/pb"
|
"github.com/cheggaaa/pb"
|
||||||
"github.com/smira/aptly/aptly"
|
|
||||||
"github.com/wsxiaoys/terminal/color"
|
"github.com/wsxiaoys/terminal/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+39
-13
@@ -2,9 +2,11 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
gocontext "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
@@ -12,16 +14,16 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/console"
|
"github.com/aptly-dev/aptly/console"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/aptly-dev/aptly/deb"
|
||||||
"github.com/smira/aptly/files"
|
"github.com/aptly-dev/aptly/files"
|
||||||
"github.com/smira/aptly/http"
|
"github.com/aptly-dev/aptly/http"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/s3"
|
"github.com/aptly-dev/aptly/s3"
|
||||||
"github.com/smira/aptly/swift"
|
"github.com/aptly-dev/aptly/swift"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
)
|
)
|
||||||
@@ -30,6 +32,8 @@ import (
|
|||||||
type AptlyContext struct {
|
type AptlyContext struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
|
gocontext.Context
|
||||||
|
|
||||||
flags, globalFlags *flag.FlagSet
|
flags, globalFlags *flag.FlagSet
|
||||||
configLoaded bool
|
configLoaded bool
|
||||||
|
|
||||||
@@ -329,7 +333,7 @@ func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedSto
|
|||||||
} else if strings.HasPrefix(name, "filesystem:") {
|
} else if strings.HasPrefix(name, "filesystem:") {
|
||||||
params, ok := context.config().FileSystemPublishRoots[name[11:]]
|
params, ok := context.config().FileSystemPublishRoots[name[11:]]
|
||||||
if !ok {
|
if !ok {
|
||||||
Fatal(fmt.Errorf("published local storage %v not configured", name[6:]))
|
Fatal(fmt.Errorf("published local storage %v not configured", name[11:]))
|
||||||
}
|
}
|
||||||
|
|
||||||
publishedStorage = files.NewPublishedStorage(params.RootDir, params.LinkMethod, params.VerifyMethod)
|
publishedStorage = files.NewPublishedStorage(params.RootDir, params.LinkMethod, params.VerifyMethod)
|
||||||
@@ -396,7 +400,7 @@ func (context *AptlyContext) GetSigner() pgp.Signer {
|
|||||||
defer context.Unlock()
|
defer context.Unlock()
|
||||||
|
|
||||||
if context.pgpProvider() == "gpg" { // nolint: goconst
|
if context.pgpProvider() == "gpg" { // nolint: goconst
|
||||||
return &pgp.GpgSigner{}
|
return pgp.NewGpgSigner()
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pgp.GoSigner{}
|
return &pgp.GoSigner{}
|
||||||
@@ -408,7 +412,7 @@ func (context *AptlyContext) GetVerifier() pgp.Verifier {
|
|||||||
defer context.Unlock()
|
defer context.Unlock()
|
||||||
|
|
||||||
if context.pgpProvider() == "gpg" { // nolint: goconst
|
if context.pgpProvider() == "gpg" { // nolint: goconst
|
||||||
return &pgp.GpgVerifier{}
|
return pgp.NewGpgVerifier()
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pgp.GoVerifier{}
|
return &pgp.GoVerifier{}
|
||||||
@@ -438,6 +442,27 @@ func (context *AptlyContext) GlobalFlags() *flag.FlagSet {
|
|||||||
return context.globalFlags
|
return context.globalFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GoContextHandleSignals upgrades context to handle ^C by aborting context
|
||||||
|
func (context *AptlyContext) GoContextHandleSignals() {
|
||||||
|
context.Lock()
|
||||||
|
defer context.Unlock()
|
||||||
|
|
||||||
|
// Catch ^C
|
||||||
|
sigch := make(chan os.Signal)
|
||||||
|
signal.Notify(sigch, os.Interrupt)
|
||||||
|
|
||||||
|
var cancel gocontext.CancelFunc
|
||||||
|
|
||||||
|
context.Context, cancel = gocontext.WithCancel(context.Context)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
<-sigch
|
||||||
|
signal.Stop(sigch)
|
||||||
|
context.Progress().PrintfStdErr("Aborting... press ^C once again to abort immediately\n")
|
||||||
|
cancel()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// Shutdown shuts context down
|
// Shutdown shuts context down
|
||||||
func (context *AptlyContext) Shutdown() {
|
func (context *AptlyContext) Shutdown() {
|
||||||
context.Lock()
|
context.Lock()
|
||||||
@@ -494,6 +519,7 @@ func NewContext(flags *flag.FlagSet) (*AptlyContext, error) {
|
|||||||
flags: flags,
|
flags: flags,
|
||||||
globalFlags: flags,
|
globalFlags: flags,
|
||||||
dependencyOptions: -1,
|
dependencyOptions: -1,
|
||||||
|
Context: gocontext.TODO(),
|
||||||
publishedStorages: map[string]aptly.PublishedStorage{},
|
publishedStorages: map[string]aptly.PublishedStorage{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package context
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/smira/flag"
|
||||||
|
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
|
||||||
|
type fatalErrorPanicChecker struct {
|
||||||
|
*CheckerInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
var FatalErrorPanicMatches Checker = &fatalErrorPanicChecker{
|
||||||
|
&CheckerInfo{Name: "FatalErrorPanics", Params: []string{"function", "expected"}},
|
||||||
|
}
|
||||||
|
|
||||||
|
func (checker *fatalErrorPanicChecker) Check(params []interface{}, names []string) (result bool, errmsg string) {
|
||||||
|
f := reflect.ValueOf(params[0])
|
||||||
|
if f.Kind() != reflect.Func || f.Type().NumIn() != 0 {
|
||||||
|
return false, "Function must take zero arguments"
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if errmsg != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
obtained := recover()
|
||||||
|
|
||||||
|
names[0] = "panic"
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
var e1 *FatalError
|
||||||
|
if e1, ok = obtained.(*FatalError); ok {
|
||||||
|
params[0] = e1
|
||||||
|
} else {
|
||||||
|
errmsg = "Panic value is not FatalError"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var e2 *FatalError
|
||||||
|
if e2, ok = params[1].(*FatalError); ok {
|
||||||
|
params[1] = e2
|
||||||
|
} else {
|
||||||
|
errmsg = "Expected value is not FatalError"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if *e1 == *e2 {
|
||||||
|
result = true
|
||||||
|
} else {
|
||||||
|
result = false
|
||||||
|
errmsg = "Not equal"
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
f.Call(nil)
|
||||||
|
return false, "Function has not panicked"
|
||||||
|
}
|
||||||
|
|
||||||
|
type AptlyContextSuite struct {
|
||||||
|
context *AptlyContext
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = Suite(&AptlyContextSuite{})
|
||||||
|
|
||||||
|
func (s *AptlyContextSuite) SetUpTest(c *C) {
|
||||||
|
flags := flag.NewFlagSet("fakeFlags", flag.ContinueOnError)
|
||||||
|
flags.String("config", "", "")
|
||||||
|
context, err := NewContext(flags)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
s.context = context
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AptlyContextSuite) TestGetPublishedStorageBadFS(c *C) {
|
||||||
|
// https://github.com/aptly-dev/aptly/issues/711
|
||||||
|
// This will fail on account of us not having a config, so the
|
||||||
|
// storage never exists.
|
||||||
|
c.Assert(func() { s.context.GetPublishedStorage("filesystem:fuji") },
|
||||||
|
FatalErrorPanicMatches,
|
||||||
|
&FatalError{ReturnCode: 1, Message: "published local storage fuji not configured"})
|
||||||
|
}
|
||||||
+3
-3
@@ -9,9 +9,9 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Changes is a result of .changes file parsing
|
// Changes is a result of .changes file parsing
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package deb
|
package deb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CollectionFactory is a single place to generate all desired collections
|
// CollectionFactory is a single place to generate all desired collections
|
||||||
|
|||||||
+2
-6
@@ -6,8 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/database"
|
|
||||||
"github.com/smira/go-uuid/uuid"
|
"github.com/smira/go-uuid/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,10 +25,7 @@ func NewContentsIndex(db database.Storage) *ContentsIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push adds package to contents index, calculating package contents as required
|
// Push adds package to contents index, calculating package contents as required
|
||||||
func (index *ContentsIndex) Push(p *Package, packagePool aptly.PackagePool, progress aptly.Progress) error {
|
func (index *ContentsIndex) Push(qualifiedName []byte, contents []string) error {
|
||||||
contents := p.Contents(packagePool, progress)
|
|
||||||
qualifiedName := []byte(p.QualifiedName())
|
|
||||||
|
|
||||||
for _, path := range contents {
|
for _, path := range contents {
|
||||||
// for performance reasons we only write to leveldb during push.
|
// for performance reasons we only write to leveldb during push.
|
||||||
// merging of qualified names per path will be done in WriteTo
|
// merging of qualified names per path will be done in WriteTo
|
||||||
|
|||||||
+34
-9
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/mkrautz/goar"
|
"github.com/mkrautz/goar"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/go-xz"
|
"github.com/smira/go-xz"
|
||||||
"github.com/smira/lzma"
|
"github.com/smira/lzma"
|
||||||
)
|
)
|
||||||
@@ -37,21 +37,46 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
|
|||||||
library := ar.NewReader(file)
|
library := ar.NewReader(file)
|
||||||
for {
|
for {
|
||||||
header, err := library.Next()
|
header, err := library.Next()
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return nil, fmt.Errorf("unable to find control.tar.gz part in package %s", packageFile)
|
return nil, fmt.Errorf("unable to find control.tar.* part in package %s", packageFile)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to read .deb archive %s: %s", packageFile, err)
|
return nil, fmt.Errorf("unable to read .deb archive %s: %s", packageFile, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if header.Name == "control.tar.gz" {
|
// As per deb(5) version 1.19.0.4 the control file may be:
|
||||||
ungzip, err := gzip.NewReader(library)
|
// - control.tar (since 1.17.6)
|
||||||
if err != nil {
|
// - control.tar.gz
|
||||||
return nil, fmt.Errorf("unable to ungzip control file from %s. Error: %s", packageFile, err)
|
// - control.tar.xz (since 1.17.6)
|
||||||
}
|
// Look for all of the above and uncompress as necessary.
|
||||||
defer ungzip.Close()
|
if strings.HasPrefix(header.Name, "control.tar") {
|
||||||
|
bufReader := bufio.NewReader(library)
|
||||||
|
|
||||||
untar := tar.NewReader(ungzip)
|
var tarInput io.Reader
|
||||||
|
|
||||||
|
switch header.Name {
|
||||||
|
case "control.tar":
|
||||||
|
tarInput = bufReader
|
||||||
|
case "control.tar.gz":
|
||||||
|
ungzip, err := gzip.NewReader(bufReader)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "unable to ungzip %s from %s", header.Name, packageFile)
|
||||||
|
}
|
||||||
|
defer ungzip.Close()
|
||||||
|
tarInput = ungzip
|
||||||
|
case "control.tar.xz":
|
||||||
|
unxz, err := xz.NewReader(bufReader)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "unable to unxz %s from %s", header.Name, packageFile)
|
||||||
|
}
|
||||||
|
defer unxz.Close()
|
||||||
|
tarInput = unxz
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unsupported tar compression in %s: %s", packageFile, header.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
untar := tar.NewReader(tarInput)
|
||||||
for {
|
for {
|
||||||
tarHeader, err := untar.Next()
|
tarHeader, err := untar.Next()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
|||||||
+11
-2
@@ -5,13 +5,13 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DebSuite struct {
|
type DebSuite struct {
|
||||||
debFile, debFile2, dscFile, dscFileNoSign string
|
debFile, debFile2, debFileWithXzControl, dscFile, dscFileNoSign string
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Suite(&DebSuite{})
|
var _ = Suite(&DebSuite{})
|
||||||
@@ -20,6 +20,7 @@ func (s *DebSuite) SetUpSuite(c *C) {
|
|||||||
_, _File, _, _ := runtime.Caller(0)
|
_, _File, _, _ := runtime.Caller(0)
|
||||||
s.debFile = filepath.Join(filepath.Dir(_File), "../system/files/libboost-program-options-dev_1.49.0.1_i386.deb")
|
s.debFile = filepath.Join(filepath.Dir(_File), "../system/files/libboost-program-options-dev_1.49.0.1_i386.deb")
|
||||||
s.debFile2 = filepath.Join(filepath.Dir(_File), "../system/changes/hardlink_0.2.1_amd64.deb")
|
s.debFile2 = filepath.Join(filepath.Dir(_File), "../system/changes/hardlink_0.2.1_amd64.deb")
|
||||||
|
s.debFileWithXzControl = filepath.Join(filepath.Dir(_File), "../system/changes/libqt5concurrent5-dbgsym_5.9.1+dfsg-2+18.04+bionic+build4_amd64.ddeb")
|
||||||
s.dscFile = filepath.Join(filepath.Dir(_File), "../system/files/pyspi_0.6.1-1.3.dsc")
|
s.dscFile = filepath.Join(filepath.Dir(_File), "../system/files/pyspi_0.6.1-1.3.dsc")
|
||||||
s.dscFileNoSign = filepath.Join(filepath.Dir(_File), "../system/files/pyspi-0.6.1-1.3.stripped.dsc")
|
s.dscFileNoSign = filepath.Join(filepath.Dir(_File), "../system/files/pyspi-0.6.1-1.3.stripped.dsc")
|
||||||
}
|
}
|
||||||
@@ -38,6 +39,14 @@ func (s *DebSuite) TestGetControlFileFromDeb(c *C) {
|
|||||||
c.Check(st["Package"], Equals, "libboost-program-options-dev")
|
c.Check(st["Package"], Equals, "libboost-program-options-dev")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DebSuite) TestGetControlFileFromDebWithXzControl(c *C) {
|
||||||
|
// Has control.tar.xz archive inside.
|
||||||
|
st, err := GetControlFileFromDeb(s.debFileWithXzControl)
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
c.Check(st["Version"], Equals, "5.9.1+dfsg-2+18.04+bionic+build4")
|
||||||
|
c.Check(st["Package"], Equals, "libqt5concurrent5-dbgsym")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DebSuite) TestGetControlFileFromDsc(c *C) {
|
func (s *DebSuite) TestGetControlFileFromDsc(c *C) {
|
||||||
verifier := &pgp.GoVerifier{}
|
verifier := &pgp.GoVerifier{}
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -11,6 +11,9 @@ import (
|
|||||||
// Stanza or paragraph of Debian control file
|
// Stanza or paragraph of Debian control file
|
||||||
type Stanza map[string]string
|
type Stanza map[string]string
|
||||||
|
|
||||||
|
// MaxFieldSize is maximum stanza field size in bytes
|
||||||
|
const MaxFieldSize = 2 * 1024 * 1024
|
||||||
|
|
||||||
// Canonical order of fields in stanza
|
// Canonical order of fields in stanza
|
||||||
// Taken from: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/vivid/apt/vivid/view/head:/apt-pkg/tagfile.cc#L504
|
// Taken from: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/vivid/apt/vivid/view/head:/apt-pkg/tagfile.cc#L504
|
||||||
var (
|
var (
|
||||||
@@ -214,7 +217,10 @@ type ControlFileReader struct {
|
|||||||
|
|
||||||
// NewControlFileReader creates ControlFileReader, it wraps with buffering
|
// NewControlFileReader creates ControlFileReader, it wraps with buffering
|
||||||
func NewControlFileReader(r io.Reader) *ControlFileReader {
|
func NewControlFileReader(r io.Reader) *ControlFileReader {
|
||||||
return &ControlFileReader{scanner: bufio.NewScanner(bufio.NewReaderSize(r, 32768))}
|
scnr := bufio.NewScanner(bufio.NewReaderSize(r, 32768))
|
||||||
|
scnr.Buffer(nil, MaxFieldSize)
|
||||||
|
|
||||||
|
return &ControlFileReader{scanner: scnr}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadStanza reeads one stanza from control file
|
// ReadStanza reeads one stanza from control file
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
@@ -135,6 +136,17 @@ func (s *ControlFileSuite) TestCanonicalCase(c *C) {
|
|||||||
c.Check(canonicalCase("packaGe-lIst"), Equals, "Package-List")
|
c.Check(canonicalCase("packaGe-lIst"), Equals, "Package-List")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ControlFileSuite) TestLongFields(c *C) {
|
||||||
|
f, err := os.Open("long.stanza")
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
r := NewControlFileReader(f)
|
||||||
|
stanza, e := r.ReadStanza(false)
|
||||||
|
c.Assert(e, IsNil)
|
||||||
|
c.Assert(len(stanza["Provides"]), Equals, 586929)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ControlFileSuite) BenchmarkReadStanza(c *C) {
|
func (s *ControlFileSuite) BenchmarkReadStanza(c *C) {
|
||||||
for i := 0; i < c.N; i++ {
|
for i := 0; i < c.N; i++ {
|
||||||
reader := bytes.NewBufferString(controlFile)
|
reader := bytes.NewBufferString(controlFile)
|
||||||
|
|||||||
+31
-7
@@ -6,13 +6,13 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CollectPackageFiles walks filesystem collecting all candidates for package files
|
// CollectPackageFiles walks filesystem collecting all candidates for package files
|
||||||
func CollectPackageFiles(locations []string, reporter aptly.ResultReporter) (packageFiles, failedFiles []string) {
|
func CollectPackageFiles(locations []string, reporter aptly.ResultReporter) (packageFiles, otherFiles, failedFiles []string) {
|
||||||
for _, location := range locations {
|
for _, location := range locations {
|
||||||
info, err2 := os.Stat(location)
|
info, err2 := os.Stat(location)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
@@ -32,6 +32,8 @@ func CollectPackageFiles(locations []string, reporter aptly.ResultReporter) (pac
|
|||||||
if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".udeb") ||
|
if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".udeb") ||
|
||||||
strings.HasSuffix(info.Name(), ".dsc") || strings.HasSuffix(info.Name(), ".ddeb") {
|
strings.HasSuffix(info.Name(), ".dsc") || strings.HasSuffix(info.Name(), ".ddeb") {
|
||||||
packageFiles = append(packageFiles, path)
|
packageFiles = append(packageFiles, path)
|
||||||
|
} else if strings.HasSuffix(info.Name(), ".buildinfo") {
|
||||||
|
otherFiles = append(otherFiles, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -46,6 +48,8 @@ func CollectPackageFiles(locations []string, reporter aptly.ResultReporter) (pac
|
|||||||
if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".udeb") ||
|
if strings.HasSuffix(info.Name(), ".deb") || strings.HasSuffix(info.Name(), ".udeb") ||
|
||||||
strings.HasSuffix(info.Name(), ".dsc") || strings.HasSuffix(info.Name(), ".ddeb") {
|
strings.HasSuffix(info.Name(), ".dsc") || strings.HasSuffix(info.Name(), ".ddeb") {
|
||||||
packageFiles = append(packageFiles, location)
|
packageFiles = append(packageFiles, location)
|
||||||
|
} else if strings.HasSuffix(info.Name(), ".buildinfo") {
|
||||||
|
otherFiles = append(otherFiles, location)
|
||||||
} else {
|
} else {
|
||||||
reporter.Warning("Unknown file extension: %s", location)
|
reporter.Warning("Unknown file extension: %s", location)
|
||||||
failedFiles = append(failedFiles, location)
|
failedFiles = append(failedFiles, location)
|
||||||
@@ -147,14 +151,34 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
|
|||||||
// go over all the other files
|
// go over all the other files
|
||||||
for i := range files {
|
for i := range files {
|
||||||
sourceFile := filepath.Join(filepath.Dir(file), filepath.Base(files[i].Filename))
|
sourceFile := filepath.Join(filepath.Dir(file), filepath.Base(files[i].Filename))
|
||||||
files[i].PoolPath, err = pool.Import(sourceFile, files[i].Filename, &files[i].Checksums, false, checksumStorage)
|
|
||||||
|
_, err = os.Stat(sourceFile)
|
||||||
|
if err == nil {
|
||||||
|
files[i].PoolPath, err = pool.Import(sourceFile, files[i].Filename, &files[i].Checksums, false, checksumStorage)
|
||||||
|
if err == nil {
|
||||||
|
candidateProcessedFiles = append(candidateProcessedFiles, sourceFile)
|
||||||
|
}
|
||||||
|
} else if os.IsNotExist(err) {
|
||||||
|
// if file is not present, try to find it in the pool
|
||||||
|
var (
|
||||||
|
err2 error
|
||||||
|
found bool
|
||||||
|
)
|
||||||
|
|
||||||
|
files[i].PoolPath, found, err2 = pool.Verify("", files[i].Filename, &files[i].Checksums, checksumStorage)
|
||||||
|
if err2 != nil {
|
||||||
|
err = err2
|
||||||
|
} else if found {
|
||||||
|
// clear error, file is already in the package pool
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reporter.Warning("Unable to import file %s into pool: %s", sourceFile, err)
|
reporter.Warning("Unable to import file %s into pool: %s", sourceFile, err)
|
||||||
failedFiles = append(failedFiles, file)
|
failedFiles = append(failedFiles, file)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
candidateProcessedFiles = append(candidateProcessedFiles, sourceFile)
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// some files haven't been imported
|
// some files haven't been imported
|
||||||
|
|||||||
+139
-30
@@ -4,12 +4,13 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type indexFiles struct {
|
type indexFiles struct {
|
||||||
@@ -20,18 +21,20 @@ type indexFiles struct {
|
|||||||
tempDir string
|
tempDir string
|
||||||
suffix string
|
suffix string
|
||||||
indexes map[string]*indexFile
|
indexes map[string]*indexFile
|
||||||
|
acquireByHash bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type indexFile struct {
|
type indexFile struct {
|
||||||
parent *indexFiles
|
parent *indexFiles
|
||||||
discardable bool
|
discardable bool
|
||||||
compressable bool
|
compressable bool
|
||||||
onlyGzip bool
|
onlyGzip bool
|
||||||
signable bool
|
signable bool
|
||||||
relativePath string
|
acquireByHash bool
|
||||||
tempFilename string
|
relativePath string
|
||||||
tempFile *os.File
|
tempFilename string
|
||||||
w *bufio.Writer
|
tempFile *os.File
|
||||||
|
w *bufio.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *indexFile) BufWriter() (*bufio.Writer, error) {
|
func (file *indexFile) BufWriter() (*bufio.Writer, error) {
|
||||||
@@ -91,11 +94,22 @@ func (file *indexFile) Finalize(signer pgp.Signer) error {
|
|||||||
file.parent.generatedFiles[file.relativePath+ext] = checksumInfo
|
file.parent.generatedFiles[file.relativePath+ext] = checksumInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
err = file.parent.publishedStorage.MkDir(filepath.Dir(filepath.Join(file.parent.basePath, file.relativePath)))
|
filedir := filepath.Dir(filepath.Join(file.parent.basePath, file.relativePath))
|
||||||
|
|
||||||
|
err = file.parent.publishedStorage.MkDir(filedir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to create dir: %s", err)
|
return fmt.Errorf("unable to create dir: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if file.acquireByHash {
|
||||||
|
for _, hash := range []string{"MD5Sum", "SHA1", "SHA256", "SHA512"} {
|
||||||
|
err = file.parent.publishedStorage.MkDir(filepath.Join(filedir, "by-hash", hash))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to create dir: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, ext := range exts {
|
for _, ext := range exts {
|
||||||
err = file.parent.publishedStorage.PutFile(filepath.Join(file.parent.basePath, file.relativePath+file.parent.suffix+ext),
|
err = file.parent.publishedStorage.PutFile(filepath.Join(file.parent.basePath, file.relativePath+file.parent.suffix+ext),
|
||||||
file.tempFilename+ext)
|
file.tempFilename+ext)
|
||||||
@@ -107,6 +121,16 @@ func (file *indexFile) Finalize(signer pgp.Signer) error {
|
|||||||
file.parent.renameMap[filepath.Join(file.parent.basePath, file.relativePath+file.parent.suffix+ext)] =
|
file.parent.renameMap[filepath.Join(file.parent.basePath, file.relativePath+file.parent.suffix+ext)] =
|
||||||
filepath.Join(file.parent.basePath, file.relativePath+ext)
|
filepath.Join(file.parent.basePath, file.relativePath+ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if file.acquireByHash {
|
||||||
|
sums := file.parent.generatedFiles[file.relativePath+ext]
|
||||||
|
for hash, sum := range map[string]string{"SHA512": sums.SHA512, "SHA256": sums.SHA256, "SHA1": sums.SHA1, "MD5Sum": sums.MD5} {
|
||||||
|
err = packageIndexByHash(file, ext, hash, sum)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to build hash file: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.signable && signer != nil {
|
if file.signable && signer != nil {
|
||||||
@@ -143,7 +167,57 @@ func (file *indexFile) Finalize(signer pgp.Signer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newIndexFiles(publishedStorage aptly.PublishedStorage, basePath, tempDir, suffix string) *indexFiles {
|
func packageIndexByHash(file *indexFile, ext string, hash string, sum string) error {
|
||||||
|
src := filepath.Join(file.parent.basePath, file.relativePath)
|
||||||
|
indexfile := path.Base(src + ext)
|
||||||
|
src = src + file.parent.suffix + ext
|
||||||
|
filedir := filepath.Dir(filepath.Join(file.parent.basePath, file.relativePath))
|
||||||
|
dst := filepath.Join(filedir, "by-hash", hash)
|
||||||
|
sumfilePath := filepath.Join(dst, sum)
|
||||||
|
|
||||||
|
// link already exists? do nothing
|
||||||
|
exists, err := file.parent.publishedStorage.FileExists(sumfilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Acquire-By-Hash: error checking exists of file %s: %s", sumfilePath, err)
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the link
|
||||||
|
err = file.parent.publishedStorage.HardLink(src, sumfilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Acquire-By-Hash: error creating hardlink %s: %s", sumfilePath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if a previous index file already exists exists, backup symlink
|
||||||
|
indexPath := filepath.Join(dst, indexfile)
|
||||||
|
oldIndexPath := filepath.Join(dst, indexfile+".old")
|
||||||
|
if exists, _ = file.parent.publishedStorage.FileExists(indexPath); exists {
|
||||||
|
// if exists, remove old symlink
|
||||||
|
if exists, _ = file.parent.publishedStorage.FileExists(oldIndexPath); exists {
|
||||||
|
var linkTarget string
|
||||||
|
linkTarget, err = file.parent.publishedStorage.ReadLink(oldIndexPath)
|
||||||
|
if err == nil {
|
||||||
|
// If we managed to resolve the link target: delete it. This is the
|
||||||
|
// oldest physical index file we no longer need. Once we drop our
|
||||||
|
// old symlink we'll essentially forget about it existing at all.
|
||||||
|
file.parent.publishedStorage.Remove(linkTarget)
|
||||||
|
}
|
||||||
|
file.parent.publishedStorage.Remove(oldIndexPath)
|
||||||
|
}
|
||||||
|
file.parent.publishedStorage.RenameFile(indexPath, oldIndexPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// create symlink
|
||||||
|
err = file.parent.publishedStorage.SymLink(filepath.Join(dst, sum), filepath.Join(dst, indexfile))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Acquire-By-Hash: error creating symlink %s: %s", filepath.Join(dst, indexfile), err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newIndexFiles(publishedStorage aptly.PublishedStorage, basePath, tempDir, suffix string, acquireByHash bool) *indexFiles {
|
||||||
return &indexFiles{
|
return &indexFiles{
|
||||||
publishedStorage: publishedStorage,
|
publishedStorage: publishedStorage,
|
||||||
basePath: basePath,
|
basePath: basePath,
|
||||||
@@ -152,6 +226,7 @@ func newIndexFiles(publishedStorage aptly.PublishedStorage, basePath, tempDir, s
|
|||||||
tempDir: tempDir,
|
tempDir: tempDir,
|
||||||
suffix: suffix,
|
suffix: suffix,
|
||||||
indexes: make(map[string]*indexFile),
|
indexes: make(map[string]*indexFile),
|
||||||
|
acquireByHash: acquireByHash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,11 +250,12 @@ func (files *indexFiles) PackageIndex(component, arch string, udeb bool) *indexF
|
|||||||
}
|
}
|
||||||
|
|
||||||
file = &indexFile{
|
file = &indexFile{
|
||||||
parent: files,
|
parent: files,
|
||||||
discardable: false,
|
discardable: false,
|
||||||
compressable: true,
|
compressable: true,
|
||||||
signable: false,
|
signable: false,
|
||||||
relativePath: relativePath,
|
acquireByHash: files.acquireByHash,
|
||||||
|
relativePath: relativePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
files.indexes[key] = file
|
files.indexes[key] = file
|
||||||
@@ -208,11 +284,12 @@ func (files *indexFiles) ReleaseIndex(component, arch string, udeb bool) *indexF
|
|||||||
}
|
}
|
||||||
|
|
||||||
file = &indexFile{
|
file = &indexFile{
|
||||||
parent: files,
|
parent: files,
|
||||||
discardable: udeb,
|
discardable: udeb,
|
||||||
compressable: false,
|
compressable: false,
|
||||||
signable: false,
|
signable: false,
|
||||||
relativePath: relativePath,
|
acquireByHash: files.acquireByHash,
|
||||||
|
relativePath: relativePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
files.indexes[key] = file
|
files.indexes[key] = file
|
||||||
@@ -237,12 +314,44 @@ func (files *indexFiles) ContentsIndex(component, arch string, udeb bool) *index
|
|||||||
}
|
}
|
||||||
|
|
||||||
file = &indexFile{
|
file = &indexFile{
|
||||||
parent: files,
|
parent: files,
|
||||||
discardable: true,
|
discardable: true,
|
||||||
compressable: true,
|
compressable: true,
|
||||||
onlyGzip: true,
|
onlyGzip: true,
|
||||||
signable: false,
|
signable: false,
|
||||||
relativePath: relativePath,
|
acquireByHash: files.acquireByHash,
|
||||||
|
relativePath: relativePath,
|
||||||
|
}
|
||||||
|
|
||||||
|
files.indexes[key] = file
|
||||||
|
}
|
||||||
|
|
||||||
|
return file
|
||||||
|
}
|
||||||
|
|
||||||
|
func (files *indexFiles) LegacyContentsIndex(arch string, udeb bool) *indexFile {
|
||||||
|
if arch == ArchitectureSource {
|
||||||
|
udeb = false
|
||||||
|
}
|
||||||
|
key := fmt.Sprintf("lci-%s-%v", arch, udeb)
|
||||||
|
file, ok := files.indexes[key]
|
||||||
|
if !ok {
|
||||||
|
var relativePath string
|
||||||
|
|
||||||
|
if udeb {
|
||||||
|
relativePath = fmt.Sprintf("Contents-udeb-%s", arch)
|
||||||
|
} else {
|
||||||
|
relativePath = fmt.Sprintf("Contents-%s", arch)
|
||||||
|
}
|
||||||
|
|
||||||
|
file = &indexFile{
|
||||||
|
parent: files,
|
||||||
|
discardable: true,
|
||||||
|
compressable: true,
|
||||||
|
onlyGzip: true,
|
||||||
|
signable: false,
|
||||||
|
acquireByHash: files.acquireByHash,
|
||||||
|
relativePath: relativePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
files.indexes[key] = file
|
files.indexes[key] = file
|
||||||
|
|||||||
+39
-19
@@ -5,8 +5,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Dependency options
|
// Dependency options
|
||||||
@@ -124,6 +124,14 @@ func NewPackageListFromRefList(reflist *PackageRefList, collection *PackageColle
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Has checks whether package is already in the list
|
||||||
|
func (l *PackageList) Has(p *Package) bool {
|
||||||
|
key := l.keyFunc(p)
|
||||||
|
_, ok := l.packages[key]
|
||||||
|
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// Add appends package to package list, additionally checking for uniqueness
|
// Add appends package to package list, additionally checking for uniqueness
|
||||||
func (l *PackageList) Add(p *Package) error {
|
func (l *PackageList) Add(p *Package) error {
|
||||||
key := l.keyFunc(p)
|
key := l.keyFunc(p)
|
||||||
@@ -441,18 +449,6 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*
|
|||||||
panic("list not indexed, can't search")
|
panic("list not indexed, can't search")
|
||||||
}
|
}
|
||||||
|
|
||||||
if dep.Relation == VersionDontCare {
|
|
||||||
for _, p := range l.providesIndex[dep.Pkg] {
|
|
||||||
if dep.Architecture == "" || p.MatchesArchitecture(dep.Architecture) {
|
|
||||||
searchResults = append(searchResults, p)
|
|
||||||
|
|
||||||
if !allMatches {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i := sort.Search(len(l.packagesIndex), func(j int) bool { return l.packagesIndex[j].Name >= dep.Pkg })
|
i := sort.Search(len(l.packagesIndex), func(j int) bool { return l.packagesIndex[j].Name >= dep.Pkg })
|
||||||
|
|
||||||
for i < len(l.packagesIndex) && l.packagesIndex[i].Name == dep.Pkg {
|
for i < len(l.packagesIndex) && l.packagesIndex[i].Name == dep.Pkg {
|
||||||
@@ -468,6 +464,18 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dep.Relation == VersionDontCare {
|
||||||
|
for _, p := range l.providesIndex[dep.Pkg] {
|
||||||
|
if dep.Architecture == "" || p.MatchesArchitecture(dep.Architecture) {
|
||||||
|
searchResults = append(searchResults, p)
|
||||||
|
|
||||||
|
if !allMatches {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,15 +519,27 @@ func (l *PackageList) FilterWithProgress(queries []PackageQuery, withDependencie
|
|||||||
|
|
||||||
// try to satisfy dependencies
|
// try to satisfy dependencies
|
||||||
for _, dep := range missing {
|
for _, dep := range missing {
|
||||||
// dependency might have already been satisfied
|
if dependencyOptions&DepFollowAllVariants == 0 {
|
||||||
// with packages already been added
|
// dependency might have already been satisfied
|
||||||
if result.Search(dep, false) != nil {
|
// with packages already been added
|
||||||
continue
|
//
|
||||||
|
// when follow-all-variants is enabled, we need to try to expand anyway,
|
||||||
|
// as even if dependency is satisfied now, there might be other ways to satisfy dependency
|
||||||
|
if result.Search(dep, false) != nil {
|
||||||
|
if dependencyOptions&DepVerboseResolve == DepVerboseResolve && progress != nil {
|
||||||
|
progress.ColoredPrintf("@{y}Already satisfied dependency@|: %s with %s", &dep, result.Search(dep, true))
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResults := l.Search(dep, true)
|
searchResults := l.Search(dep, true)
|
||||||
if searchResults != nil {
|
if len(searchResults) > 0 {
|
||||||
for _, p := range searchResults {
|
for _, p := range searchResults {
|
||||||
|
if result.Has(p) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if dependencyOptions&DepVerboseResolve == DepVerboseResolve && progress != nil {
|
if dependencyOptions&DepVerboseResolve == DepVerboseResolve && progress != nil {
|
||||||
progress.ColoredPrintf("@{g}Injecting package@|: %s", p)
|
progress.ColoredPrintf("@{g}Injecting package@|: %s", p)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/go-uuid/uuid"
|
"github.com/smira/go-uuid/uuid"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+7
-5
@@ -7,8 +7,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Package is single instance of Debian package
|
// Package is single instance of Debian package
|
||||||
@@ -622,6 +622,7 @@ type PackageDownloadTask struct {
|
|||||||
File *PackageFile
|
File *PackageFile
|
||||||
Additional []PackageDownloadTask
|
Additional []PackageDownloadTask
|
||||||
TempDownPath string
|
TempDownPath string
|
||||||
|
Done bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DownloadList returns list of missing package files for download in format
|
// DownloadList returns list of missing package files for download in format
|
||||||
@@ -629,14 +630,15 @@ type PackageDownloadTask struct {
|
|||||||
func (p *Package) DownloadList(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (result []PackageDownloadTask, err error) {
|
func (p *Package) DownloadList(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (result []PackageDownloadTask, err error) {
|
||||||
result = make([]PackageDownloadTask, 0, 1)
|
result = make([]PackageDownloadTask, 0, 1)
|
||||||
|
|
||||||
for idx, f := range p.Files() {
|
files := p.Files()
|
||||||
verified, err := f.Verify(packagePool, checksumStorage)
|
for idx := range files {
|
||||||
|
verified, err := files[idx].Verify(packagePool, checksumStorage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !verified {
|
if !verified {
|
||||||
result = append(result, PackageDownloadTask{File: &p.Files()[idx]})
|
result = append(result, PackageDownloadTask{File: &files[idx]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ func (collection *PackageCollection) SearchSupported() bool {
|
|||||||
|
|
||||||
// SearchByKey finds package by exact key
|
// SearchByKey finds package by exact key
|
||||||
func (collection *PackageCollection) SearchByKey(arch, name, version string) (result *PackageList) {
|
func (collection *PackageCollection) SearchByKey(arch, name, version string) (result *PackageList) {
|
||||||
result = NewPackageList()
|
result = NewPackageListWithDuplicates(true, 0)
|
||||||
|
|
||||||
for _, key := range collection.db.KeysByPrefix([]byte(fmt.Sprintf("P%s %s %s", arch, name, version))) {
|
for _, key := range collection.db.KeysByPrefix([]byte(fmt.Sprintf("P%s %s %s", arch, name, version))) {
|
||||||
pkg, err := collection.ByKey(key)
|
pkg, err := collection.ByKey(key)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package deb
|
package deb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PackageFile is a single file entry in package
|
// PackageFile is a single file entry in package
|
||||||
@@ -27,7 +27,12 @@ type PackageFile struct {
|
|||||||
|
|
||||||
// Verify that package file is present and correct
|
// Verify that package file is present and correct
|
||||||
func (f *PackageFile) Verify(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (bool, error) {
|
func (f *PackageFile) Verify(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (bool, error) {
|
||||||
return packagePool.Verify(f.PoolPath, f.Filename, &f.Checksums, checksumStorage)
|
generatedPoolPath, exists, err := packagePool.Verify(f.PoolPath, f.Filename, &f.Checksums, checksumStorage)
|
||||||
|
if exists && err == nil {
|
||||||
|
f.PoolPath = generatedPoolPath
|
||||||
|
}
|
||||||
|
|
||||||
|
return exists, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPoolPath returns path to the file in the pool
|
// GetPoolPath returns path to the file in the pool
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/files"
|
"github.com/aptly-dev/aptly/files"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/smira/aptly/files"
|
"github.com/aptly-dev/aptly/files"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ppaRegexp = regexp.MustCompile("^ppa:([^/]+)/(.+)$")
|
var ppaRegexp = regexp.MustCompile("^ppa:([^/]+)/(.+)$")
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package deb
|
package deb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+56
-13
@@ -17,10 +17,10 @@ import (
|
|||||||
"github.com/smira/go-uuid/uuid"
|
"github.com/smira/go-uuid/uuid"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type repoSourceItem struct {
|
type repoSourceItem struct {
|
||||||
@@ -64,6 +64,9 @@ type PublishedRepo struct {
|
|||||||
|
|
||||||
// True if repo is being re-published
|
// True if repo is being re-published
|
||||||
rePublishing bool
|
rePublishing bool
|
||||||
|
|
||||||
|
// Provide index files per hash also
|
||||||
|
AcquireByHash bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePrefix splits [storage:]prefix into components
|
// ParsePrefix splits [storage:]prefix into components
|
||||||
@@ -312,6 +315,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
|
|||||||
"Sources": sources,
|
"Sources": sources,
|
||||||
"Storage": p.Storage,
|
"Storage": p.Storage,
|
||||||
"SkipContents": p.SkipContents,
|
"SkipContents": p.SkipContents,
|
||||||
|
"AcquireByHash": p.AcquireByHash,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +560,9 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tempDir)
|
defer os.RemoveAll(tempDir)
|
||||||
|
|
||||||
indexes := newIndexFiles(publishedStorage, basePath, tempDir, suffix)
|
indexes := newIndexFiles(publishedStorage, basePath, tempDir, suffix, p.AcquireByHash)
|
||||||
|
|
||||||
|
legacyContentIndexes := map[string]*ContentsIndex{}
|
||||||
|
|
||||||
for component, list := range lists {
|
for component, list := range lists {
|
||||||
hadUdebs := false
|
hadUdebs := false
|
||||||
@@ -595,21 +601,32 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start a db batch. If we fill contents data we'll need
|
||||||
|
// to push each path of the package into the database.
|
||||||
|
// We'll want this batched so as to avoid an excessive
|
||||||
|
// amount of write() calls.
|
||||||
|
tempDB.StartBatch()
|
||||||
|
defer tempDB.FinishBatch()
|
||||||
|
|
||||||
for _, arch := range p.Architectures {
|
for _, arch := range p.Architectures {
|
||||||
if pkg.MatchesArchitecture(arch) {
|
if pkg.MatchesArchitecture(arch) {
|
||||||
var bufWriter *bufio.Writer
|
var bufWriter *bufio.Writer
|
||||||
|
|
||||||
if !p.SkipContents {
|
if !p.SkipContents {
|
||||||
key := fmt.Sprintf("%s-%v", arch, pkg.IsUdeb)
|
key := fmt.Sprintf("%s-%v", arch, pkg.IsUdeb)
|
||||||
|
qualifiedName := []byte(pkg.QualifiedName())
|
||||||
|
contents := pkg.Contents(packagePool, progress)
|
||||||
|
|
||||||
contentIndex := contentIndexes[key]
|
for _, contentIndexesMap := range []map[string]*ContentsIndex{contentIndexes, legacyContentIndexes} {
|
||||||
|
contentIndex := contentIndexesMap[key]
|
||||||
|
|
||||||
if contentIndex == nil {
|
if contentIndex == nil {
|
||||||
contentIndex = NewContentsIndex(tempDB)
|
contentIndex = NewContentsIndex(tempDB)
|
||||||
contentIndexes[key] = contentIndex
|
contentIndexesMap[key] = contentIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
contentIndex.Push(qualifiedName, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
contentIndex.Push(pkg, packagePool, progress)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb).BufWriter()
|
bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb).BufWriter()
|
||||||
@@ -683,6 +700,9 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
release["Component"] = component
|
release["Component"] = component
|
||||||
release["Origin"] = p.GetOrigin()
|
release["Origin"] = p.GetOrigin()
|
||||||
release["Label"] = p.GetLabel()
|
release["Label"] = p.GetLabel()
|
||||||
|
if p.AcquireByHash {
|
||||||
|
release["Acquire-By-Hash"] = "yes"
|
||||||
|
}
|
||||||
|
|
||||||
var bufWriter *bufio.Writer
|
var bufWriter *bufio.Writer
|
||||||
bufWriter, err = indexes.ReleaseIndex(component, arch, udeb).BufWriter()
|
bufWriter, err = indexes.ReleaseIndex(component, arch, udeb).BufWriter()
|
||||||
@@ -698,6 +718,26 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, arch := range p.Architectures {
|
||||||
|
for _, udeb := range []bool{true, false} {
|
||||||
|
index := legacyContentIndexes[fmt.Sprintf("%s-%v", arch, udeb)]
|
||||||
|
if index == nil || index.Empty() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var bufWriter *bufio.Writer
|
||||||
|
bufWriter, err = indexes.LegacyContentsIndex(arch, udeb).BufWriter()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to generate contents index: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = index.WriteTo(bufWriter)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to generate contents index: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if progress != nil {
|
if progress != nil {
|
||||||
progress.Printf("Finalizing metadata files...\n")
|
progress.Printf("Finalizing metadata files...\n")
|
||||||
}
|
}
|
||||||
@@ -720,6 +760,9 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
release["Codename"] = p.Distribution
|
release["Codename"] = p.Distribution
|
||||||
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
|
release["Date"] = time.Now().UTC().Format("Mon, 2 Jan 2006 15:04:05 MST")
|
||||||
release["Architectures"] = strings.Join(utils.StrSlicesSubstract(p.Architectures, []string{ArchitectureSource}), " ")
|
release["Architectures"] = strings.Join(utils.StrSlicesSubstract(p.Architectures, []string{ArchitectureSource}), " ")
|
||||||
|
if p.AcquireByHash {
|
||||||
|
release["Acquire-By-Hash"] = "yes"
|
||||||
|
}
|
||||||
release["Description"] = " Generated by aptly\n"
|
release["Description"] = " Generated by aptly\n"
|
||||||
release["MD5Sum"] = ""
|
release["MD5Sum"] = ""
|
||||||
release["SHA1"] = ""
|
release["SHA1"] = ""
|
||||||
@@ -1097,7 +1140,7 @@ func (collection *PublishedRepoCollection) CleanupPrefixComponentFiles(prefix st
|
|||||||
// Remove removes published repository, cleaning up directories, files
|
// Remove removes published repository, cleaning up directories, files
|
||||||
func (collection *PublishedRepoCollection) Remove(publishedStorageProvider aptly.PublishedStorageProvider,
|
func (collection *PublishedRepoCollection) Remove(publishedStorageProvider aptly.PublishedStorageProvider,
|
||||||
storage, prefix, distribution string, collectionFactory *CollectionFactory, progress aptly.Progress,
|
storage, prefix, distribution string, collectionFactory *CollectionFactory, progress aptly.Progress,
|
||||||
force bool) error {
|
force, skipCleanup bool) error {
|
||||||
repo, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
|
repo, err := collection.ByStoragePrefixDistribution(storage, prefix, distribution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1134,7 +1177,7 @@ func (collection *PublishedRepoCollection) Remove(publishedStorageProvider aptly
|
|||||||
collection.list[len(collection.list)-1], collection.list[repoPosition], collection.list =
|
collection.list[len(collection.list)-1], collection.list[repoPosition], collection.list =
|
||||||
nil, collection.list[len(collection.list)-1], collection.list[:len(collection.list)-1]
|
nil, collection.list[len(collection.list)-1], collection.list[:len(collection.list)-1]
|
||||||
|
|
||||||
if len(cleanComponents) > 0 {
|
if !skipCleanup && len(cleanComponents) > 0 {
|
||||||
err = collection.CleanupPrefixComponentFiles(repo.Prefix, cleanComponents,
|
err = collection.CleanupPrefixComponentFiles(repo.Prefix, cleanComponents,
|
||||||
publishedStorageProvider.GetPublishedStorage(storage), collectionFactory, progress)
|
publishedStorageProvider.GetPublishedStorage(storage), collectionFactory, progress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+46
-8
@@ -8,9 +8,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/files"
|
"github.com/aptly-dev/aptly/files"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
@@ -756,7 +756,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefixRoot(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *PublishedRepoRemoveSuite) TestRemoveRepo1and2(c *C) {
|
func (s *PublishedRepoRemoveSuite) TestRemoveRepo1and2(c *C) {
|
||||||
err := s.collection.Remove(s.provider, "", "ppa", "anaconda", s.factory, nil, false)
|
err := s.collection.Remove(s.provider, "", "ppa", "anaconda", s.factory, nil, false, false)
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
_, err = s.collection.ByStoragePrefixDistribution("", "ppa", "anaconda")
|
_, err = s.collection.ByStoragePrefixDistribution("", "ppa", "anaconda")
|
||||||
@@ -776,10 +776,48 @@ func (s *PublishedRepoRemoveSuite) TestRemoveRepo1and2(c *C) {
|
|||||||
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/dists/osminog"), PathExists)
|
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/dists/osminog"), PathExists)
|
||||||
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/pool/contrib"), PathExists)
|
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/pool/contrib"), PathExists)
|
||||||
|
|
||||||
err = s.collection.Remove(s.provider, "", "ppa", "anaconda", s.factory, nil, false)
|
err = s.collection.Remove(s.provider, "", "ppa", "anaconda", s.factory, nil, false, false)
|
||||||
c.Check(err, ErrorMatches, ".*not found")
|
c.Check(err, ErrorMatches, ".*not found")
|
||||||
|
|
||||||
err = s.collection.Remove(s.provider, "", "ppa", "meduza", s.factory, nil, false)
|
err = s.collection.Remove(s.provider, "", "ppa", "meduza", s.factory, nil, false, false)
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), Not(PathExists))
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/osminog"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/pool/main"), Not(PathExists))
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/pool/contrib"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "dists/anaconda"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "pool/main"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/dists/osminog"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/pool/contrib"), PathExists)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PublishedRepoRemoveSuite) TestRemoveRepo1and2SkipCleanup(c *C) {
|
||||||
|
err := s.collection.Remove(s.provider, "", "ppa", "anaconda", s.factory, nil, false, true)
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
|
_, err = s.collection.ByStoragePrefixDistribution("", "ppa", "anaconda")
|
||||||
|
c.Check(err, ErrorMatches, ".*not found")
|
||||||
|
|
||||||
|
collection := NewPublishedRepoCollection(s.db)
|
||||||
|
_, err = collection.ByStoragePrefixDistribution("", "ppa", "anaconda")
|
||||||
|
c.Check(err, ErrorMatches, ".*not found")
|
||||||
|
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/osminog"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/pool/main"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/pool/contrib"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "dists/anaconda"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "pool/main"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/dists/osminog"), PathExists)
|
||||||
|
c.Check(filepath.Join(s.publishedStorage2.PublicPath(), "ppa/pool/contrib"), PathExists)
|
||||||
|
|
||||||
|
err = s.collection.Remove(s.provider, "", "ppa", "anaconda", s.factory, nil, false, true)
|
||||||
|
c.Check(err, ErrorMatches, ".*not found")
|
||||||
|
|
||||||
|
err = s.collection.Remove(s.provider, "", "ppa", "meduza", s.factory, nil, false, true)
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||||
@@ -794,7 +832,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveRepo1and2(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *PublishedRepoRemoveSuite) TestRemoveRepo3(c *C) {
|
func (s *PublishedRepoRemoveSuite) TestRemoveRepo3(c *C) {
|
||||||
err := s.collection.Remove(s.provider, "", ".", "anaconda", s.factory, nil, false)
|
err := s.collection.Remove(s.provider, "", ".", "anaconda", s.factory, nil, false, false)
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
_, err = s.collection.ByStoragePrefixDistribution("", ".", "anaconda")
|
_, err = s.collection.ByStoragePrefixDistribution("", ".", "anaconda")
|
||||||
@@ -816,7 +854,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveRepo3(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *PublishedRepoRemoveSuite) TestRemoveRepo5(c *C) {
|
func (s *PublishedRepoRemoveSuite) TestRemoveRepo5(c *C) {
|
||||||
err := s.collection.Remove(s.provider, "files:other", "ppa", "osminog", s.factory, nil, false)
|
err := s.collection.Remove(s.provider, "files:other", "ppa", "osminog", s.factory, nil, false, false)
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
|
|
||||||
_, err = s.collection.ByStoragePrefixDistribution("files:other", "ppa", "osminog")
|
_, err = s.collection.ByStoragePrefixDistribution("files:other", "ppa", "osminog")
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+22
-12
@@ -2,6 +2,7 @@ package deb
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
gocontext "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -14,11 +15,11 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/http"
|
"github.com/aptly-dev/aptly/http"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/go-uuid/uuid"
|
"github.com/smira/go-uuid/uuid"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
@@ -112,6 +113,12 @@ func NewRemoteRepo(name string, archiveRoot string, distribution string, compone
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetArchiveRoot of remote repo
|
||||||
|
func (repo *RemoteRepo) SetArchiveRoot(archiveRoot string) {
|
||||||
|
repo.ArchiveRoot = archiveRoot
|
||||||
|
repo.prepare()
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *RemoteRepo) prepare() error {
|
func (repo *RemoteRepo) prepare() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -252,13 +259,13 @@ func (repo *RemoteRepo) Fetch(d aptly.Downloader, verifier pgp.Verifier) error {
|
|||||||
|
|
||||||
if verifier == nil {
|
if verifier == nil {
|
||||||
// 0. Just download release file to temporary URL
|
// 0. Just download release file to temporary URL
|
||||||
release, err = http.DownloadTemp(d, repo.ReleaseURL("Release").String())
|
release, err = http.DownloadTemp(gocontext.TODO(), d, repo.ReleaseURL("Release").String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 1. try InRelease file
|
// 1. try InRelease file
|
||||||
inrelease, err = http.DownloadTemp(d, repo.ReleaseURL("InRelease").String())
|
inrelease, err = http.DownloadTemp(gocontext.TODO(), d, repo.ReleaseURL("InRelease").String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
goto splitsignature
|
goto splitsignature
|
||||||
}
|
}
|
||||||
@@ -280,12 +287,12 @@ func (repo *RemoteRepo) Fetch(d aptly.Downloader, verifier pgp.Verifier) error {
|
|||||||
|
|
||||||
splitsignature:
|
splitsignature:
|
||||||
// 2. try Release + Release.gpg
|
// 2. try Release + Release.gpg
|
||||||
release, err = http.DownloadTemp(d, repo.ReleaseURL("Release").String())
|
release, err = http.DownloadTemp(gocontext.TODO(), d, repo.ReleaseURL("Release").String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
releasesig, err = http.DownloadTemp(d, repo.ReleaseURL("Release.gpg").String())
|
releasesig, err = http.DownloadTemp(gocontext.TODO(), d, repo.ReleaseURL("Release.gpg").String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -391,7 +398,10 @@ ok:
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(stanza, "SHA512")
|
err = parseSums("SHA512", func(sum *utils.ChecksumInfo, data string) { sum.SHA512 = data })
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
repo.Meta = stanza
|
repo.Meta = stanza
|
||||||
|
|
||||||
@@ -430,7 +440,7 @@ func (repo *RemoteRepo) DownloadPackageIndexes(progress aptly.Progress, d aptly.
|
|||||||
|
|
||||||
for _, info := range packagesPaths {
|
for _, info := range packagesPaths {
|
||||||
path, kind := info[0], info[1]
|
path, kind := info[0], info[1]
|
||||||
packagesReader, packagesFile, err := http.DownloadTryCompression(d, repo.IndexesRootURL(), path, repo.ReleaseFiles, ignoreMismatch, maxTries)
|
packagesReader, packagesFile, err := http.DownloadTryCompression(gocontext.TODO(), d, repo.IndexesRootURL(), path, repo.ReleaseFiles, ignoreMismatch, maxTries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -592,7 +602,7 @@ func (repo *RemoteRepo) Decode(input []byte) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") {
|
if strings.HasPrefix(err.Error(), "codec.decoder: readContainerLen: Unrecognized descriptor byte: hex: 80") {
|
||||||
// probably it is broken DB from go < 1.2, try decoding w/o time.Time
|
// probably it is broken DB from go < 1.2, try decoding w/o time.Time
|
||||||
var repo11 struct {
|
var repo11 struct { // nolint: maligned
|
||||||
UUID string
|
UUID string
|
||||||
Name string
|
Name string
|
||||||
ArchiveRoot string
|
ArchiveRoot string
|
||||||
|
|||||||
+7
-7
@@ -7,13 +7,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/smira/aptly/aptly"
|
"github.com/aptly-dev/aptly/aptly"
|
||||||
"github.com/smira/aptly/console"
|
"github.com/aptly-dev/aptly/console"
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/files"
|
"github.com/aptly-dev/aptly/files"
|
||||||
"github.com/smira/aptly/http"
|
"github.com/aptly-dev/aptly/http"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -10,8 +10,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
"github.com/smira/go-uuid/uuid"
|
"github.com/smira/go-uuid/uuid"
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/smira/aptly/database"
|
"github.com/aptly-dev/aptly/database"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/DisposaBoy/JsonConfigReader"
|
"github.com/DisposaBoy/JsonConfigReader"
|
||||||
"github.com/smira/aptly/pgp"
|
"github.com/aptly-dev/aptly/pgp"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/aptly-dev/aptly/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UploadersRule is single rule of format: what packages can group or key upload
|
// UploadersRule is single rule of format: what packages can group or key upload
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user