Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37865501
en ru br
ALT Linux repositórios
S:0.1.11-alt1

Group :: Desenvolvimento/Outros
RPM: update-source-functions

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

update-source-functions-0.1.9/000075500000000000000000000000001227321401100162765ustar00rootroot00000000000000update-source-functions-0.1.9/Makefile.am000064400000000000000000000002731227321401100203340ustar00rootroot00000000000000
SUBDIRS = scripts #po

ACLOCAL_AMFLAGS = -I m4

EXTRA_DIST = m4/ChangeLog

#update-gmo:
# $(MAKE) $(AM_MAKEFLAGS) update-gmo -C po

#all-local: update-gmo

#.PHONY: update-gmo all-local
update-source-functions-0.1.9/configure.ac000064400000000000000000000007541227321401100205720ustar00rootroot00000000000000dnl Process this file with autoconf to create configure.

AC_PREREQ([2.57])
AC_INIT(update-source-functions,[0.1.0], [http://bugs.altlinux.org/enter_bug.cgi?product=Sisyphus,component=update-source-functions],update-source-functions)
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE

AC_PROG_GREP
AC_PROG_SED
#AC_PROG_AWK
#AM_GNU_GETTEXT([external])
#AM_GNU_GETTEXT_VERSION([0.18.1])

AC_SUBST(VERSION)

AC_OUTPUT([Makefile
scripts/Makefile])
# po/Makefile.in])
update-source-functions-0.1.9/scripts/000075500000000000000000000000001227321401100177655ustar00rootroot00000000000000update-source-functions-0.1.9/scripts/Makefile.am000064400000000000000000000000571227321401100220230ustar00rootroot00000000000000
dist_bin_SCRIPTS = update-source-functions.sh
update-source-functions-0.1.9/scripts/update-source-functions.sh000064400000000000000000000336451227321401100251220ustar00rootroot00000000000000#!/bin/sh
#
# Copyright (C) 2013 Paul Wolneykien <manowar@altlinux.org>
# 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 3 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 <http://www.gnu.org/licenses/>.

# General filename pattern with stating version part. Can be used
# to define more specific patterns as "$filename$BASIC_VERPAT".
BASIC_VERPAT='-\([0-9]\+\(\.[0-9]\+\)*\).tar.[bgx]*z[0-9]*'

# Outputs the list of available versions for the given
# SourceForge.net hosted project.
#
# The project RSS URI can be obtained at the "Files" section
# on the project page. The filename regex, if passed, limits
# the files in the output list and should contain \(\) pair
# to select the version number. By default, the pattern is
# '-\([0-9]\+\(\.[0-9]\+\)*\).tar.[bgx]*z[0-9]*'.
#
# The output format is: version [tab] URI
#
# args: sourceforge-rss-URI [filename-regex]
get_available_sourceforge_versions()
{
local uri="$1"
local pat="${2:-$BASIC_VERPAT}"

pat="$(echo $pat | sed -e 's,/,\\/,g')"
rsstail -1 -l -u "$uri" | sed -n -e "
/^Title:[[:space:]]\\(.*$pat\\)[[:space:]]*\$/ {
s/^Title:[[:space:]]\\+\\(.*$pat\\)[[:space:]]*\$/\\2/;
h; n;
s/^Link:[[:space:]]\\+//;
H; g;
s/\\n/\\t/p;
}"
}

# Outputs the current gear package version (V-altV).
get_package_current_version()
{
gear --describe 2>/dev/null | sed -e 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]]\+\)[[:space:]]\+\([^[:space:]]\+\)\?.*$/\1-\2/'
}

# Outputs the current gear package plain version.
get_package_plain_current_version()
{
get_package_current_version | sed -e 's/-alt[0-9._][^-]*$//'
}

# Compares the specified package versions.
#
# args: ver-major-1 ver-minor-1 ver-major-2 ver-minor-2
compare_versions()
{
local vernum1="$1"
local rcnum1="$2"
local vernum2="$3"
local rcnum2="$4"

if [ -z "$vernum1" ]; then
echo -1
return 0
fi

if [ "$vernum1$rcnum1" = "$vernum2$rcnum2" ]; then
echo 0
elif [ "$vernum1" == "$vernum2" ]; then
if [ -z "$rcnum1" ]; then
echo 1
elif [ -z "$rcnum2" ]; then
echo -1
else
rpmvercmp "$rcnum1" "$rcnum2"
fi
else
rpmvercmp "$vernum1" "$vernum2"
fi
}

