[pacman-dev] Fwd: [makepkg patch - generate .SRCINFO file when running "--source"]
vlad
vla at uni-bonn.de
Tue Aug 3 05:25:03 EDT 2010
Sorry, forgot the patch.
Here it is.
Vlad
--
-------------- next part --------------
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 9f3bbb2..ebc6087 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -961,6 +961,75 @@ write_pkginfo() {
fi
}
+write_srcinfo() {
+# usage: write_srcinfo name
+
+ local packager
+ if [[ -n ${PACKAGER} ]]; then packager="${PACKAGER}"
+ else packager="none"; fi
+ local builddate=$(date -u "+%s")
+
+ msg2 "$(gettext "Generating .SRCINFO file...")"
+ echo "# Generated by makepkg $myver"
+ echo "# $(LC_ALL=C date -u)"
+ # use "global" as tag for vars needed in entire $BUILDFILE
+ if (( SPLITPKG )); then
+ echo "global pkgbase = ${pkgbase}"
+ printf "global pkgname = %s\n" "${pkgname[@]}"
+ else echo "global pkgname = $1"
+ fi
+ echo "global pkgver = ${pkgver}-${pkgrel}"
+ echo "global pkgdesc = ${pkgdesc}"
+ echo "global url = ${url}"
+ echo "global packager = ${packager}"
+ echo "global builddate = $builddate"
+ [[ ${changelog} ]] && echo "global changelog = ${changelog}"
+
+ # arrays
+ [[ ${source} ]] && printf "global source = %s\n" "${source[@]}"
+ [[ ${license} ]] && printf "global license = %s\n" "${license[@]}"
+ [[ ${groups} ]] && printf "global group = %s\n" "${groups[@]}"
+ printf "global arch = %s\n" "${arch[@]}"
+ [[ ${backup} ]] && printf "global backup = %s\n" "${backup[@]}"
+ [[ ${depends} ]] && printf "global depends = %s\n" "${depends[@]}"
+ [[ ${makedepends} ]] && printf "global makedepends = %s\n" "${makedepends[@]}"
+ [[ ${optdepends} ]] && printf "global optdepends = %s\n" "${optdepends[@]}"
+ [[ ${conflicts} ]] && printf "global conflict = %s\n" "${conflicts[@]}"
+ [[ ${provides} ]] && printf "global provides = %s\n" "${provides[@]}"
+ [[ ${replaces} ]] && printf "global replaces = %s\n" "${replaces[@]}"
+
+ if (( SPLITPKG )); then
+ local name vararray override tempvar
+ IFS=$'\n'
+ for name in "${pkgname[@]}"; do
+ # use $name as tag for vars needed only in package_$name
+ # standardize function formatting: delete whitespaces/tabs at the beginning and
+ # change trailing character to \n at the end of each line inside function; grep the variables
+ vararray=( $(declare -f "package_${name}" | /bin/sed -e "s/^[ \t]*//" -e "s/;$/\n/" | /bin/grep -e "^[[:alpha:]]*=") )
+ for override in "${vararray[@]}"; do
+ tempvar="${override%%=*}"
+ # first check if var is in allowed overrides (splitpkg_overrides)
+ if [[ ${splitpkg_overrides[*]} =~ " ${tempvar} " ]]; then
+ declare -a temparray
+ eval temparray="${override#*=}"
+ [[ "${tempvar}" == "pkgrel" ]] && printf "${name} pkgver = ${pkgver}-${temparray[0]}\n" && continue
+ printf "${name} ${tempvar} = %s\n" "${temparray[@]}"
+ unset temparray
+ fi
+ unset tempvar
+ done
+ done
+ unset IFS
+ fi
+
+ # TODO maybe remove this at some point
+ # warn if license array is not present or empty
+ if [[ -z ${license} ]]; then
+ warning "$(gettext "Please add a license line to your %s!")" "${BUILDSCRIPT}"
+ plain "$(gettext "Example for GPL\'ed software: license=('GPL').")"
+ fi
+}
+
check_package() {
cd "$pkgdir"
@@ -1091,6 +1160,8 @@ create_srcpackage() {
local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
mkdir "${srclinks}"/${pkgbase}
+ write_srcinfo ${pkgbase} > "${srclinks}/${pkgbase}/.SRCINFO"
+
msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}"
More information about the pacman-dev
mailing list