diff mbox series

UBUNTU: [Packaging] Do not allow update-version-dkms to be run on a derivative kernel

Message ID 20210304161638.22111-2-tim.gardner@canonical.com
State New
Headers show
Series UBUNTU: [Packaging] Do not allow update-version-dkms to be run on a derivative kernel | expand

Commit Message

Tim Gardner March 4, 2021, 4:16 p.m. UTC
It is too easy to run this script when drifting through the cranky cheat sheet
without really thinking about what you're doing while cranking a derivative
kernel.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---

v2 - use debian.DERIVATIVE/etc/update.conf to determine if this is a master
     dependent derivative.

 update-version-dkms | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Thadeu Lima de Souza Cascardo March 4, 2021, 4:21 p.m. UTC | #1
On Thu, Mar 04, 2021 at 09:16:38AM -0700, Tim Gardner wrote:
> It is too easy to run this script when drifting through the cranky cheat sheet
> without really thinking about what you're doing while cranking a derivative
> kernel.
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
> 
> v2 - use debian.DERIVATIVE/etc/update.conf to determine if this is a master
>      dependent derivative.
> 
>  update-version-dkms | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/update-version-dkms b/update-version-dkms
> index d90ce2c85f65..70158d3c6127 100755
> --- a/update-version-dkms
> +++ b/update-version-dkms
> @@ -19,6 +19,17 @@ esac
>  # find our changelog.
>  debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
>  
> +# Make sure this isn't a derivative kernel
> +uconf=$debian/etc/update.conf
> +if [ -f $uconf ]
> +then
> +	if egrep -q "DEBIAN_MASTER=debian\.master" $uconf
> +	then

We have derivatives of derivatives, like xenial/linux-azure, which has
debian.azure-4.15 as DEBIAN_MASTER.

Cascardo.

> +		echo "Do not run this script on a derivative kernel."
> +		exit 1
> +	fi
> +fi
> +
>  # identify the current series
>  series=$(dpkg-parsechangelog -l"$debian/changelog" -SDistribution)
>  if [ "$series" = "UNRELEASED" ]; then
> -- 
> 2.17.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Tim Gardner March 4, 2021, 5:44 p.m. UTC | #2
On 3/4/21 9:21 AM, Thadeu Lima de Souza Cascardo wrote:
> On Thu, Mar 04, 2021 at 09:16:38AM -0700, Tim Gardner wrote:
>> It is too easy to run this script when drifting through the cranky cheat sheet
>> without really thinking about what you're doing while cranking a derivative
>> kernel.
>>
>> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
>> ---
>>
>> v2 - use debian.DERIVATIVE/etc/update.conf to determine if this is a master
>>       dependent derivative.
>>
>>   update-version-dkms | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/update-version-dkms b/update-version-dkms
>> index d90ce2c85f65..70158d3c6127 100755
>> --- a/update-version-dkms
>> +++ b/update-version-dkms
>> @@ -19,6 +19,17 @@ esac
>>   # find our changelog.
>>   debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
>>   
>> +# Make sure this isn't a derivative kernel
>> +uconf=$debian/etc/update.conf
>> +if [ -f $uconf ]
>> +then
>> +	if egrep -q "DEBIAN_MASTER=debian\.master" $uconf
>> +	then
> 
> We have derivatives of derivatives, like xenial/linux-azure, which has
> debian.azure-4.15 as DEBIAN_MASTER.
> 

Is it sufficient to just check if DEBIAN_MASTER exists in 
$debian/etc/update.conf ?

rtg
-----------
Tim Gardner
Canonical, Inc
Thadeu Lima de Souza Cascardo March 4, 2021, 6:29 p.m. UTC | #3
On Thu, Mar 04, 2021 at 10:44:50AM -0700, Tim Gardner wrote:
> 
> 
> On 3/4/21 9:21 AM, Thadeu Lima de Souza Cascardo wrote:
> > On Thu, Mar 04, 2021 at 09:16:38AM -0700, Tim Gardner wrote:
> > > It is too easy to run this script when drifting through the cranky cheat sheet
> > > without really thinking about what you're doing while cranking a derivative
> > > kernel.
> > > 
> > > Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> > > ---
> > > 
> > > v2 - use debian.DERIVATIVE/etc/update.conf to determine if this is a master
> > >       dependent derivative.
> > > 
> > >   update-version-dkms | 11 +++++++++++
> > >   1 file changed, 11 insertions(+)
> > > 
> > > diff --git a/update-version-dkms b/update-version-dkms
> > > index d90ce2c85f65..70158d3c6127 100755
> > > --- a/update-version-dkms
> > > +++ b/update-version-dkms
> > > @@ -19,6 +19,17 @@ esac
> > >   # find our changelog.
> > >   debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
> > > +# Make sure this isn't a derivative kernel
> > > +uconf=$debian/etc/update.conf
> > > +if [ -f $uconf ]
> > > +then
> > > +	if egrep -q "DEBIAN_MASTER=debian\.master" $uconf
> > > +	then
> > 
> > We have derivatives of derivatives, like xenial/linux-azure, which has
> > debian.azure-4.15 as DEBIAN_MASTER.
> > 
> 
> Is it sufficient to just check if DEBIAN_MASTER exists in
> $debian/etc/update.conf ?
> 

The generation of DEBIAN_MASTER is one of the most controversial so far. The
right thing to do was to fetch the derived_from kernel and look up at its
debian/debian.env. But that was deemed too expensive.

I forgot the details about any reasons for keeping an update.conf for non
derived kernels. I just know there are some outliers we don't care to fix. Some
of the 5.0 or 5.3 kernels come to mind.

Right now, for kernels that are not derived from anything, we don't create an
update.conf (see kteam-tools/cranky/fixes.d/generate-update-conf). So, just
checking for the file presence should be enough. It's just that there may be
some corner cases where we might want to still generate it, but I just don't
recall the specifics.

So, there would still be a chance that this will break for a given kernel. But
we can fix it up when we find out. But checking for DEBIAN_MASTER=debian.master
was sure to break some.

Cascardo.

> rtg
> -----------
> Tim Gardner
> Canonical, Inc
diff mbox series

Patch

diff --git a/update-version-dkms b/update-version-dkms
index d90ce2c85f65..70158d3c6127 100755
--- a/update-version-dkms
+++ b/update-version-dkms
@@ -19,6 +19,17 @@  esac
 # find our changelog.
 debian=$(awk -F= '($1 == "DEBIAN") { print $2 }' <debian/debian.env)
 
+# Make sure this isn't a derivative kernel
+uconf=$debian/etc/update.conf
+if [ -f $uconf ]
+then
+	if egrep -q "DEBIAN_MASTER=debian\.master" $uconf
+	then
+		echo "Do not run this script on a derivative kernel."
+		exit 1
+	fi
+fi
+
 # identify the current series
 series=$(dpkg-parsechangelog -l"$debian/changelog" -SDistribution)
 if [ "$series" = "UNRELEASED" ]; then