# Compares the specified package plain versions.
#
# args: ver-1 ver-2
compare_versions_plain()
{
compare_versions "$1" '' "$2" ''
}

# Outputs the list of versions, each greater than the current
# or specified package version.
#
# input: The list of version uri pairs.
# args: [comparator] [current-version]
get_greater_source_versions()
{
local cmp="${1-compare_versions_plain}"
local v0="${2-$(get_package_plain_current_version)}"

while IFS="$(printf '\t')" read -r v rest; do
if [ $("$cmp" "$v0" "$v") -lt 0 ]; then
printf '%s\t%s\n' "$v" "$rest" 2>/dev/null
fi
done
}

# Outputs the lowest available source package version, if any.
#
# input: The list of version uri pairs.
# args: [comparator] [current-version]
get_next_source_version()
{
local cmp="${1-compare_versions_plain}"

get_greater_source_versions "$@" | (
least=
uri=
while IFS="$(printf '\t')" read -r v rest; do
if [ -z "$least" ] || [ $("$cmp" "$v" "$least") -lt 0 ]; then
least="$v"
uri="$rest"
fi
done

[ -n "$least" ] && printf '%s\t%s\n' "$least" "$uri" 2>/dev/null ||:
)
}

# Outputs the highest (latest) available source package version,
# if any.
#
# input: The list of version uri pairs.
# args: [comparator] [current-version]
get_latest_source_version()
{
local cmp="${1-compare_versions_plain}"

get_greater_source_versions "$@" | (
latest=
uri=
while IFS="$(printf '\t')" read -r v rest; do
if [ -z "$latest" ] || [ "$("$cmp" "$v" "$latest")" = "1" ]; then
latest="$v"
uri="$rest"
fi
done

[ -n "$latest" ] && printf '%s\t%s\n' "$latest" "$uri" 2>/dev/null ||:
)
}

# Outputs the list of available versions for the given
# GitHub hosted project.
#
# The output format is: version [tab] URI
#
# args: github-user project [transform-version-pattern]
get_available_github_versions()
{
local tr="${3:-/^[^0-9]\+//g}"
curl -s "https://api.github.com/repos/$1/$2/tags" | python -c "
import sys
import simplejson as json
tags = json.load (sys.stdin)
for tag in tags:
print '%s\\t%s\\n' % (tag['name'], tag['tarball_url'])
" | sed -e "s$tr"
}

# Outputs the list of available versions published as files
# at the given network directory.
#
# The filename regex, if passed, limits the files in
# the output list and should contain \(\) pair to select
# the version number. By default, the pattern is
# '-\([0-9]\+\(\.[0-9]\+\)*\).tar.[bgx]*z[0-9]*'.
#
# The output format is: version [tab] URI
# args: directory-URI [filename-regex]
get_available_pubdir_versions()
{
local uri="$1"
local pat="${2:-$BASIC_VERPAT}"

pat="$(echo $pat | sed -e 's,/,\\/,g')"
local uriq="$(echo "${uri%/}" | sed -e 's,/,\\/,g')"
local baseuri="$(echo "$uri" | sed -e 's,^\([^:]\+://[^/]\+\)/\?.*$,\1,')"
local baseuriq="$(echo "$baseuri" | sed -e 's,/,\\/,g')"
(
if echo "$uri" | grep -iq '^ftp:'; then
curl -sl "${uri%/}/"
elif echo "$uri" | grep -iq '^https\?:'; then
curl -s "$uri" | \
sed -e "s/[[:space:]][Hh][Rr][Ee][Ff]=['\"][^'\"]*['\"]/\\n&\\n/g" | \
sed -n -e "s/^[[:space:]][Hh][Rr][Ee][Ff]=['\"]\\([^'\"]*\\)['\"]/\\1/p"
else
echo "Unknown URI scheme: ${uri%%:*}" >&2
fi
) | sed -n -e "/^https\\?:.*$pat\$/ { s/^.*$pat\$/\\1\t&/p; d }" \
-e "/^ftp\\?:.*$pat\$/ { s/^.*$pat\$/\\1\t&/p; d }" \
-e "/^\\// s/^.*$pat\$/\\1\\t$baseuriq&/p" \
-e "/^[^\\/]/ s/^.*$pat\$/\\1\\t$uriq\\/&/p"
}

