diff options
author | cezarmathe | 2018-12-12 18:47:49 +0200 |
---|---|---|
committer | cezarmathe | 2018-12-12 18:47:49 +0200 |
commit | bfd4c976e5026ee1b25e98012c0cfdb3949fb2e2 (patch) | |
tree | a961762240ece66c0d655b500a85d10bfe3dbfc9 | |
download | aur-bfd4c976e5026ee1b25e98012c0cfdb3949fb2e2.tar.gz |
First repotools release.
-rw-r--r-- | .SRCINFO | 42 | ||||
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | PKGBUILD | 65 | ||||
-rw-r--r-- | add_remove_packages.sh | 25 | ||||
-rw-r--r-- | build_environment.sh | 17 | ||||
-rw-r--r-- | build_packages.sh | 50 | ||||
-rw-r--r-- | cycle.sh | 15 | ||||
-rw-r--r-- | help_usage.sh | 9 | ||||
-rw-r--r-- | new_meta_package.sh | 1 | ||||
-rw-r--r-- | new_repository.sh | 64 | ||||
-rw-r--r-- | pacman_entries.sh | 18 | ||||
-rwxr-xr-x | repotools | 257 | ||||
-rw-r--r-- | repotools.conf | 8 | ||||
-rw-r--r-- | sync_repositories.sh | 43 | ||||
-rw-r--r-- | update_repositories.sh | 15 | ||||
-rw-r--r-- | utils.sh | 17 |
16 files changed, 667 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..60af7ef78f2a --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,42 @@ +pkgbase = repotools + pkgdesc = Utility for creating and maintaining custom user repositories. + pkgver = 0.1 + pkgrel = 1 + url = https://github.com/cezarmathe/repotools + arch = x86_64 + license = MIT + depends = git + depends = aurutils + backup = etc/repotools.conf + source = repotools + source = repotools.conf + source = add_remove_packages.sh + source = build_environment.sh + source = build_packages.sh + source = cycle.sh + source = help_usage.sh + source = new_meta_package.sh + source = new_repository.sh + source = pacman_entries.sh + source = sync_repositories.sh + source = update_repositories.sh + source = utils.sh + source = LICENSE + validpgpkeys = 61C1AF95BB594AD40DEEB7103F8F89E56422CBA8 + md5sums = 7421f50cf89be766e910b9fcbb36c235 + md5sums = deb5ca2e557abab23905145c625f06a1 + md5sums = a0b7d63a8aa5cde42c21f11b182180b3 + md5sums = 846d10842ef7c63a6e493104cbf4a61c + md5sums = 70aea403ce23dc0c83c203cf24036896 + md5sums = eb33d6e5471a83e52af3d7df9d4d51a9 + md5sums = 3ae35c3be45b14387650a5d68286696f + md5sums = e643ddd60ba72ad53e53d45eac76250d + md5sums = 879df82b7fe4ec27f2aa45d2c4715ac4 + md5sums = 5e480eb9052bd62328142e26617721f7 + md5sums = 638355180cca826d3f14d74be7cce9d0 + md5sums = df83bedfaf82a7b89aec6535bc490093 + md5sums = b9bbf84850ea005568429d396e449f56 + md5sums = 1269890d8780c9cbf0aef3d1eb01bbb5 + +pkgname = repotools + diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000000..cd9603274ae6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Cezar Mathe + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..482dfcaea8ef --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,65 @@ +# Maintainer: Cezar Mathe <cezarmathe@gmail.com> +pkgname=repotools +pkgver=0.1 +pkgrel=1 +pkgdesc="Utility for creating and maintaining custom user repositories." +arch=(x86_64) +url="https://github.com/cezarmathe/repotools" +license=('MIT') +depends=('git' 'aurutils') +backup=('etc/repotools.conf') +source=("repotools" + "repotools.conf" + "add_remove_packages.sh" + "build_environment.sh" + "build_packages.sh" + "cycle.sh" + "help_usage.sh" + "new_meta_package.sh" + "new_repository.sh" + "pacman_entries.sh" + "sync_repositories.sh" + "update_repositories.sh" + "utils.sh" + "LICENSE") +md5sums=('7421f50cf89be766e910b9fcbb36c235' + 'deb5ca2e557abab23905145c625f06a1' + 'a0b7d63a8aa5cde42c21f11b182180b3' + '846d10842ef7c63a6e493104cbf4a61c' + '70aea403ce23dc0c83c203cf24036896' + 'eb33d6e5471a83e52af3d7df9d4d51a9' + '3ae35c3be45b14387650a5d68286696f' + 'e643ddd60ba72ad53e53d45eac76250d' + '879df82b7fe4ec27f2aa45d2c4715ac4' + '5e480eb9052bd62328142e26617721f7' + '638355180cca826d3f14d74be7cce9d0' + 'df83bedfaf82a7b89aec6535bc490093' + 'b9bbf84850ea005568429d396e449f56' + '1269890d8780c9cbf0aef3d1eb01bbb5') +validpgpkeys=('61C1AF95BB594AD40DEEB7103F8F89E56422CBA8') + +package() { + + install -Dm755 "${srcdir}/repotools" "${pkgdir}/usr/bin/repotools" + + install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" + + script_files=("add_remove_packages.sh" + "build_environment.sh" + "build_packages.sh" + "cycle.sh" + "help_usage.sh" + "new_meta_package.sh" + "new_repository.sh" + "pacman_entries.sh" + "sync_repositories.sh" + "update_repositories.sh" + "utils.sh") + + for script_file in ${script_files[*]} + do + install -Dm 644 "${srcdir}/${script_file}" "${pkgdir}/usr/lib/${pkgname}/${script_file}" + done + + install -Dm644 "${srcdir}/repotools.conf" "${pkgdir}/etc/${pkgname}.conf" +} diff --git a/add_remove_packages.sh b/add_remove_packages.sh new file mode 100644 index 000000000000..f23481e1e152 --- /dev/null +++ b/add_remove_packages.sh @@ -0,0 +1,25 @@ +# Functions for adding and removing packages from repositories + +# Add a package to the specified repository +function add_package() { + local repository_name="$1"; shift + local package_name="$1"; shift + + aursync --repo "${repository_name}" --root "${PATH_REPOSITORIES}/${repository_name}/pkg/" "${package_name}" +} + +# Remove a package from the specified repository +function remove_package() { + local repository_name="$1"; shift + local package_name="$1"; shift + + local previous_wd="$(pwd)" + + cd "${PATH_REPOSITORIES}/${repository_name}" + + repo-remove "${PATH_REPOSITORIES}/${repository_name}/${LOCAL_DB_FILE}" "${package_name}" + + rm "${PATH_REPOSITORIES}/${repository_name}/pkg/${package_name}-*.pkg.tar.xz" + + cd "${previous_wd}" +}
\ No newline at end of file diff --git a/build_environment.sh b/build_environment.sh new file mode 100644 index 000000000000..a1d26fde4bce --- /dev/null +++ b/build_environment.sh @@ -0,0 +1,17 @@ +# Functions for interacting with the build environment + +function initialize_build_environment() { + local directory="$1"; shift + + if [[ -z "${directory}" ]]; then + mkdir -p "${PATH_BUILD}" + mkarchroot -C /etc/pacman.conf "${PATH_BUILD}/root" base-devel + else + if [[ "${directory:0:1}" = "/" ]]; then + mkdir -p "${directory}" + mkarchroot -C /etc/pacman.conf "${directory}/root" base-devel + else + echo "Path is invalid" + fi + fi +}
\ No newline at end of file diff --git a/build_packages.sh b/build_packages.sh new file mode 100644 index 000000000000..3c8fc8933d96 --- /dev/null +++ b/build_packages.sh @@ -0,0 +1,50 @@ +# Functions for building packages + +# Build a single package from a repository +# or all packages within repository +# Calling this function with no parameters +# build all packages within repository +function build_package() { + local repository_name="$1"; shift + local package_name="$1"; shift + + if [[ ! -d "${PATH_REPOSITORIES}/${repository_name}/src" ]]; then + echo "The repository ${repository_name} does not have packages that need to be built." + return + fi + + if [[ ! -z "${package_name}" ]]; then + # build a package from the specified repository + if [[ ! -d "${PATH_REPOSITORIES}/${repository_name}/src/${package_name}" ]]; then + echo "The repository ${repository_name} does not have a buildable package named ${package_name}." + return + else + local previous_wd="$(pwd)" + + cd "${PATH_REPOSITORIES}/${repository_name}/src/${package_name}" + makechrootpkg -cur "${PATH_BUILD}" + + repo-add "${PATH_REPOSITORIES}/${repository_name}/${LOCAL_DB_FILE}" *.pkg.tar.xz + + cp *.pkg.tar.xz "${PATH_REPOSITORIES}/${repository_name}/pkg/" + + cd "${previous_wd}" + fi + else + # build all packages from the specified repository + echo "Building all packages from ${repository_name}.." + + for packagename in "${PATH_REPOSITORIES}/${repository_name}/src/*"; do + bash repotools -B "$(basename ${packagename}) ${repository_name}" + done + fi +} + +# Build all packages from all repositories +function build_all_packages() { + echo "Building all packages from all repositories.." + + for reponame in "${PATH_REPOSITORIES}/*"; do + bash repotools -b "$(basename ${reponame})" + done +}
\ No newline at end of file diff --git a/cycle.sh b/cycle.sh new file mode 100644 index 000000000000..ebf68edc8d20 --- /dev/null +++ b/cycle.sh @@ -0,0 +1,15 @@ +# The cycle function + +function cycle() { + + echo "Starting the cycle.." + + bash repotools -s + + bash repotools -d + + bash repotools -u + + bash repotools -s + +}
\ No newline at end of file diff --git a/help_usage.sh b/help_usage.sh new file mode 100644 index 000000000000..52e362747ed5 --- /dev/null +++ b/help_usage.sh @@ -0,0 +1,9 @@ +# Functions for printing the help and usage + +function print_help() { + echo +} + +function print_usage() { + echo +}
\ No newline at end of file diff --git a/new_meta_package.sh b/new_meta_package.sh new file mode 100644 index 000000000000..03c1e29f70b2 --- /dev/null +++ b/new_meta_package.sh @@ -0,0 +1 @@ +# Functions for creating meta packages
\ No newline at end of file diff --git a/new_repository.sh b/new_repository.sh new file mode 100644 index 000000000000..3eec06e5a8d0 --- /dev/null +++ b/new_repository.sh @@ -0,0 +1,64 @@ +# Functions for creating a new repository + +# Create a new repository +function new_repository() { + local repository_name="$1"; shift + + if [[ -d "${PATH_REPOSITORIES}/${repository_name}" ]]; then + echo "The repository already exists." + else + # create the repository directory + mkdir "${PATH_REPOSITORIES}/${repository_name}" + + # create the pkg dir and the database + mkdir "${PATH_REPOSITORIES}/${repository_name}/pkg" + repo-add "${PATH_REPOSITORIES}/${repository_name}/pkg/${repository_name}.db.tar.xz" + + # create a folder for meta packages if required + if [[ -z "${arg_new_repo}" ]]; then + mkdir "${PATH_REPOSITORIES}/${repository_name}/src" + echo "placeholder file" > "${PATH_REPOSITORIES}/${repository_name}/src/.placeholder" + fi + + # create the config file + touch "${PATH_REPOSITORIES}/${repository_name}/.config" + + echo "# Configuration file for the repository" >> "${PATH_REPOSITORIES}/${repository_name}/.config" + echo + echo "LOCAL_REPOSITORY_NAME=\"${repository_name}\"" >> "${PATH_REPOSITORIES}/${repository_name}/.config" + echo "LOCAL_REMOTE_PACKAGE_DIR=\"insert url here\"" >> "${PATH_REPOSITORIES}/${repository_name}/.config" + echo "LOCAL_DB_FILE=\"pkg/${repository_name}.db.tar.xz\"" >> "${PATH_REPOSITORIES}/${repository_name}/.config" + echo "LOCAL_REMOTE_REPO_ADDRESS=\"insert url here\"" >> "${PATH_REPOSITORIES}/${repository_name}/.config" +# EOF + + # edit the config file + vim "${PATH_REPOSITORIES}/${repository_name}/.config" + + # create the gitignore file + vim "${PATH_REPOSITORIES}/${repository_name}/.gitignore" + + fi +} + +# Initialize the new repository +function new_repository_init() { + local repository_name="$1"; shift + + bash "${PATH_REPOTOOLS}/repotools" -G "${repository_name}" > "${PATH_REPOSITORIES}/${repository_name}/pacman-entry.txt" + + local previous_wd="$(pwd)" + + cd "${PATH_REPOSITORIES}/${repository_name}" + + git init + git add . + git add .config + git add .gitignore + git commit -m "Initial config" + + git remote add origin "${LOCAL_REMOTE_REPO_ADDRESS}" + + git push --set-upstream origin master + + cd "${previous_wd}" +}
\ No newline at end of file diff --git a/pacman_entries.sh b/pacman_entries.sh new file mode 100644 index 000000000000..b4e84f448e4f --- /dev/null +++ b/pacman_entries.sh @@ -0,0 +1,18 @@ +# Functions for generating pacman entries for repositories + +function generate_pacman_entry() { + local repository_name="$1"; shift + + if [[ ! -z "${repository_name}" ]]; then + # generate the entry for a single package + echo "[${LOCAL_REPOSITORY_NAME}]" + echo "SigLevel = Optional TrustAll" + echo "Server = ${LOCAL_REMOTE_PACKAGE_DIR}/" + echo + else + # generate the entry for all packages + for reponame in "${PATH_REPOSITORIES}/*"; do + bash repotools -G "$(basename ${reponame})" + done + fi +}
\ No newline at end of file diff --git a/repotools b/repotools new file mode 100755 index 000000000000..d5622450dfb9 --- /dev/null +++ b/repotools @@ -0,0 +1,257 @@ +#!/bin/bash +# Author: Cezar Mathe <cezarmathe@gmail.com> https://github.com/cezarmathe/repotools + +# Load the configuration +if [[ -f "${XDG_CONFIG_HOME}/repotools.conf" ]]; then + source "${XDG_CONFIG_HOME}/repotools.conf" +elif [[ -f "${HOME}/.config/repotools.conf" ]]; then + source "${HOME}/.config/repotools.conf" +elif [[ -f "/etc/repotools.conf" ]]; then + source "/etc/repotools.conf" +else + echo "No configuration file could be found." +fi + +script_modules_base_path="/usr/lib/repotools" + +script_files=("add_remove_packages.sh" + "build_environment.sh" + "build_packages.sh" + "cycle.sh" + "help_usage.sh" + "new_meta_package.sh" + "new_repository.sh" + "pacman_entries.sh" + "sync_repositories.sh" + "update_repositories.sh" + "utils.sh") + +for item in ${script_files[*]}; do + if [ ! -f "${script_modules_base_path}/${item}" ]; then + echo "${item} file not found." + exit 1 + fi + source "${script_modules_base_path}/${item}" +done + +# ---------- + + + +# Main cli + +function main() { + while getopts 'A:bB:cdgGhiI:M:nNR:sSuU' flag; do + case "${flag}" in + + A) + # Add a new package: -A <package_name> <repo_name> + flag_add=1 + arg_add="${OPTARG}" + shift 2;; + + b) + # Build all packages within a single repository: -b <repo_name> + flag_build=1 + shift;; + + B) + # Build a package: -B <package_name> <repo_name> + flag_build=1 + arg_build="${OPTARG}" + shift 2;; + + c) + # Cycle: -c + flag_cycle=1 + shift;; + + d) + # Build all packages within all repositories: -d + flag_build_all=1 + shift;; + + g) + # Generate a pacman entry for all repositories: -g + flag_generate_pacman_entry=1 + shift;; + + G) + # Generate a pacman entry for a single repository: -G <repo_name> + flag_Generate_pacman_entry=1 + shift;; + + h) + # Help&usage: -h + print_help + exit + ;; + + i) + # Initialize the build environment in the default directory: -i + flag_init_build_env=1 + shift;; + + I) + # Initialize the build environment in a specific directory: -I <directory> + flag_init_build_env=1 + arg_init_build_env="${OPTARG}" + shift 2;; + + M) + # Create a new meta package: -M <package_name> <repo_name> + flag_new_meta_pkg=1 + arg_new_meta_pkg="${OPTARG}" + shift 2;; + + n) + # Create a new repository for meta packages: -n <repo_name> + flag_new_repo=1 + shift ;; + N) + # Create a new repository for regular packages: -N <repo_name> + flag_new_repo=1 + arg_new_repo=1 + shift ;; + + R) + # Remove a package: -R <package_name> <repo_name> + flag_remove=1 + arg_remove="${OPTARG}" + shift 2;; + + s) + # Sync all repositories: -s + flag_sync=1 + shift;; + + S) + # Sync a single repository: -S <repo_name> + flag_Sync=1 + shift;; + + u) + # Update all repositories: -u + flag_update=1 + shift;; + + U) + # Update a single repository: -U <repo_name> + flag_Update=1 + shift;; + + *) + print_usage + exit 1 + ;; + + esac + done + + # trap remove_tmp_files EXIT + + # Flags that are completely independent + if [[ ! -z "${flag_init_build_env}" ]]; then + initialize_build_environment "${arg_init_build_env}" + fi + # ---------- + + # The cycle flag blocks other flags + if [[ ! -z "${flag_cycle}" ]]; then + cycle + exit + fi + # ---------- + + # Flags that do not depend on a repository name + if [[ ! -z "${flag_sync}" ]]; then + # sync all repositories + sync_with_remote + fi + + if [[ ! -z "${flag_update}" ]]; then + # update all repositories + update_repository + fi + + if [[ ! -z "${flag_build_all}" ]]; then + # build all packages in all repositories + build_all_packages + fi + + if [[ ! -z "${flag_generate_pacman_entry}" ]]; then + generate_pacman_entry + fi + # ---------- + + # Flags that depend on a repository name + local repository_name="$1"; shift + + # checking whether a repository name was specified + if [[ -z "${repository_name}" ]]; then + echo "No repository name specified." + exit 1 + fi + + # the new repository command is executed before anything else that requires a valid repository + if [[ ! -z "${flag_new_repo}" ]]; then + # create a new repository + # ${arg_new_repo} specifies whether the created repository will be a + # meta package repository or a regular package repository + # new_repository "${repository_name}" "${arg_new_repo}" + new_repository "${repository_name}" + fi + + # checking whether the specified repository exists or not + if [[ ! -d "${PATH_REPOSITORIES}/${repository_name}" ]]; then + echo "The repository ${repository_name} does not exist." + exit 1 + fi + + # source the repository config before other commands so it needs to be + # called only once + source_pkg_config "${repository_name}" + + # initialize git if a repository was created + if [[ ! -z "${flag_new_repo}" ]]; then + new_repository_init "${repository_name}" + fi + + if [[ ! -z "${flag_Sync}" ]]; then + # sync a single repository + sync_with_remote "${repository_name}" + fi + + if [[ ! -z "${flag_add}" ]]; then + # add a package in a repository + add_package "${repository_name}" "${arg_add}" + fi + + if [[ ! -z "${flag_remove}" ]]; then + # remove a package in a repository + remove_package "${repository_name}" "${arg_remove}" + fi + + if [[ ! -z "${flag_Update}" ]]; then + # update packages within a repository + update_repository "${repository_name}" + fi + + if [[ ! -z "${flag_build}" ]]; then + # build a package/packages within a repository + build_package "${repository_name}" "${arg_build}" + fi + + if [[ ! -z "${flag_new_meta_pkg}" ]]; then + # create a new meta package in a repository + # create_new_meta_package "${repository_name}" "${arg_new_meta_pkg}" + echo + fi + + if [[ ! -z "${flag_Generate_pacman_entry}" ]]; then + generate_pacman_entry "${repository_name}" + fi + # ---------- +} + +main $@
\ No newline at end of file diff --git a/repotools.conf b/repotools.conf new file mode 100644 index 000000000000..fd40582ef786 --- /dev/null +++ b/repotools.conf @@ -0,0 +1,8 @@ +# Global configuration file for the repotools utility + +# Local storage for repositories +PATH_REPOSITORIES="${HOME}/.local/share/repotools/repositories" + +# Build environment for building packages in a clean chroot +PATH_BUILD="{HOME}/.local/share/repotools/build" + diff --git a/sync_repositories.sh b/sync_repositories.sh new file mode 100644 index 000000000000..07040103ae36 --- /dev/null +++ b/sync_repositories.sh @@ -0,0 +1,43 @@ +# Functions for syncing repositories with the remote + +function sync_with_remote() { + local repository_name="$1"; shift + + if [[ ! -z "${repository_name}" ]]; then + # sync a single repository + + if [[ -z "${LOCAL_REMOTE_REPO_ADDRESS}" ]]; then + echo "The repository ${repository_name} does not have a remote git address configured." + return + fi + + git --work-tree="${PATH_REPOSITORIES}/${repository_name}/" --git-dir="${PATH_REPOSITORIES}/${repository_name}/.git" remote update + + git --work-tree="${PATH_REPOSITORIES}/${repository_name}/" --git-dir="${PATH_REPOSITORIES}/${repository_name}/.git" add . + + git --work-tree="${PATH_REPOSITORIES}/${repository_name}/" --git-dir="${PATH_REPOSITORIES}/${repository_name}/.git" commit -a -m "$(date)" + + local upstream=${1:-'@{u}'} + local local_status=$(git --work-tree=${PATH_REPOSITORIES}/${repository_name}/ --git-dir=${PATH_REPOSITORIES}/${repository_name}/.git rev-parse @) + local remote_status=$(git --work-tree=${PATH_REPOSITORIES}/${repository_name}/ --git-dir=${PATH_REPOSITORIES}/${repository_name}/.git rev-parse "$upstream") + local base_status=$(git --work-tree=${PATH_REPOSITORIES}/${repository_name}/ --git-dir=${PATH_REPOSITORIES}/${repository_name}/.git merge-base @ "$upstream") + + if [ $local_status == $remote_status ]; then + echo "The repository ${repository_name} is up to date." + elif [ $local_status == $base_status ]; then + echo "${repository_name} is not up to date with the remote, pulling the changes.." + git --work-tree="${PATH_REPOSITORIES}/${repository_name}/" --git-dir="${PATH_REPOSITORIES}/${repository_name}/.git" pull + elif [ $remote_status == $base_status ]; then + echo "${repository_name} is ahead of the remote, pushing the changes.." + git --work-tree="${PATH_REPOSITORIES}/${repository_name}/" --git-dir="${PATH_REPOSITORIES}/${repository_name}/.git" push + else + echo "${repository_name} and the remote are diverged." + fi + else + # sync all repositories + echo "Syncing all repositories." + for reponame in "${PATH_REPOSITORIES}/*"; do + bash repotools -S "$(basename ${reponame})" + done + fi +}
\ No newline at end of file diff --git a/update_repositories.sh b/update_repositories.sh new file mode 100644 index 000000000000..f4762251729f --- /dev/null +++ b/update_repositories.sh @@ -0,0 +1,15 @@ +# Functions for updating repositories + +function update_repository() { + local repository_name="$1"; shift + + if [[ ! -z "${repository_name}" ]]; then + # update a single repository + aursync --repo "$LOCAL_REPOSITORY_NAME" --root "$PATH_REPOSITORIES/${repository_name}/pkg" -u + else + # update all repositories + for reponame in "${PATH_REPOSITORIES}/*"; do + bash repotools -U "$(basename ${reponame})" + done + fi +}
\ No newline at end of file diff --git a/utils.sh b/utils.sh new file mode 100644 index 000000000000..67ddb38a8409 --- /dev/null +++ b/utils.sh @@ -0,0 +1,17 @@ +# Utilities + +function source_pkg_config() { + + local repository_name="$1"; shift + + if [[ ! -f "${PATH_REPOSITORIES}/${repository_name}/.config" ]]; then + echo "The repository ${repository_name} has no config file." + exit 1 + fi + + source "${PATH_REPOSITORIES}/${repository_name}/.config" +} + +function remove_tmp_files() { + rm "${PATH_REPOSITORIES}"/*.tmp +}
\ No newline at end of file |