diff mbox

[1/2] scripts/package/Makefile: make revision update a function

Message ID 20170816110855.6021-1-riku.voipio@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Riku Voipio Aug. 16, 2017, 11:08 a.m. UTC
From: Riku Voipio <riku.voipio@linaro.org>

The updated deb-pkg and bindeb-pkg will use the same snippet,
so make it reusable.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 scripts/package/Makefile | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Masahiro Yamada Sept. 7, 2017, 5:04 p.m. UTC | #1
Hi Riku,


2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> The updated deb-pkg and bindeb-pkg will use the same snippet,
> so make it reusable.
>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
> ---
>  scripts/package/Makefile | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 71b4a8af9d4d..9867638896ad 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>  rm -f $(2) $(objtree)/.scmversion
>
> +quiet_cmd_updateversion = UPDATEVERSION
> +      cmd_updateversion = \
> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
> +
>  # rpm-pkg
>  # ---------------------------------------------------------------------------
>  rpm-pkg rpm: FORCE
>         $(MAKE) clean
>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
> +       $(call cmd,updateversion)
>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>         rm $(KERNELPATH).tar.gz kernel.spec
>
> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>  binrpm-pkg: FORCE
>         $(MAKE) KBUILD_SRC=
>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
> -
> +       $(call cmd,updateversion)
>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>         rm binkernel.spec



scripts/mkversion is pretty small.
I think scripts/mkversion can also update .version

For example,




if [ ! -f .version ]
then
    version=1
else
    version=$(expr 0$(cat .version) + 1)
fi

echo $version > .version
echo $version




Then, remove the duplicated code from the Makefile.
Masahiro Yamada Sept. 8, 2017, 3:40 p.m. UTC | #2
2017-09-08 2:04 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> Hi Riku,
>
>
> 2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
>> From: Riku Voipio <riku.voipio@linaro.org>
>>
>> The updated deb-pkg and bindeb-pkg will use the same snippet,
>> so make it reusable.
>>
>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>> ---
>>  scripts/package/Makefile | 12 +++++++-----
>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>> index 71b4a8af9d4d..9867638896ad 100644
>> --- a/scripts/package/Makefile
>> +++ b/scripts/package/Makefile
>> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>>  rm -f $(2) $(objtree)/.scmversion
>>
>> +quiet_cmd_updateversion = UPDATEVERSION
>> +      cmd_updateversion = \
>> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
>> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
>> +
>>  # rpm-pkg
>>  # ---------------------------------------------------------------------------
>>  rpm-pkg rpm: FORCE
>>         $(MAKE) clean
>>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>> +       $(call cmd,updateversion)
>>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>>         rm $(KERNELPATH).tar.gz kernel.spec
>>
>> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>>  binrpm-pkg: FORCE
>>         $(MAKE) KBUILD_SRC=
>>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>> -
>> +       $(call cmd,updateversion)
>>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>>         rm binkernel.spec
>
>
>
> scripts/mkversion is pretty small.
> I think scripts/mkversion can also update .version
>
> For example,
>
>
>
>
> if [ ! -f .version ]
> then
>     version=1
> else
>     version=$(expr 0$(cat .version) + 1)
> fi
>
> echo $version > .version
> echo $version
>
>
>
>
> Then, remove the duplicated code from the Makefile.



Sorry, please let me think about this carefully.

We have simliar code in
scripts/link-vmlinux.sh and scripts/mkversion
Riku Voipio Sept. 11, 2017, 10:48 a.m. UTC | #3
On 8 September 2017 at 18:40, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 2017-09-08 2:04 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
>> Hi Riku,
>>
>>
>> 2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
>>> From: Riku Voipio <riku.voipio@linaro.org>
>>>
>>> The updated deb-pkg and bindeb-pkg will use the same snippet,
>>> so make it reusable.
>>>
>>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>>> ---
>>>  scripts/package/Makefile | 12 +++++++-----
>>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>>> index 71b4a8af9d4d..9867638896ad 100644
>>> --- a/scripts/package/Makefile
>>> +++ b/scripts/package/Makefile
>>> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>>>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>>>  rm -f $(2) $(objtree)/.scmversion
>>>
>>> +quiet_cmd_updateversion = UPDATEVERSION
>>> +      cmd_updateversion = \
>>> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
>>> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>> +
>>>  # rpm-pkg
>>>  # ---------------------------------------------------------------------------
>>>  rpm-pkg rpm: FORCE
>>>         $(MAKE) clean
>>>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>>>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>> +       $(call cmd,updateversion)
>>>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>>>         rm $(KERNELPATH).tar.gz kernel.spec
>>>
>>> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>>>  binrpm-pkg: FORCE
>>>         $(MAKE) KBUILD_SRC=
>>>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>> -
>>> +       $(call cmd,updateversion)
>>>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>>>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>>>         rm binkernel.spec
>>
>>
>>
>> scripts/mkversion is pretty small.
>> I think scripts/mkversion can also update .version
>>
>> For example,
>>
>>
>>
>>
>> if [ ! -f .version ]
>> then
>>     version=1
>> else
>>     version=$(expr 0$(cat .version) + 1)
>> fi
>>
>> echo $version > .version
>> echo $version
>>
>>
>>
>>
>> Then, remove the duplicated code from the Makefile.
>
>
>
> Sorry, please let me think about this carefully.
>
> We have simliar code in
> scripts/link-vmlinux.sh and scripts/mkversion