# Outputs the list of available versions for the named
# Python module using the information from PyPI.
#
# The output format is: version [tab] URI
#
# args: module-name
get_available_pypi_versions()
{
local name="$1"
local base_uri='https://pypi.python.org/packages/source/'

get_available_pubdir_versions "$base_uri$(echo "$name" | cut -c1)/$name/" "$name$BASIC_VERPAT"
}

# Outputs the list of available versions scanning the tags in
# the given project git repository. A regular expression can
# be used to select and transform the results.
#
# The output format is: version [tab] url [tab] remote-tag-path
#
# args: URL [regexp] [substr]
get_available_git_versions()
{
local url="$1"
local surl="$(echo "$url" | sed -e 's,/,\\/,g')"
local regexp="${2:+$(echo "$2" | sed -e 's,/,\\/,g')}"
local substr="${3:+$(echo "$3" | sed -e 's,/,\\/,g')}"

git ls-remote --tags "$url" | \
sed -n -e "
h;
s/^[^[:space:]]\\+[[:space:]]\\+//;
s,^refs/tags/,,;
/\^{}$/ d;
${regexp:+/$regexp/! d;}
${substr:+s/$regexp/$substr/;}
x;
s/^[^[:space:]]\\+[[:space:]]\\+//;
s/^.*$/$surl\\t&/;
H;
g;
s/\\n/\\t/;
p;
"

}

# Checks if there are some unmerged files in the
# current tree.
git_check_unmerged()
{

git status --porcelain | grep -Pq '^(DD|UD|AU|UA|DU|AA|UU)\s'

}

# Tries to resolve the common git-merge conflict cases
# targeting the 'theirs' state.
#
# args: [subdir]
git_resolve_conflicts()
{
git_check_unmerged || return 0

local dir="${1:-}"

git status --porcelain | \
while read -r status path; do
tpath="$path"
[ -z "$dir" ] || tpath="${tpath#${dir%/}/}"
case "$status" in
DD|UD)
git rm "$path"
;;
AU|UA|DU|AA|UU)
if git show MERGE_HEAD:"$tpath" 1>"$path" 2>/dev/null; then
git add "$path"
else
git rm "$path"
fi
;;
esac
done

git_check_unmerged && return 1

return 0
}

# Performs a subtree merge of the current HEAD and the given
# tag in the remote git repository. With the -r option tries
# to resolve the common git-merge conflict cases targeting the
# 'theirs' state.
#
# args: [-r] URL remote-tag-path subdir
git_subtree_merge()
{
local resolve=
[ "$1" = '-r' ] && resolve=-r
[ -z "${1##-*}" ] && shift
local url="$1"
local tag="$2"
local dir="${3%/}"

echo "Fetching $tag from $url..." >&2
if git fetch -q "$url" "$tag:$tag"; then
if git merge-base HEAD "$tag" 1>/dev/null; then
echo "Making a subtree merge having a common base commit" >&2
if ! git pull -q -s recursive -Xsubtree="$dir" -Xtheirs --no-commit "$url" "$tag"; then
if git_check_unmerged; then
echo "Trying to automatically resolve the merge conflicts" >&2
if git_resolve_conflicts "$dir"; then
echo "Conflicts successfully resolved" >&2
else
echo "Unable to automatically resolve the merge conflicts" >&2
return 1
fi
else
echo "Unable to pull $tag from $url" >&2
return 1
fi
fi
else
echo "No common commits found for $tag" >&2
if [ -n "$(git ls-tree HEAD -- "$dir")" ]; then
if git rm -q -r "$dir"; then
echo "Clear the target subdirectory before importing $tag" >&2
if ! git commit -q -m "Clear the target subdirectory before importing $tag from $url"; then
echo "Unable to commit" >&2
return 1
fi
if ! mkdir "$dir"; then
echo "Unable to re-make the $dir" >&2
return 1
fi
else
echo "Unable to clear the tree $dir/" >&2
return 1
fi
else
rm -fr "$dir"
if ! mkdir "$dir"; then
echo "Unable to re-make the $dir" >&2
return 1
fi
fi
echo "Making a pre-merge of $tag" >&2
if git merge -q -s ours --no-commit "$tag"; then
echo "Bind the subtree to $dir" >&2
if ! git read-tree --prefix=$dir/ -u "$tag"; then
echo "Unable to bind the tree" >&2
return 1
fi
else
echo "Unable to merge" >&2
return 1
fi
fi
if ! git commit -q -m "Subtree merge of $url $tag"; then
echo "Unable to commit" >&2
return 1
fi
else
echo "Unable to fetch $tag from $url" >&2
return 1
fi

echo "Tag $tag successfully merged into the $dir" >&2
}


