aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/pkgs32
1 files changed, 31 insertions, 1 deletions
diff --git a/bin/pkgs b/bin/pkgs
index a64f969..1e0eb0d 100755
--- a/bin/pkgs
+++ b/bin/pkgs
@@ -6,6 +6,7 @@ package_dir_base="$HOME/packages/"
repo=""
package=""
mode=""
+new_package=0
declare -A upstreams=(
["aur"]="aur@aur.archlinux.org"
@@ -42,6 +43,31 @@ add_package() {
rm "$tmp_file"
}
+create_package() {
+ local name="$1"
+ local pkgbuild=""
+ local maintainer=""
+ local mail=""
+ maintainer="$(git config --get --global user.name)"
+ mail="$(git config --get --global user.email)"
+ create_repo_dir
+ cd "${package_dirs[$repo]}"
+ if [ "$repo" == "aur" ]; then
+ git clone "${upstreams[$repo]}:${name}"
+ pkgbuild="${name}/PKGBUILD"
+ else
+ mkdir -p "${name}"/{trunk,repos}
+ pkgbuild="${name}/trunk/PKGBUILD"
+ fi
+ if [ ! -f "${pkgbuild}" ]; then
+ cp /usr/share/pacman/PKGBUILD.proto "${pkgbuild}"
+ sed -e "s/NAME/$name/g" \
+ -e "1i# $maintainer <$mail>" \
+ -e '/#/d' \
+ -i "${pkgbuild}"
+ fi
+}
+
remove_package() {
local name="$1"
local tmp_file=""
@@ -129,7 +155,7 @@ update_packages() {
}
if [ ${#@} -gt 0 ]; then
- while getopts ':a:chlur:ACEP' flag; do
+ while getopts ':a:chlnur:ACEP' flag; do
case "${flag}" in
a)
check_mode_set
@@ -152,6 +178,9 @@ if [ ${#@} -gt 0 ]; then
check_mode_set
mode="list"
;;
+ n)
+ new_package=1
+ ;;
# TODO: introduce -m flag for moving package (e.g. community2extra, extra2community)
# TODO: introduce -n flag for creating new package (with PKGBUILD copied
# from default)
@@ -205,6 +234,7 @@ case "${mode}" in
exit 1
else
add_package "$package"
+ [ $new_package ] && create_package "$package"
fi
;;
remove)