Oh. Looking deeper, running "make binrpm" twice in a row incrediments
the .version with two. I think we can leave updating version to
link-mklinux and drop updating .version from
scripts/packaging/Makefile. The actual use of mkversion is then to
predict the next version, and we can stop using .version directly in
builddeb since the build will outdate it.

Riku
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada Sept. 14, 2017, 11:23 a.m. UTC | #4
2017-09-11 19:48 GMT+09:00 Riku Voipio <riku.voipio@linaro.org>:
> On 8 September 2017 at 18:40, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> 2017-09-08 2:04 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
>>> Hi Riku,
>>>
>>>
>>> 2017-08-16 20:08 GMT+09:00  <riku.voipio@linaro.org>:
>>>> From: Riku Voipio <riku.voipio@linaro.org>
>>>>
>>>> The updated deb-pkg and bindeb-pkg will use the same snippet,
>>>> so make it reusable.
>>>>
>>>> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
>>>> ---
>>>>  scripts/package/Makefile | 12 +++++++-----
>>>>  1 file changed, 7 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
>>>> index 71b4a8af9d4d..9867638896ad 100644
>>>> --- a/scripts/package/Makefile
>>>> +++ b/scripts/package/Makefile
>>>> @@ -44,14 +44,18 @@ tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
>>>>         $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
>>>>  rm -f $(2) $(objtree)/.scmversion
>>>>
>>>> +quiet_cmd_updateversion = UPDATEVERSION
>>>> +      cmd_updateversion = \
>>>> +       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
>>>> +       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>>> +
>>>>  # rpm-pkg
>>>>  # ---------------------------------------------------------------------------
>>>>  rpm-pkg rpm: FORCE
>>>>         $(MAKE) clean
>>>>         $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
>>>>         $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
>>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>>> +       $(call cmd,updateversion)
>>>>         rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
>>>>         rm $(KERNELPATH).tar.gz kernel.spec
>>>>
>>>> @@ -60,9 +64,7 @@ rpm-pkg rpm: FORCE
>>>>  binrpm-pkg: FORCE
>>>>         $(MAKE) KBUILD_SRC=
>>>>         $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
>>>> -       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
>>>> -       mv -f $(objtree)/.tmp_version $(objtree)/.version
>>>> -
>>>> +       $(call cmd,updateversion)
>>>>         rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
>>>>                 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
>>>>         rm binkernel.spec
>>>
>>>
>>>
>>> scripts/mkversion is pretty small.
>>> I think scripts/mkversion can also update .version
>>>
>>> For example,
>>>
>>>
>>>
>>>
>>> if [ ! -f .version ]
>>> then
>>>     version=1
>>> else
>>>     version=$(expr 0$(cat .version) + 1)
>>> fi
>>>
>>> echo $version > .version
>>> echo $version
>>>
>>>
>>>
>>>
>>> Then, remove the duplicated code from the Makefile.
>>
>>
>>
>> Sorry, please let me think about this carefully.
>>
>> We have simliar code in
>> scripts/link-vmlinux.sh and scripts/mkversion
>
> Oh. Looking deeper, running "make binrpm" twice in a row incrediments
> the .version with two. I think we can leave updating version to
> link-mklinux and drop updating .version from
> scripts/packaging/Makefile. The actual use of mkversion is then to
> predict the next version, and we can stop using .version directly in
> builddeb since the build will outdate it.
>

Even worse, the spec file claims a different number from
the one embedded in the kernel image
(for both rpm-pkg and binrpm-pkg).

I sent a patch.  Seems working as far as I tested.
diff mbox

Patch

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 71b4a8af9d4d..9867638896ad 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -44,14 +44,18 @@  tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
 	$(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
 rm -f $(2) $(objtree)/.scmversion
 
+quiet_cmd_updateversion = UPDATEVERSION
+      cmd_updateversion = \
+	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version; \
+	mv -f $(objtree)/.tmp_version $(objtree)/.version
+
 # rpm-pkg
 # ---------------------------------------------------------------------------
 rpm-pkg rpm: FORCE
 	$(MAKE) clean
 	$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
 	$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
-	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
-	mv -f $(objtree)/.tmp_version $(objtree)/.version
+	$(call cmd,updateversion)
 	rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
 	rm $(KERNELPATH).tar.gz kernel.spec
 
@@ -60,9 +64,7 @@  rpm-pkg rpm: FORCE
 binrpm-pkg: FORCE
 	$(MAKE) KBUILD_SRC=
 	$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
-	$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
-	mv -f $(objtree)/.tmp_version $(objtree)/.version
-
+	$(call cmd,updateversion)
 	rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
 		$(UTS_MACHINE) -bb $(objtree)/binkernel.spec
 	rm binkernel.spec