## File and Git management functions

# Asserts the given next version isn't empty and aborts the program
# with 0 status and the corresponding message if it is empty.
#
# Sets the NEXT, DOWNLOAD_URI and TARNAME variables.
#
# args: next-ver-uri
assert_nextver() {
local NEXT_VER_URI="$1"

if [ -z "$NEXT_VER_URI" ]; then
echo "No greater version available" >&2
exit 0
fi

NEXT="$(echo "$NEXT_VER_URI" | cut -f1)"
DOWNLOAD_URI="$(echo "$NEXT_VER_URI" | cut -f2)"
local URISUF=${DOWNLOAD_URI##*.}
URISUF="${URISUF%/*}"
URISUF="${URISUF%%\?*}"
TARNAME="$SRCDIR-$NEXT.tar.$URISUF"
}

# Downloads the given archive then unpacks it replacing the files
# in the given dir. Then commits the result to Git with the
# corresponding commit message.
#
# Sets the NEXT, DOWNLOAD_URI and TARNAME variables.
#
# args: next-ver-uri srcdir
update_srcdir() {
local NEXT_VER_URI="$1"
local SRCDIR="$2"

NEXT="$(echo "$NEXT_VER_URI" | cut -f1)"
DOWNLOAD_URI="$(echo "$NEXT_VER_URI" | cut -f2)"
local URISUF=${DOWNLOAD_URI##*.}
URISUF="${URISUF%/*}"
URISUF="${URISUF%%\?*}"
TARNAME="$SRCDIR-$NEXT.tar.$URISUF"

assert_nextver "$NEXT_VER_URI"

wget -nv -O "$TARNAME" "$DOWNLOAD_URI"
echo "Successfully fetched the next version $NEXT" >&2

rm -rf "$SRCDIR"
mkdir "$SRCDIR"
tar x --strip-components=$TARSTRIPS -f "$TARNAME" -C "$SRCDIR"
echo "Successfully extracted the sources from $TARNAME" >&2

rm -v "$TARNAME"
git add -A "$SRCDIR"
git commit -a -m "New upstream release $NEXT"
git tag -a -m "Upstream version $NEXT" "$NEXT"
echo "The sources updated successfully" >&2
}

# Updates the version and the release numbers in the given spec file
# or $SPEC.
#
# Sets the EPOCH, VERNUM and RELEASE variables.
#
# args: spec next-ver[-uri]
update_spec_ver() {
local SPEC="$1"
local NEXT="$(echo "$2" | cut -f1)"
VERNUM="$NEXT"

EPOCH="$(sed -n -e 's/^Epoch:[[:space:]]*//p' "$SPEC")"
RELEASE="alt1"

sed -i -e "s/^Version:.*\$/Version: $VERNUM/" "$SPEC"
sed -i -e "s/^Release:.*\$/Release: $RELEASE/" "$SPEC"
echo "Version information updated successfully" >&2
}

# Adds changelog message based on the given version or the current
# version number that is found in the spec.
#
# args: spec [next-ver[-uri]]
update_spec_log() {
local SPEC="$1"
local NEXT="$(echo "${2:-}" | cut -f1)"

local NEWVER="${NEXT:-$(rpm -q --qf '%{VERSION}\n' --specfile "$SPEC" | head -1)}"
add_changelog -e "- Freshed up to v$NEWVER with the help of cronbuild and update-source-functions." "$SPEC"
}
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009