For discussion of Alpine Linux development and developer support

4 2

[alpine-devel] [PATCH] list: Detect orphaned packages correctly

A. Wilcox
Details
Message ID
<20190321234232.33363-1-AWilcox@Wilcox-Tech.com>
Sender timestamp
1553211752
DKIM signature
missing
Download raw message
Patch: +2 -2
BIT(1) corresponds with decimal 2, which is the first available repository.
BIT(0) corresponds with decimal 1, which is the installed repository.

Before this fix, `apk list -O` would list every package installed from the
first available repository, which is the 'system' repository on most Adélie
Linux computers.

After this fix, `apk list -O` correctly lists only the packages which are
no longer available.
---
 src/list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/list.c b/src/list.c
index e285e3f..dcbaeea 100644
--- a/src/list.c
+++ b/src/list.c
@@ -61,7 +61,7 @@ static int is_orphaned(const struct apk_name *name)
 	/* repo 1 is always installed-db, so if other bits are set it means the package is available somewhere
 	 * (either cache or in a proper repo)
 	 */
-	return (repos & ~BIT(1)) == 0;
+	return (repos & ~BIT(0)) == 0;
 }
 
 /* returns the currently installed package if there is a newer package that satisfies `name` */
@@ -144,7 +144,7 @@ static void filter_package(const struct apk_package *pkg, const struct list_ctx
 	if (ctx->orphaned && !is_orphaned(pkg->name))
 		return;
 
-	if (ctx->available && pkg->repos == BIT(1))
+	if (ctx->available && pkg->repos == BIT(0))
 		return;
 
 	if (ctx->upgradable && !is_upgradable(pkg->name, pkg))
-- 
2.21.0



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Timo Teras
Details
Message ID
<20190323172952.43760ffa@vostro>
In-Reply-To
<20190321234232.33363-1-AWilcox@Wilcox-Tech.com> (view parent)
Sender timestamp
1553354992
DKIM signature
missing
Download raw message
Hi,

Seems this is a bug in the relatively new 'list' applet. Rest of the
code uses:
	repos == BIT(APK_REPOSITORY_CACHED)

maybe also use this syntax consistently in both locations.

Care to update the patch with this?

Thanks,
Timo

On Thu, 21 Mar 2019 18:42:32 -0500
"A. Wilcox" <AWilcox@Wilcox-Tech.com> wrote:

> BIT(1) corresponds with decimal 2, which is the first available
> repository. BIT(0) corresponds with decimal 1, which is the installed
> repository.
> 
> Before this fix, `apk list -O` would list every package installed
> from the first available repository, which is the 'system' repository
> on most Adélie Linux computers.
> 
> After this fix, `apk list -O` correctly lists only the packages which
> are no longer available.
> ---
>  src/list.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/list.c b/src/list.c
> index e285e3f..dcbaeea 100644
> --- a/src/list.c
> +++ b/src/list.c
> @@ -61,7 +61,7 @@ static int is_orphaned(const struct apk_name *name)
>  	/* repo 1 is always installed-db, so if other bits are set
> it means the package is available somewhere
>  	 * (either cache or in a proper repo)
>  	 */
> -	return (repos & ~BIT(1)) == 0;
> +	return (repos & ~BIT(0)) == 0;
>  }
>  
>  /* returns the currently installed package if there is a newer
> package that satisfies `name` */ @@ -144,7 +144,7 @@ static void
> filter_package(const struct apk_package *pkg, const struct list_ctx
> if (ctx->orphaned && !is_orphaned(pkg->name)) return;
>  
> -	if (ctx->available && pkg->repos == BIT(1))
> +	if (ctx->available && pkg->repos == BIT(0))
>  		return;
>  
>  	if (ctx->upgradable && !is_upgradable(pkg->name, pkg))



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---

[alpine-devel] [PATCH v2] list: Detect orphaned packages correctly

A. Wilcox
Details
Message ID
<20190501135615.33377-1-AWilcox@Wilcox-Tech.com>
In-Reply-To
<20190323172952.43760ffa@vostro> (view parent)
Sender timestamp
1556718975
DKIM signature
missing
Download raw message
Patch: +2 -2
BIT(1) corresponds with decimal 2, which is the first available repository.
BIT(0) corresponds with decimal 1, which is the installed repository.

Before this fix, `apk list -O` would list every package installed from the
first available repository, which is the 'system' repository on most Adélie
Linux computers.

After this fix, `apk list -O` correctly lists only the packages which are
no longer available.
---
 src/list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/list.c b/src/list.c
index e285e3f..dcbaeea 100644
--- a/src/list.c
+++ b/src/list.c
@@ -61,7 +61,7 @@ static int is_orphaned(const struct apk_name *name)
 	/* repo 1 is always installed-db, so if other bits are set it means the package is available somewhere
 	 * (either cache or in a proper repo)
 	 */
-	return (repos & ~BIT(1)) == 0;
+	return (repos & ~BIT(0)) == 0;
 }
 
 /* returns the currently installed package if there is a newer package that satisfies `name` */
