From 5bbf15572626010ce6e2bc783d0a980fc24662b2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 25 Aug 2013 14:22:12 -0400 Subject: Move libregit into its own directory/subpackage --- Makefile | 3 ++- src/libregit | 74 --------------------------------------------------- src/libregit/Makefile | 1 + src/libregit/libregit | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 75 deletions(-) delete mode 100755 src/libregit create mode 100644 src/libregit/Makefile create mode 100755 src/libregit/libregit diff --git a/Makefile b/Makefile index 3f95e6e..27139ae 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include config.mk ################################################################################ # these are the resulting packages -packages=doc libretools libretools-mips64el librelib +packages=doc libretools libretools-mips64el librelib libregit # and which directories they contain doc=doc libretools=\ @@ -17,6 +17,7 @@ libretools=\ src/toru libretools-mips64el=src/mips64el-tools librelib=src/lib +libregit=src/libregit ################################################################################ diff --git a/src/libregit b/src/libregit deleted file mode 100755 index c20c25d..0000000 --- a/src/libregit +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2012-2013 Pacman Development Team -# Copyright (c) 2012-2013 Luke Shumaker -# -# 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; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. libremessages - -cd_safe() { - if ! cd "$1"; then - error "Failed to change to directory %s" "$1" - plain "Aborting..." - exit 1 - fi -} - -download_git() { - if [[ ! -d "$dir/.git" ]] ; then - msg2 "Cloning %s %s repo..." "${repo}" "git" - if ! git clone "$repo" "$dir"; then - error "Failure while downloading %s %s repo" "${repo}" "git" - plain "Aborting..." - exit 1 - fi - else - cd_safe "$dir" - # Make sure we are fetching the right repo - if [[ "$repo" != "$(git config --get remote.origin.url)" ]] ; then - error "%s is not a clone of %s" "$dir" "$repo" - plain "Aborting..." - exit 1 - fi - msg2 "Updating %s %s repo..." "${repo}" "git" - if ! git pull origin "$ref"; then - # only warn on failure to allow offline builds - warning "Failure while updating %s %s repo" "${repo}" "git" - fi - fi -} - -usage() { - print 'Usage: %s repo ref dir' "${0##*/}" - echo - print "Clones or pulls from the git URL 'repo', and checks out the git ref" - print "'ref' to the directory 'dir'." - echo - print "It does safety checks, figures out whether to clone or pull, and other" - print "helpful things. This exists because the same 'download_git' function" - print "from makepkg was being copied again and again." -} - -main() { - [[ $# == 3 ]] || { usage >&2; return 1; } - repo=$1 - ref=$2 - dir=$3 - - [[ -d "${dir%/*}" ]] || mkdir -p "${dir%/*}" - download_git -} - -main "$@" diff --git a/src/libregit/Makefile b/src/libregit/Makefile new file mode 100644 index 0000000..2c76089 --- /dev/null +++ b/src/libregit/Makefile @@ -0,0 +1 @@ +include ../../common.mk diff --git a/src/libregit/libregit b/src/libregit/libregit new file mode 100755 index 0000000..c20c25d --- /dev/null +++ b/src/libregit/libregit @@ -0,0 +1,74 @@ +#!/bin/bash + +# Copyright (c) 2012-2013 Pacman Development Team +# Copyright (c) 2012-2013 Luke Shumaker +# +# 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; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. libremessages + +cd_safe() { + if ! cd "$1"; then + error "Failed to change to directory %s" "$1" + plain "Aborting..." + exit 1 + fi +} + +download_git() { + if [[ ! -d "$dir/.git" ]] ; then + msg2 "Cloning %s %s repo..." "${repo}" "git" + if ! git clone "$repo" "$dir"; then + error "Failure while downloading %s %s repo" "${repo}" "git" + plain "Aborting..." + exit 1 + fi + else + cd_safe "$dir" + # Make sure we are fetching the right repo + if [[ "$repo" != "$(git config --get remote.origin.url)" ]] ; then + error "%s is not a clone of %s" "$dir" "$repo" + plain "Aborting..." + exit 1 + fi + msg2 "Updating %s %s repo..." "${repo}" "git" + if ! git pull origin "$ref"; then + # only warn on failure to allow offline builds + warning "Failure while updating %s %s repo" "${repo}" "git" + fi + fi +} + +usage() { + print 'Usage: %s repo ref dir' "${0##*/}" + echo + print "Clones or pulls from the git URL 'repo', and checks out the git ref" + print "'ref' to the directory 'dir'." + echo + print "It does safety checks, figures out whether to clone or pull, and other" + print "helpful things. This exists because the same 'download_git' function" + print "from makepkg was being copied again and again." +} + +main() { + [[ $# == 3 ]] || { usage >&2; return 1; } + repo=$1 + ref=$2 + dir=$3 + + [[ -d "${dir%/*}" ]] || mkdir -p "${dir%/*}" + download_git +} + +main "$@" -- cgit v1.2.2