Reproducible builds folks: Managing container and environment state
Author: ceridwen
With some more help from Martin Pitt, it became clear to me that my
previous mental model of how autopkgtest worked is very different from
how it does work. I'll illustrate by borrowing my previous
example.
I know that schroot has the following behavior:
The default behaviour is as follows (all directory paths are inside the chroot). A login shell is run in the current working directory. If this is not available, it will try $HOME (when --preserve-environment is used), then the user's home directory, and / inside the chroot in turn. A command is always run in the current working directory inside the chroot. If none of the directories are available, schroot will exit with an error status.I was naively thinking that the way autopkgtest would work is that it would set the current working directory of the schroot call and the ensuing
subprocess call would thus take place in that directory
inside the schroot. That is not how it works. If you want to
change directories inside the virtual server, you have to use cd.
The same is true of, at least, environment variables, which have their
own specific handling in the adt_testbed.Testbed methods but have to
be passed as strings, and umask. I'm assuming this is because the
direct methods with qemu images or LXC containers don't work.
What this means is that I was thinking about the problem the wrong
way: what reprotest needs to do is generate shell scripts. This is
how autopkgtest
works.
If this goes beyond laying out commands linearly one after another,
for instance if it demands conditionals or other nested constructs,
the right way to do it is to build an abstract syntax tree
representation of the shell script and then convert it to code.
Whether I need more complicated shell scripts depends on my approach
to handling state in the containers. I need to know what state
persists across separate command executions: if I call
adt_testbed.Testbed.execute() twice, what if any changes I make to
the container will carry forward from the first to the second? There
are three categories here. First, some properties of a system aren't
preserved even from one command execution to the next, like working
directory and environment variables. (I thought working directory
would be preserved, but it's not). The second is state that persists
while the testbed is open and is then automatically reverted when it's
closed, like files copied into temporary directories on the tesbed.
The third is state that persists across different sessions on the same
container and must be cleaned up by reprotest. It's worth noting that
which state falls into which category may vary by the container in
question, though for the most part I can either do unnecessary cleanup
or issue unnecessary commands to handle the differences. autopkgtest
itself has a very different approach to cleanup, as it relies almost
entirely on the builtin reversion capabilities from some of its
containers. I would prefer to avoid doing the same, partly because I
know that some of the modifications I need to make, for instance
creating new users or mounting disorderfs, can't be reverted by the
faster, simpler containers like schroot.
From discussions with Lunar, I think
that the variations that correspond to environment variables
(captures_environment, home, locales, path, and timezone)
fall into the first category, but because of the special handling for
them they don't require sending a separate command. The shell (bash
foo) accepts a script or command as an argument so it also doesn't
need a separate command. Setting the working directory and umask
require separate commands that have to be joined. On Linux, setarch
also accepts a command/script as an argument so can be handled like
the shell, but there's no unified POSIX protocol for mocking uname
so other OSes will require different approaches. Users, groups, file
ordering, host, and domain will require cleanup in all containers
except for (maybe) qemu. If I want to handle the cleanup in the shell
scripts themselves, I need conditionals so that for instance the shell
script only tries to unmount disorderfs if disorderfs was successfully
mounted. This approach would simplify the error handling problems
I've had before, where when a build crashes cleanup code run from
Python doesn't get run until after the testbed stop accepting
commands.
Lunar suggested the Plumbum library
to me, and I think I can use it to avoid writing my own shell AST
library. It has a
method
that converts the Python representation of a shell script into a string that can be passed to Testbed.command(). Integrating Plumbum to generate the necessary scripts is where I'm going in the next week.
Any feedback on any of this is welcome. I'm also curious what other
projects are using autopkgtest code. Holger
brought to my attention
piuparts,
which brings the list up to four that I'm aware of, autopkgtest
itself, sbuild, piuparts, and now reprotest.
I've spent the past days updating several of my websites to be "responsive". Mostly that means I open the site in firefox then press
The best known smart bulb setups (such as the Philips Hue and the Belkin Wemo) are based on Zigbee, a low-energy, low-bandwidth protocol that operates on various unlicensed radio bands. The problem with Zigbee is that basically no home routers or mobile devices have a Zigbee radio, so to communicate with them you need an additional device (usually called a hub or bridge) that can speak Zigbee and also hook up to your existing home network. Requests are sent to the hub (either directly if you're on the same network, or via some external control server if you're on a different network) and it sends appropriate Zigbee commands to the bulbs.
Several years ago I've
Over the past year I ve been refining my understanding of the core
claims of Kantian ethics. I ve realised that I have deeply Kantian
intuitions about a lot of issues, and I understand these intuitions
better now that I can put them in Kantian terms. Consider two
exercises of state power: riot police suppressing protesters by
non-lethal means, and soldiers shooting protesters to death. I feel
more uncomfortable thinking about the first: there s something
altogether more sinister about it than the second, even though the
second is much more sad.
I think that the reason is that non-lethal weaponry is designed to
take away people s agency, and it often achieves this aim by means of
emotional manipulation. Riot police use so-called baton charges to
incite fearful retreat. Protesters have reasoned that in their
political situation, they have a duty to resist the incumbent
government. Riot police seek to unseat this conviction and cause fear
to determine what the protesters will do. In Kantian terms, the
riot police fail to respect the moral agency of the protesters by
seeking to unseat the moral personality s determination of what the
protester will do.
A controversial example that Kant uses to make this point is the axe
murderer case. Kant asks us to imagine that someone bangs on our
front door and begs us to hide him in our house, because someone who
wishes to kill him is coming up behind them. We do so. When the axe
murderer arrives, he goes door-to-door and asks us whether the
intended victim is in each house. Kant says that it is morally wrong
to lie to the axe murderer and say that the victim is not in your
house. How could this be? Surely there is a moral duty to protect
the victim from being killed? Indeed there is, but when it comes into
conflict with the duty not to lie, that second duty wins out. That s
because respecting the moral agency of individuals is paramount. In
this case, we would fail to respect the murderer s agency if we didn t
allow him to take the decision to murder or not murder the victim; by
lying to him we (disrespectfully) bypass his choice as to whether to
do it.
It s obviously crazy to say that we are morally required to give up
the victim. Kant gives the wrong answer in this case. However, the
case definitely reveals a requirement to respect other people s view
of what they should do, and give them a chance to do it. Similarly it
seems like we shouldn t give semi-automatics to our riot police, but
there s something wrong with a lot of what they do.
During the recent campaigns about Britain s EU referendum, some
criticised Jeremy Corbyn s campaigning on the grounds that he failed
to make an emotional appeal, instead asking people to make their own
rational decision when they come to cast their vote. So he lost out
the emotional appeals other people were making. It seems that he was
successfully respecting individual agency. You ve got to give people
a chance to live up to their own idea of what they should do.
I m not sure how to reconcile these various ideas, and I m not sure
what it says about me that I find non-lethal weaponry as uncomfortable
as I do.


I had my strong doubts as to whether the shipment would be allowed through customs, and was happily surprised by a smiling Graham today before noon. He handed me a smallish box that arrived to his office, containing...