@@ -144,7 +144,7 @@ static void filter_package(const struct apk_package *pkg, const struct list_ctx
 	if (ctx->orphaned && !is_orphaned(pkg->name))
 		return;
 
-	if (ctx->available && pkg->repos == BIT(1))
+	if (ctx->available && pkg->repos == BIT(0))
 		return;
 
 	if (ctx->upgradable && !is_upgradable(pkg->name, pkg))
-- 
2.21.0



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---

[alpine-devel] [PATCH v3] list: Detect orphaned packages correctly

A. Wilcox
Details
Message ID
<20190501135916.33879-1-AWilcox@Wilcox-Tech.com>
In-Reply-To
<20190323172952.43760ffa@vostro> (view parent)
Sender timestamp
1556719156
DKIM signature
missing
Download raw message
Patch: +2 -2
BIT(1) corresponds with decimal 2, which is the first available repository.

Before this fix, `apk list -O` would list every package installed from the
first available repository, which is the 'system' repository on most Adélie
Linux computers.

After this fix, `apk list -O` correctly lists only the packages which are
no longer available.
---
 src/list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/list.c b/src/list.c
index e285e3f..202dab2 100644
--- a/src/list.c
+++ b/src/list.c
@@ -61,7 +61,7 @@ static int is_orphaned(const struct apk_name *name)
 	/* repo 1 is always installed-db, so if other bits are set it means the package is available somewhere
 	 * (either cache or in a proper repo)
 	 */
-	return (repos & ~BIT(1)) == 0;
+	return (repos & ~BIT(APK_REPOSITORY_CACHED)) == 0;
 }
 
 /* returns the currently installed package if there is a newer package that satisfies `name` */
@@ -144,7 +144,7 @@ static void filter_package(const struct apk_package *pkg, const struct list_ctx
 	if (ctx->orphaned && !is_orphaned(pkg->name))
 		return;
 
-	if (ctx->available && pkg->repos == BIT(1))
+	if (ctx->available && pkg->repos == BIT(APK_REPOSITORY_CACHED))
 		return;
 
 	if (ctx->upgradable && !is_upgradable(pkg->name, pkg))
-- 
2.21.0



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---

Re: [alpine-devel] [PATCH v3] list: Detect orphaned packages correctly

Timo Teras
Details
Message ID
<20190501185723.7fb230dd@vostro>
In-Reply-To
<20190501135916.33879-1-AWilcox@Wilcox-Tech.com> (view parent)
Sender timestamp
1556726243
DKIM signature
missing
Download raw message
Hi,

Applied. Thanks!

On Wed,  1 May 2019 08:59:16 -0500
"A. Wilcox" <AWilcox@Wilcox-Tech.com> wrote:

> BIT(1) corresponds with decimal 2, which is the first available
> repository.
> 
> Before this fix, `apk list -O` would list every package installed
> from the first available repository, which is the 'system' repository
> on most Adélie Linux computers.
> 
> After this fix, `apk list -O` correctly lists only the packages which
> are no longer available.
> ---
>  src/list.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/list.c b/src/list.c
> index e285e3f..202dab2 100644
> --- a/src/list.c
> +++ b/src/list.c
> @@ -61,7 +61,7 @@ static int is_orphaned(const struct apk_name *name)
>  	/* repo 1 is always installed-db, so if other bits are set
> it means the package is available somewhere
>  	 * (either cache or in a proper repo)
>  	 */
> -	return (repos & ~BIT(1)) == 0;
> +	return (repos & ~BIT(APK_REPOSITORY_CACHED)) == 0;
>  }
>  
>  /* returns the currently installed package if there is a newer
> package that satisfies `name` */ @@ -144,7 +144,7 @@ static void
> filter_package(const struct apk_package *pkg, const struct list_ctx
> if (ctx->orphaned && !is_orphaned(pkg->name)) return;
>  
> -	if (ctx->available && pkg->repos == BIT(1))
> +	if (ctx->available && pkg->repos ==
> BIT(APK_REPOSITORY_CACHED)) return;
>  
>  	if (ctx->upgradable && !is_upgradable(pkg->name, pkg))



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---