summaryrefslogtreecommitdiffstats
path: root/src/oh-buildopk
diff options
context:
space:
mode:
Diffstat (limited to 'src/oh-buildopk')
-rw-r--r--src/oh-buildopk76
1 files changed, 64 insertions, 12 deletions
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