aboutsummaryrefslogtreecommitdiffstats
path: root/bin/pkgs
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2019-04-16 15:55:53 +0200
committerDavid Runge <dave@sleepmap.de>2019-04-16 15:55:53 +0200
commit3f72ffb85f9a7ba0474dbf5c827ff3f0b1b1ae41 (patch)
treed16c1bf54e33d5a7e54195c31c5951c1089a97bf /bin/pkgs
parent81161bf2495521616988ca2158b4a8dca0a71a2c (diff)
downloaddotfiles-3f72ffb85f9a7ba0474dbf5c827ff3f0b1b1ae41.tar.gz
dotfiles-3f72ffb85f9a7ba0474dbf5c827ff3f0b1b1ae41.tar.bz2
dotfiles-3f72ffb85f9a7ba0474dbf5c827ff3f0b1b1ae41.tar.xz
dotfiles-3f72ffb85f9a7ba0474dbf5c827ff3f0b1b1ae41.zip
bin/pkgs: Adding option to initially create a new package upon adding it (-n flag). This automatically retrieves name and email from git config --global for maintainer info.
Diffstat (limited to 'bin/pkgs')
-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)