Skip to content

Commit

Permalink
Merge pull request #1386 from aptly-dev/fix/add-provided-package
Browse files Browse the repository at this point in the history
Fix/add provided package
  • Loading branch information
neolynx authored Nov 8, 2024
2 parents 7436454 + 9d05949 commit 6647f6d
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 91 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.deb filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
with:
# fetch the whole repo for `git describe` to work
fetch-depth: 0
lfs: true

- name: "Run flake8"
run: |
Expand Down
22 changes: 8 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,16 @@ following [PR template](.github/PULL_REQUEST_TEMPLATE.md).
Make sure that purpose of your change is clear, all the tests and checks pass, and all new code is covered with tests
if that is possible.

### Forking and Cloning
### Get the Source

As aptly is using Go modules, aptly repository could be cloned to any location on the file system:

git clone [email protected]:aptly-dev/aptly.git
cd aptly

For main repo under your GitHub user and add it as another Git remote:

git remote add <user> [email protected]:<user>/aptly.git

That way you can continue to build project as is (you don't need to adjust import paths), but you would need
to specify your remote name when pushing branches:

git push <user> <your-branch>
Make sure git with LFS support ist installed.

To clone the git repo, run the following commands:
```
git clone [email protected]:aptly-dev/aptly.git
cd aptly
git lfs checkout
```

## Development Setup

Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ test: prepare swagger etcd-install ## Run unit tests
system-test: prepare swagger etcd-install ## Run system tests
# build coverage binary
go test -v -coverpkg="./..." -c -tags testruncli
# Download fixture-db, fixture-pool, etcd.db
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
test -f ~/etcd.db || (curl -o ~/etcd.db.xz http://repo.aptly.info/system-tests/etcd.db.xz && xz -d ~/etcd.db.xz)
# Extract fixture-db, fixture-pool, etcd.db
test -e ~/aptly-fixture-db || tar -C ~/ -xf system/files/aptly-fixture.tar.xz
test -f ~/etcd.db || xz -dc system/files/etcd.db.xz > ~/etcd.db
# Run system tests
PATH=$(BINPATH)/:$(PATH) && FORCE_COLOR=1 $(PYTHON) system/run.py --long --coverage-dir $(COVERAGE_DIR) $(CAPTURE) $(TEST)

Expand All @@ -100,7 +99,7 @@ serve: prepare swagger-install ## Run development server (auto recompiling)
test -f $(BINPATH)/air || go install github.com/air-verse/[email protected]
cp debian/aptly.conf ~/.aptly.conf
sed -i /enableSwaggerEndpoint/s/false/true/ ~/.aptly.conf
PATH=$(BINPATH):$$PATH air -build.pre_cmd 'swag init -q --markdownFiles docs' -build.exclude_dir docs,system,debian,pgp/keyrings,pgp/test-bins,completion.d,man,deb/testdata,console,_man,cmd,systemd,obj-x86_64-linux-gnu -- api serve -listen 0.0.0.0:3142
PATH=$(BINPATH):$$PATH air -build.pre_cmd 'swag init -q --markdownFiles docs' -build.exclude_dir docs,system,debian,pgp/keyrings,pgp/test-bins,completion.d,man,deb/testdata,console,_man,systemd,obj-x86_64-linux-gnu -- api serve -listen 0.0.0.0:3142

dpkg: prepare swagger ## Build debian packages
@test -n "$(DEBARCH)" || (echo "please define DEBARCH"; exit 1)
Expand Down
29 changes: 19 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Current limitations:

* translations are not supported yet

Download
--------
Install Stable Version
-----------------------

To install aptly on Debian/Ubuntu, add new repository to ``/etc/apt/sources.list``::

Expand All @@ -58,19 +58,28 @@ After that you can install aptly as any other software package::
Don't worry about squeeze part in repo name: aptly package should work on Debian squeeze+,
Ubuntu 10.0+. Package contains aptly binary, man page and bash completion.

If you would like to use nightly builds (unstable), please use following repository::

deb http://repo.aptly.info/ nightly main
Other Binaries
~~~~~~~~~~~~~~~~~

Binary executables (depends almost only on libc) are available for download from `GitHub Releases <https://github.com/aptly-dev/aptly/releases>`_.

If you have Go environment set up, you can build aptly from source by running (go 1.14+ required)::
Install CI Version
--------------------

More recent versions are available as CI builds (development, might be unstable).

Debian GNU/Linux
~~~~~~~~~~~~~~~~~

Install the following APT key::

sudo wget -O /etc/apt/keyrings/aptly.asc https://www.aptly.info/pubkey.txt

Define CI APT sources in ``/etc/apt/sources.list.d/aptly-ci.list``::

git clone https://github.com/aptly-dev/aptly
cd aptly
make modules install
deb [signed-by=/etc/apt/keyrings/aptly.asc] http://repo.aptly.info/ci DIST main

Binary would be installed to ``$GOPATH/bin/aptly``.
Where DIST is one of: ``buster``, ``bullseye``, ``bookworm``, ``focal``, ``jammy``, ``noble``

Contributing
------------
Expand Down
2 changes: 1 addition & 1 deletion api/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func apiSnapshotsPull(c *gin.Context) {
// If we haven't seen such name-architecture pair and were instructed to remove, remove it
if !noRemove && !seen {
// Remove all packages with the same name and architecture
packageSearchResults := toPackageList.Search(deb.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name}, true)
packageSearchResults := toPackageList.Search(deb.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name}, true, false)
for _, p := range packageSearchResults {
toPackageList.Remove(p)
removedPackages = append(removedPackages, p.String())
Expand Down
2 changes: 1 addition & 1 deletion cmd/snapshot_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
// If we haven't seen such name-architecture pair and were instructed to remove, remove it
if !noRemove && !seen {
// Remove all packages with the same name and architecture
pS := packageList.Search(deb.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name}, true)
pS := packageList.Search(deb.Dependency{Architecture: pkg.Architecture, Pkg: pkg.Name}, true, false)
for _, p := range pS {
packageList.Remove(p)
context.Progress().ColoredPrintf("@r[-]@| %s removed", p)
Expand Down
2 changes: 1 addition & 1 deletion deb/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
}

if forceReplace {
conflictingPackages := list.Search(Dependency{Pkg: p.Name, Version: p.Version, Relation: VersionEqual, Architecture: p.Architecture}, true)
conflictingPackages := list.Search(Dependency{Pkg: p.Name, Version: p.Version, Relation: VersionEqual, Architecture: p.Architecture}, true, false)
for _, cp := range conflictingPackages {
reporter.Removed("%s removed due to conflict with package being added", cp)
list.Remove(cp)
Expand Down
35 changes: 19 additions & 16 deletions deb/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (l *PackageList) VerifyDependencies(options int, architectures []string, so
hash := dep.Hash()
satisfied, ok := cache[hash]
if !ok {
satisfied = sources.Search(dep, false) != nil
satisfied = sources.Search(dep, false, true) != nil
cache[hash] = satisfied
}

Expand Down Expand Up @@ -459,7 +459,7 @@ func (l *PackageList) SearchByKey(arch, name, version string) (result *PackageLi
}

// Search searches package index for specified package(s) using optimized queries
func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*Package) {
func (l *PackageList) Search(dep Dependency, allMatches bool, searchProvided bool) (searchResults []*Package) {
if !l.indexed {
panic("list not indexed, can't search")
}
Expand All @@ -479,18 +479,20 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*
i++
}

providers, ok := l.providesIndex[dep.Pkg]
if !ok {
return
}
for _, p := range providers {
if dep.Architecture == "" || p.MatchesArchitecture(dep.Architecture) {
if p.MatchesDependency(dep) {
searchResults = append(searchResults, p)
}
if searchProvided {
providers, ok := l.providesIndex[dep.Pkg]
if !ok {
return
}
for _, p := range providers {
if dep.Architecture == "" || p.MatchesArchitecture(dep.Architecture) {
if p.MatchesDependency(dep) {
searchResults = append(searchResults, p)
}

if !allMatches {
return
if !allMatches {
return
}
}
}
}
Expand Down Expand Up @@ -544,15 +546,16 @@ func (l *PackageList) FilterWithProgress(queries []PackageQuery, withDependencie
//
// 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 {
// FIXME: do not search twice
if result.Search(dep, false, true) != nil {
if dependencyOptions&DepVerboseResolve == DepVerboseResolve && progress != nil {
progress.ColoredPrintf("@{y}Already satisfied dependency@|: %s with %s", &dep, result.Search(dep, true))
progress.ColoredPrintf("@{y}Already satisfied dependency@|: %s with %s", &dep, result.Search(dep, true, true))
}
continue
}
}

searchResults := l.Search(dep, true)
searchResults := l.Search(dep, true, true)
if len(searchResults) > 0 {
for _, p := range searchResults {
if result.Has(p) {
Expand Down
Loading

0 comments on commit 6647f6d

Please sign in to comment.