From b72653f654882335026d04de5c25ea02c20e8412 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 13 Nov 2012 14:19:36 -0500 Subject: clean up some misc scripts --- src/diff-unfree | 95 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 47 deletions(-) (limited to 'src/diff-unfree') diff --git a/src/diff-unfree b/src/diff-unfree index a0a8d63..24ada67 100755 --- a/src/diff-unfree +++ b/src/diff-unfree @@ -20,66 +20,67 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -source /etc/libretools.conf -custom_config=$XDG_CONFIG_HOME/libretools/libretools.conf - -[[ "$1" == "--help" ]] && { - msg "Diff-Unfree helps you diff build scripts from ABSLibre against - (Unfree) ABS. Package name and repo will we guessed if you don't - specify them." - msg2 "Usage: $0 [community|packages] [unfree-package] [repo]" - exit 0 -} +. /etc/libretools.conf + +cmd=${0##*/} -[[ ! -r PKGBUILD ]] && { - error "This is not a build dir." - exit 1 +usage() { + echo "Usage: $cmd [community|packages] [unfree-package] [repo]" + echo "Usage: $cmd --help" + echo "Helps you diff build scripts from ABSLibre against (Unfree) ABS." + echo "" + echo "Package name and repo will we guessed if you don't specify them." } -package_guess=$(basename $PWD) +main() { + if [[ "$1" == "--help" ]]; then + usage + exit 0 + fi -repo=${1:-$(basename $(dirname $PWD))} -package=${2:-${package_guess/-libre}} -trunk=${3:-trunk} + local package_guess=${PWD##*/} + local repo=${1:-$(basename ${PWD%/*})} + local package=${2:-${package_guess%-libre}} + local trunk=${3:-trunk} -tmp_dir=$(mktemp -d /tmp/${package}.XXXXXX) + svnrepo="packages" + case $repo in + community*) svnrepo="community";; + multilib*) svnrepo="community";; + *) :;; + esac -svnrepo="packages" -case $repo in - community*) - svnrepo="community" - ;; - multilib*) - svnrepo="community" - ;; - *) - ;; -esac + if [[ ! -r PKGBUILD ]]; then + error "This is not a build dir." + exit 1 + fi -unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" -[[ ! -d "${tmp_dir}" ]] && { - error "Can't create temp dir" - exit 1 -} + tmp_dir="$(mktemp --tmpdir -d ${package}.XXXXXX)" + if [[ ! -d "${tmp_dir}" ]]; then + error "Can't create temp dir" + exit 1 + fi + unfree_dir="${tmp_dir}/${svnrepo}/${package}/${trunk}" -stdnull 'pushd "${tmp_dir}"' + stdnull 'pushd "${tmp_dir}"' -msg "Getting diff from $repo/$package..." + msg "Getting diff from $repo/$package..." -stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' + stdnull 'svn checkout --depth=empty svn://svn.archlinux.org/$svnrepo' -cd ${svnrepo} -svn update ${package} + cd ${svnrepo} + svn update ${package} -# Back to start dir -stdnull popd + # Back to start dir + stdnull popd -msg "Diffing files" + msg "Diffing files" -for _file in ${unfree_dir}/*; do - msg2 "$(basename "${_file}")" - ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" -done + for _file in ${unfree_dir}/*; do + msg2 "$(basename "${_file}")" + ${DIFFTOOL} "$PWD/$(basename "${_file}")" "${_file}" + done +} -exit $? +main "$@" -- cgit v1.2.3-54-g00ecf