summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeppia <seppia@seppia.net>2018-04-30 13:20:18 +0200
committerSeppia <seppia@seppia.net>2018-04-30 13:20:18 +0200
commit539bb576360fcdc38e0e579fee9bc2239e2f64a6 (patch)
tree8e0f8e9578d176477f422f4ac6b816bceefa1825
parent9b11e743ac79d6e397f38798ad6e165976949fed (diff)
downloadrepofish-539bb576360fcdc38e0e579fee9bc2239e2f64a6.tar.gz
repofish-539bb576360fcdc38e0e579fee9bc2239e2f64a6.tar.bz2
repofish-539bb576360fcdc38e0e579fee9bc2239e2f64a6.zip
Add actual sources and update README
-rw-r--r--README3
-rwxr-xr-xrepo.sh192
2 files changed, 194 insertions, 1 deletions
diff --git a/README b/README
index 743db5c..601ddb9 100644
--- a/README
+++ b/README
@@ -5,10 +5,11 @@ Repofish shell script
USAGE:
-The script uses two global variables:
+The script uses three global variables:
SRC_PATH (where the single packages repos are)
REPO_PATH (the parh of the actual local repository)
+ REPO_NAME (the name to use for the repository)
You can globally set these variables in your enviroment or just hardcode
the values in the script. They are commented as a default.
diff --git a/repo.sh b/repo.sh
new file mode 100755
index 0000000..3573b0e
--- /dev/null
+++ b/repo.sh
@@ -0,0 +1,192 @@
+#!/bin/sh
+
+## You can set these variables here or in your enviroment
+
+#SRC_PATH='/path/to/packages/sources'
+#REPO_PATH='/path/to/archlinux/repo'
+#REPO_NAME='repo_name'
+
+add_package() {
+ if [ ! -d "${SRC_PATH}/$(echo $1 | cut -d '/' -f 4 | cut -d '.' -f 1)" ]; then
+ cd ${SRC_PATH}
+ git clone $1
+ else
+ echo 'Package already present.'
+ fi
+}
+
+rm_package() {
+ if [ -d "${SRC_PATH}/$1" ]; then
+ rm -rf ${SRC_PATH}/$1
+ else
+ echo 'Package not present.'
+ fi
+}
+
+check_package() {
+ if [ -d "${SRC_PATH}/$1" ]; then
+ vim ${SRC_PATH}/$1/PKGBUILD
+ else
+ echo 'Package not found.'
+ fi
+}
+
+list_packages() {
+ find ${SRC_PATH}/* -type d -prune | cut -d '/' -f5
+}
+
+clean_packages() {
+ if [ "$1" != '' ]; then
+ find ${SRC_PATH} -type f -iname "*$1*.pkg.tar.xz" -exec rm {} \;
+ else
+ find ${SRC_PATH} -type f -iname "*.pkg.tar.xz" -exec rm {} \;
+ fi
+}
+
+build_packages() {
+ if [ "$1" != '' ]; then
+ cd $(find ${SRC_PATH}/* -type d -prune -iname "*$1")
+ makepkg -Cs
+ else
+ for i in $(find ${SRC_PATH}/* -type d -prune)
+ do
+ cd $i
+ makepkg -Cs
+ done
+ fi
+}
+
+upgrade_packages() {
+ if [ "$1" != '' ]; then
+ cd $(find ${SRC_PATH}/* -type d -prune -iname "*$1")
+ git pull
+ makepkg -Cs
+ else
+ for i in $(find ${SRC_PATH}/* -type d -prune)
+ do
+ cd $i
+ git pull
+ makepkg -Cs
+ done
+ fi
+}
+
+install_package() {
+ if [ -d "${SRC_PATH}/$1" ]; then
+ cd $(find ${SRC_PATH}/* -type d -prune -iname "*$1")
+ git pull
+ makepkg -Csi
+ else
+ echo 'Package not found.'
+ fi
+}
+
+update_repo() {
+ if [ "$1" != '' ]; then
+ find ${SRC_PATH} -type f -iname "*$1*pkg.tar.xz" -exec cp {} ${REPO_PATH}/x86_64/ \;
+ repo-add ${REPO_PATH}/x86_64/${REPO_NAME}.db.tar.gz ${REPO_PATH}/x86_64/*$1*.pkg.tar.xz
+ else
+ find ${SRC_PATH} -type f -iname "*pkg.tar.xz" -exec cp {} ${REPO_PATH}/x86_64/ \;
+ repo-add ${REPO_PATH}/x86_64/${REPO_NAME}.db.tar.gz ${REPO_PATH}/x86_64/*.pkg.tar.xz
+ fi
+}
+
+print_help() {
+ echo 'repo.sh SEPPIOFISH repo tool'
+ echo
+ echo ' USAGE: repo.sh COMMAND PKGNAME (default ALL)'
+ echo
+ echo ' add (url) adds git package repository from aur'
+ echo ' rm remove package'
+ echo ' check check PKGBUILD'
+ echo ' list lists availables packages'
+ echo ' update updates the packages in the repo'
+ echo ' build builds the packages'
+ echo ' upgrade upgrades the packages'
+ echo ' install builds and installs the package'
+ echo ' clean cleans the packages'
+ echo ' help prints this help'
+ echo
+}
+
+if [ "$1" == '' ]; then
+ echo 'warning: no command called.'
+elif [ "$1" == 'add' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" == '' ]; then
+ echo 'error: missing argument.'
+ else
+ add_package $2
+ fi
+elif [ "$1" == 'rm' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" == '' ]; then
+ echo 'error: missing argument.'
+ else
+ rm_package $2
+ fi
+elif [ "$1" == 'check' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" == '' ]; then
+ echo 'error: missing argument.'
+ else
+ check_package $2
+ fi
+elif [ "$1" == 'list' ]; then
+ if [ "$2" != '' ]; then
+ echo 'error: too many arguments.'
+ else
+ list_packages
+ fi
+elif [ "$1" == 'update' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" != '' ]; then
+ update_repo $2
+ else
+ update_repo
+ fi
+elif [ "$1" == 'build' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" != '' ]; then
+ build_packages $2
+ else
+ build_packages
+ fi
+elif [ "$1" == 'upgrade' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" != '' ]; then
+ upgrade_packages $2
+ else
+ upgrade_packages
+ fi
+elif [ "$1" == 'install' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" == '' ]; then
+ echo 'error: missing argument.'
+ else
+ install_package $2
+ fi
+elif [ "$1" == 'clean' ]; then
+ if [ "$3" != '' ]; then
+ echo 'error: too many arguments.'
+ elif [ "$2" != '' ]; then
+ clean_packages $2
+ else
+ clean_packages
+ fi
+elif [ "$1" == 'help' ]; then
+ if [ "$2" != '' ]; then
+ echo 'error: too many arguments.'
+ else
+ print_help
+ fi
+else
+ echo 'error: unrecocnized command.'
+fi