summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-01-29 21:58:22 (EST)
committer P. J. McDermott <pjm@nac.net>2012-01-29 21:58:22 (EST)
commit41d829c1647e42b003fbf3d98c8c600c5e2fdf2a (patch)
tree31077fc61e3942fe3d1a4d78dbc1adf8e5c3cc2c
parent51740fc8e456deba55a0cd240535a22c4fbe816c (diff)
Use correct architecture name in oh-buildopk.
The interface and logic is changed to resemble that of oh-gencontrol.
-rw-r--r--TODO1
-rw-r--r--man/oh-buildopk.15
-rw-r--r--src/oh-buildopk76
-rw-r--r--src/opkbuild2
4 files changed, 70 insertions, 14 deletions
diff --git a/TODO b/TODO
index ca09915..c236ab8 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
TODO:
* Fix oh-strip.
* Make oh-strip obey a missing '-l' option.
- * Handle "Architecture" field in oh-buildopk.
* Check on file ownership and modes.
* Finish tar archive handling in opkhelper.
* Build packages with copyright information and changelogs. [1][2]
diff --git a/man/oh-buildopk.1 b/man/oh-buildopk.1
index 89b6081..69cb47b 100644
--- a/man/oh-buildopk.1
+++ b/man/oh-buildopk.1
@@ -4,10 +4,15 @@
oh-buildopk \- Pack binary package files into an opk file.
.SH SYNOPSIS
.B oh-buildopk
+.BR -s \ |
.IR pkgname ...
.SH DESCRIPTION
.B oh-buildopk
packs files in a binary package staging area into an opk file.
+.SH OPTIONS
+.TP
+.B \-s
+Build an opk file for the binary package that contains source packaging.
.SH COPYRIGHT
Copyright (C) 2012 Patrick "P. J." McDermott
.sp
diff --git a/src/oh-buildopk b/src/oh-buildopk
index 3d67596..3021aa2 100644
--- a/src/oh-buildopk
+++ b/src/oh-buildopk
@@ -20,34 +20,86 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. @@LIBDIR@@/opkhelper/controlfields
+. @@LIBDIR@@/opkhelper/architecture
print_usage()
{
- printf 'Usage: %s pkgname...\n' "$1"
+ printf 'Usage: %s -s | pkgname...\n' "$1"
}
-if [ ${#} -eq 0 ]; then
- print_usage ${0} >&2
- exit 1
+opts=$(getopt -n "${0}" -o 's' -- "${@}")
+if [ ${?} -ne 0 ]; then
+ print_usage "${0}" >&2
+ exit 1;
fi
+eval set -- "${opts}"
+while true; do
+ case "${1}" in
+ -s)
+ is_srcpkg=true
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ print_usage "${0}" >&2
+ exit 1
+ ;;
+ esac
+done
-# Iterate over packages.
-while [ ${#} -gt 0 ]; do
- printf 'oh-buildopk: Packing package "%s"...\n' "${1}"
+if [ -n "${is_srcpkg}" ]; then
+ pkg="${OH_SRCPKG}-src"
# Write debian-binary.
echo '2.0' > debian-binary || exit 2
+
# Pack data.tar.gz.
- cd ${1}.data
+ cd ${pkg}.data
tar -czf ../data.tar.gz . || exit 2
cd ..
+
# Pack control.tar.gz.
- cd ${1}.control
+ cd ${pkg}.control
tar -czf ../control.tar.gz . || exit 2
cd ..
+
# Pack opk file.
- tar -czf ../../${1}_$(oh_get_field Version)_arch.opk \
+ tar -czf ../../${pkg}_${OH_PKGVER}-${OH_PKGREV}_all.opk \
debian-binary data.tar.gz control.tar.gz || exit 2
rm -Rf debian-binary control data.tar.gz control.tar.gz || exit 2
- shift
-done
+else
+ if [ ${#} -eq 0 ]; then
+ print_usage ${0} >&2
+ exit 1
+ fi
+
+ # Iterate over packages.
+ while [ ${#} -gt 0 ]; do
+ printf 'oh-buildopk: Packing package "%s"...\n' "${1}"
+
+ arch="$(oh_get_package_architecture ${1})"
+
+ # Write debian-binary.
+ echo '2.0' > debian-binary || exit 2
+
+ # Pack data.tar.gz.
+ cd ${1}.data
+ tar -czf ../data.tar.gz . || exit 2
+ cd ..
+
+ # Pack control.tar.gz.
+ cd ${1}.control
+ tar -czf ../control.tar.gz . || exit 2
+ cd ..
+
+ # Pack opk file.
+ tar -czf ../../${1}_${OH_PKGVER}-${OH_PKGREV}_${arch}.opk \
+ debian-binary data.tar.gz control.tar.gz || exit 2
+ rm -Rf debian-binary control data.tar.gz control.tar.gz || exit 2
+
+ shift
+ done
+fi
diff --git a/src/opkbuild b/src/opkbuild
index e11e078..1c57869 100644
--- a/src/opkbuild
+++ b/src/opkbuild
@@ -157,7 +157,7 @@ for file in ../*; do
esac
done
( ${uid0_cmd} oh-gencontrol -s;) || error "${srcpkg}-src"
-( ${uid0_cmd} oh-buildopk ${srcpkg}-src;) || error "${srcpkg}-src"
+( ${uid0_cmd} oh-buildopk -s;) || error "${srcpkg}-src"
( ${uid0_cmd} rm -Rf ${srcpkg}-src.data;) || error "${srcpkg}-src"
printf 'opkbuild: Package "%s" complete!\n\n' "${srcpkg}-src"