#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-create-package
|
|
# Copyright (C) 2008 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
#Description: Creates a new package
|
|
#Alias: pkg
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. "$SDEROOT/lib/libsde.in"
|
|
. "$SDEROOT/lib/sde-package.in"
|
|
. "$SDEROOT/lib/sde-package/hives.in"
|
|
|
|
create_usage() {
|
|
local progname=${0##*/}
|
|
cat <<EOT
|
|
Usage: ${progname//-/ } [--hive <hive>[:<index>]] [<repository>/][<package>] [hive arguments]
|
|
|
|
Available Hives (--hivelist):
|
|
download Create from a list of download locations (default)
|
|
freshmeat Create based on freshmeat.net information (Alias: fm)
|
|
debian Create based on packages.debian.org information
|
|
|
|
EOT
|
|
}
|
|
|
|
shortopts=''
|
|
longopts='help,hive:,hivelist'
|
|
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
|
|
if [ $? -ne 0 ]; then
|
|
create_usage
|
|
exit -1
|
|
fi
|
|
|
|
# load new arguments list
|
|
eval set -- "$options"
|
|
|
|
hive=
|
|
hiveindex=
|
|
hivelist=
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--help)
|
|
create_usage
|
|
exit 0 ;;
|
|
|
|
--hive)
|
|
hive=$2; shift
|
|
;;
|
|
--hivelist)
|
|
hivelist=yes
|
|
;;
|
|
|
|
--) shift; break ;;
|
|
*) echo_abort 1 "$1: Unknown argument, aborting."
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# just list know hives
|
|
#
|
|
if [ -n "$hivelist" ]; then
|
|
for x in $( package_hives_list ); do
|
|
echo $x
|
|
done
|
|
exit 0
|
|
fi
|
|
|
|
# validate the choosen hive
|
|
#
|
|
if [ -n "$hive" ]; then
|
|
# split hive and hiveindex
|
|
if expr "$hive" : ".*:.*" > /dev/null; then
|
|
hiveindex="${hive#*:}"
|
|
hive="${hive%%:*}"
|
|
fi
|
|
|
|
# translate into the real name of the hive, in the case the alias was gives
|
|
x=$( package_hive_alias "$hive" )
|
|
if [ -z "$x" ]; then
|
|
echo_abort 1 "$hive: Invalid hive."
|
|
else
|
|
hive="$x"
|
|
fi
|
|
else
|
|
# assume download hive of none is given
|
|
hive='download'
|
|
fi
|
|
|
|
# $repo/$pkg
|
|
#
|
|
pkg="$1"; shift
|
|
if [ -z "$pkg" ]; then
|
|
echo_error "no package name given."
|
|
create_usage
|
|
exit 1
|
|
elif expr "$pkg" : ".*/.*" > /dev/null; then
|
|
# repository given
|
|
repo="${pkg%/*}"
|
|
pkg="${pkg##*/}"
|
|
else
|
|
# detect repo based on $PWD
|
|
repo=$( package_autodetect_repo )
|
|
# base use wip/ if the detection failed
|
|
repo="${repo:-wip}"
|
|
fi
|
|
|
|
# validate $pkg
|
|
#
|
|
confdir=$( package_confdir "$pkg" )
|
|
[ -z "$confdir" ] || echo_abort 2 "$pkg: package already exists (${confdir#$SDEROOT/})."
|
|
|
|
echo_info "Creating package/$repo/$pkg from $hive:${hiveindex:-$pkg}"
|
|
|
|
"$SDEROOT/lib/sde-package/hives/$hive" "${hiveindex:-$pkg}" "$@"
|