On Tue, May 5, 2020 at 4:13 PM Chris Johns <[email protected]> wrote:
>
>
> On 5 May 2020, at 5:37 pm, Vijay Kumar Banerjee <[email protected]> wrote:
>
>
>
>
> On Tue, May 5, 2020 at 9:56 AM Chris Johns <[email protected]> wrote:
>>
>> On 4/5/20 8:16 pm, Vijay Kumar Banerjee wrote:
>> >
>> >
>> > On Mon, May 4, 2020 at 4:39 AM Chris Johns <[email protected]
>> > <mailto:[email protected]>> wrote:
>> >
>> > Hi
>> >
>> > Are uninstall command useful with RTEMS? A use case that shows how it
>> > would be used may help.
>> >
>> > The use case in mind was libbsd. The uninstall command comes handy in
>> > cleaning off the files that were installed, and there's no need to delete
>> > it
>> > manually. I remember having some issues with libbsd while taking a trial
>> > and error approach in searching for the right sources, the residue of the
>> > old build would often cause problems and I had to delete them manually.
>>
>> I understand. I see this as a development issue and not something a user
>> would typically do. A release can have the pieces in a vertically
>> software stack built on top of each other, i.e. a single prefix. For
>> development where you can have specific pieces that are moving relative
>> to each other I recommend separate sandboxing. The user manual details
>> this. Prefix based sandboxing lets you remove a specific prefix without
>> needing to rebuild the whole stack.
>>
>> > I use separate prefixes to manage this. We do not track common files
>> > when installing to a common prefix so building ARM and then PowerPC to
>> > the same prefix then uninstalling only the PowerPC build would remove
>> > files needed by ARM.
>> >
>> > waf only removes the files that have been installed with install_files. If
>> > I
>> > run ./waf uninstall from libbsd, only the files under
>> > arm-rtems5/beagleboneblack/lib
>> > are getting affected.
>>
>> That must be the default uninstall for waf. We should decide to move one
>> way or the other, that is remove the uninstall because it is broken or
>> we fix it, i.e. your patch?
>>
>> I hesitate adding something that is not manually tested often and so not
>> kept up to date. Would a unit test be a solution? Something that
>> collects a hash based stamp for all the files under a prefix, performs
>> the install and the uninstall steps and then verifies the prefix tree is
>> exactly the same?
>>
> The uninstall function is currently broken but it would be nice to have.
>
>
> Sure that is fine with me.
>
> The unit-test approach sounds great and will make sure that it doesn't
> break anything. Is this an issue for the release if the uninstall is broken?
>
>
> I suggest doing the patch for master and we can review it for 5.2.
>
> Is there any example of some unit-test added like this?
>
>
> Not that I know of. If it is a single module maybe it can used in all our waf
> repos.
>
Hi Chris,
I added support in rtems_waf to test the uninstall function, following
the approach that you suggested. I'm attaching the patch here, please
have a look.
I am using it in libbsd by calling it from wscript like this:
```
diff --git a/wscript b/wscript
index 0979644a..74fc1f48 100644
--- a/wscript
+++ b/wscript
@@ -226,6 +226,9 @@ def configure(conf):
update_builders(conf, conf.env.BUILDSET)
rtems.configure(conf, bsp_configure)
+def test(bld):
+ rtems.test_uninstall(bld)
+
def build(bld):
rtems.build(bld)
builders[bld.libbsd_buildset_name].build(bld)
```
If this approach looks alright to you, I'll send a v2 of the patchset
for libbsd and rtems_waf for review.
Thanks,
Vijay
>
> Chris
From b78d5a654593b961e8964be2115333da326fe4ed Mon Sep 17 00:00:00 2001
From: Vijay Kumar Banerjee <[email protected]>
Date: Fri, 8 May 2020 00:11:38 +0530
Subject: [PATCH rtems_waf] rtems: Add function to test waf uninstall
---
rtems.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/rtems.py b/rtems.py
index 067a213..ab6d03b 100644
--- a/rtems.py
+++ b/rtems.py
@@ -303,6 +303,46 @@ def build(bld):
if bld.env.LONG_COMMANDS == 'yes':
long_command_line()
+def get_dir_hash(bld):
+ from waflib import ConfigSet, Options
+ import hashlib
+
+ env = ConfigSet.ConfigSet()
+ env.load(Options.lockfile)
+ prefix = env.options['prefix']
+ shahash = hashlib.sha1()
+
+ for root, dirs, files in os.walk(prefix):
+ for names in files:
+ filepath = os.path.join(root, names)
+ try:
+ f1 = open(filepath, 'rb')
+ except:
+ f1.close()
+ continue
+
+ while 1:
+ buf = f1.read(4096)
+ if not buf:
+ break
+ shahash.update(hashlib.sha1(buf).hexdigest())
+ f1.close()
+ return shahash.hexdigest()
+
+def test_uninstall(bld):
+ print('TESTING WAF UNINSTALL\n')
+ print('CALCULATING HASH BEFORE INSTALL')
+ initial_hash = get_dir_hash(bld)
+ subprocess.call(['./waf', 'install'])
+ subprocess.call(['./waf', 'uninstall'])
+ print('CALCULATING HASH AFTER UNINSTALL')
+ final_hash = get_dir_hash(bld)
+
+ if (initial_hash == final_hash):
+ print("TEST PASSED")
+ else:
+ print("TEST FAILED")
+
def load_cpuopts(conf):
options = ['RTEMS_DEBUG',
'RTEMS_MULTIPROCESSING',
--
2.21.1
_______________________________________________
devel mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/devel