diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/opkbuild | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/opkbuild b/src/opkbuild index 0b15d5f..42e903f 100644 --- a/src/opkbuild +++ b/src/opkbuild @@ -32,6 +32,38 @@ error() exit 1 } +opts=$(getopt -n "${0}" -o 'r:' -- "${@}") +if [ ${?} -ne 0 ]; then + print_usage "${0}" >&2 + exit 1; +fi +eval set -- "${opts}" +while true; do + case "${1}" in + -r) + uid0_cmd=${2} + shift 2 + ;; + --) + shift + break + ;; + *) + print_usage "${0}" >&2 + exit 1 + ;; + esac +done + +if [ -z "${uid0_cmd}" ]; then + uid0_cmd=fakeroot +fi +${uid0_cmd} true +if [ ${?} -ne 0 ]; then + printf 'opkbuild: Error running command to gain UID 0\n' >&2 + exit 1 +fi + # Sanity checks. printf 'opkbuild: Checking for sanity...\n' if [ ! -f format -o ! -f build -o ! -f control ]; then @@ -56,21 +88,22 @@ version=$(oh_get_field Version) # Build *-src package. printf 'opkbuild: Attempting to build package "%s"...\n' "${srcpkg}-src" printf 'opkbuild: Installing files for package "%s"...\n' "${srcpkg}-src" -mkdir -p ${srcpkg}-src.data/usr/src/${srcpkg}_${version} || +${uid0_cmd} mkdir -p ${srcpkg}-src.data/usr/src/${srcpkg}_${version} || error "${srcpkg}-src" for file in ../*; do case ${file} in ../tmp) ;; ../*) - cp -R ${file} ${srcpkg}-src.data/usr/src/${srcpkg}_${version} || + ${uid0_cmd} cp -R ${file} \ + ${srcpkg}-src.data/usr/src/${srcpkg}_${version} || error "${srcpkg}-src" ;; esac done -oh-gencontrol -s || error "${srcpkg}-src" -oh-buildopk ${srcpkg}-src || error "${srcpkg}-src" -rm -Rf ${srcpkg}-src.data +${uid0_cmd} oh-gencontrol -s || error "${srcpkg}-src" +${uid0_cmd} oh-buildopk ${srcpkg}-src || error "${srcpkg}-src" +${uid0_cmd} rm -Rf ${srcpkg}-src.data || error "${srcpkg}-src" printf 'opkbuild: Package "%s" complete!\n\n' "${srcpkg}-src" # Build other binary packages. @@ -91,7 +124,7 @@ for binpkgdir in ../*.pkg/; do fi # TODO: Other compression formats, putting things in src/, ... # Build the package. - ../build ${binpkg} || error "${binpkg}" + ${uid0_cmd} ../build ${binpkg} || error "${binpkg}" printf 'opkbuild: Package "%s" complete!\n\n' "${binpkg}" # Clean up everything except the build stamps. for file in *; do |