build: factorize code between upgrade and .install files