build.sh: clean-up and adapt for SD