I kinda solve that by doing something like this:<p><pre><code>    # install runtime deps
    dpkg -l | awk &#x27;{print $2}&#x27; | sort &gt; old.txt
    # install build deps
    # build software
    dpkg -l | awk &#x27;{print $2}&#x27; | sort &gt; new.txt
    apt-get -y remove --purge $(comm -13 old.txt  new.txt)
</code></pre>
Probably a better way to accomplish that, but it was the easiest way I could see to implement an &#x27;undo&#x27;