makepkg patch - generate .SRCINFO file when running "--source"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hello list,

Here is a patch against makepkg from git which introduces a new function
"write_srcinfo()". This generates a file .SRCINFO - like the .PKGINFO
one - when "makepkg --source" is run and then it is added to the src.tar.gz
archive. 
I think having such a file is an important step for getting split packages to
the AUR. It is also useful for third party applications. Since this file is
generated during making the source archive, there is no need for parsing/sourcing
the PKGBUILD everytime meta infos are needed afterwards.
This is also a way of standardizing the source archive.

.SRCINFO looks like (generated for gcc from core):
"
# Generated by makepkg 3.4.0
# Tue Jul 27 12:56:38 UTC 2010
global pkgbase = gcc
global pkgname = gcc
global pkgname = gcc-libs
global pkgname = gcc-fortran
global pkgname = gcc-objc
global pkgname = gcc-ada
global pkgver = 4.5.0-6
global pkgdesc = The GNU Compiler Collection
global url = http://gcc.gnu.org
global packager = Vlad George <donvla@xxxxxxxxxxxxxxxxxxxxx>
global builddate = 1280235398
global source = ftp://gcc.gnu.org/pub/gcc/snapshots/4.5-20100610/gcc-core-4.5-20100610.tar.bz2
global source = ftp://gcc.gnu.org/pub/gcc/snapshots/4.5-20100610/gcc-g++-4.5-20100610.tar.bz2
global source = ftp://gcc.gnu.org/pub/gcc/snapshots/4.5-20100610/gcc-fortran-4.5-20100610.tar.bz2
global source = ftp://gcc.gnu.org/pub/gcc/snapshots/4.5-20100610/gcc-objc-4.5-20100610.tar.bz2
global source = ftp://gcc.gnu.org/pub/gcc/snapshots/4.5-20100610/gcc-ada-4.5-20100610.tar.bz2
global source = ftp://gcc.gnu.org/pub/gcc/libstdc++/doxygen/libstdc++-man.20100312.tar.bz2
global source = gcc_pure64.patch
global source = gcc-hash-style-both.patch
global source = r160561.patch
global license = GPL
global license = LGPL
global license = custom
global arch = i686
global arch = x86_64
global makedepends = binutils>=2.20.1
global makedepends = libmpc>=0.8.2-2
global makedepends = cloog-ppl>=0.15.8
global makedepends = libelf
global makedepends = gcc-ada
gcc depends = binutils>=2.20.1
gcc depends = libmpc>=0.8.1-2
gcc depends = cloog-ppl>=0.15.8
gcc depends = libelf
gcc groups = base-devel
gcc install = gcc.install
gcc-libs pkgdesc = Runtime libraries shipped by GCC for C and C++ languages
gcc-libs groups = base
gcc-libs depends = glibc>=2.11.1-2
gcc-libs install = gcc-libs.install
gcc-fortran pkgdesc = Fortran front-end for GCC
gcc-fortran depends = gcc=4.5.0-6
gcc-fortran install = gcc-fortran.install
gcc-objc pkgdesc = Objective-C front-end for GCC
gcc-objc depends = gcc=4.5.0-6
gcc-ada pkgdesc = Ada front-end for GCC (GNAT)
gcc-ada depends = gcc=4.5.0-6
gcc-ada install = gcc-ada.install 
"

As you see this file contains of different parts separated by a leading
tag. "global" denotes the global PKGBUILD vars and the name of the split
package denotes the local package variables. However, this is just a
first formatting approach. This can be changed according to further
needs. I think this is a clear and easily readable/parseable output.
Note that "packager" defaults to the person who actually build the
source archive. Perhaps this has to be changed to AUR user name, not to
the makepkg.conf PACKAGER entry.

Vlad

-- 
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}"
 

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux