2016-06-24 18:47:32 -04:00
#!/bin/bash
set -e
## SETTINGS ##
2016-06-30 03:11:08 -04:00
# You can get a list of your private identities with gpg -K.
# You can get the exact string with:
# - gpg -K --fingerprint --with-colons [<your identity, e.g. joeshmoe@joe.com>] | egrep '^fpr:' | cut -f10 -d":"
2016-06-24 18:47:32 -04:00
GPGKEY = '748231EBCBD808A14F5E85D28C004C2F93481F6B' # https://wiki.archlinux.org/index.php/PKGBUILD#validpgpkeys
MAINTNAME = 'brent s. <bts[at]square-r00t[dot]net>'
PKGBUILD_DIR = '/opt/dev/arch'
2016-07-06 09:41:11 -04:00
AUR_PKGS_DIR = " ${ PKGBUILD_DIR } " # should be the dir where the aur_pkgs dir lives
# Get PKGTYPE
PS3 = 'What type of package is this?: '
options = ( "Release/Versioned" "VCS (Git, SVN, Mercurial, etc.)" "Quit" )
select opt in " ${ options [@] } "
do
case ${ opt } in
"Release/Versioned" )
PKGTYPE = "release"
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
"VCS (Git, SVN, Mercurial, etc.)" )
PKGTYPE = "vcs"
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
"Quit" )
exit 0
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
*) echo invalid option; ;
esac
done
# get VCSTYPE, if it's a source package
if [ [ " ${ PKGTYPE } " = = 'vcs' ] ] ;
then
PS3 = 'What type of version-control?: '
options = ( "Git" "Subversion" "Mercurial" "Bazaar" "(Other)" "Quit" )
select opt in " ${ options [@] } "
do
case ${ opt } in
"Git" )
VCSTYPE = 'git'
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
"Subversion" )
VCSTYPE = 'svn'
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
2016-09-13 15:45:56 -04:00
"Mercurial" )
VCSTYPE = 'hg'
break
; ;
2016-07-06 09:41:11 -04:00
"Bazaar" )
VCSTYPE = 'bzr'
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
"(Other)" )
VCSTYPE = 'unknown'
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
"Quit" )
exit 0
2016-08-02 18:22:02 -04:00
break
2016-07-06 09:41:11 -04:00
; ;
*) echo invalid option; ;
esac
done
fi
2016-06-24 18:47:32 -04:00
2016-07-06 09:41:11 -04:00
# get PKGNAME
echo -ne "\nWhat is the NAME of the package? (Exclude VCS type if it's a source-control package,\nthat will be prepended automatically): "
read PKGNAME
echo
2016-06-24 18:47:32 -04:00
2016-07-06 09:41:11 -04:00
# check PKGNAME
2016-06-24 18:47:32 -04:00
set +e # disable bail-on-error because we want a non-zero if a package name is not right, etc.
2016-10-22 06:16:39 -04:00
echo " ${ PKGNAME } " | egrep -Eq '^([a-z0-9\_\-])+$'
2016-06-24 18:47:32 -04:00
if [ [ " ${ ? } " -ne '0' ] ] ;
then
echo "ERROR: That does not seem to be a valid package name!"
exit
fi
2016-07-06 09:41:11 -04:00
set -e
_PKGNAME = " ${ PKGNAME } "
if [ [ -n " ${ VCSTYPE } " && " ${ VCSTYPE } " != '' ] ] ;
2016-06-24 18:47:32 -04:00
then
2016-07-06 09:41:11 -04:00
PKGNAME = " ${ PKGNAME } - ${ VCSTYPE } "
fi
# Get the version to pre-populate the PKGBUILD with, if a release.
if [ [ " ${ PKGTYPE } " = = 'release' ] ] ;
2016-06-24 18:47:32 -04:00
then
2016-07-06 09:41:11 -04:00
echo -n " What is the VERSION of the current release you are packaging for ${ PKGNAME } ? "
read PKGVER
set +e
echo " ${ PKGVER } " | egrep -Eq '^([0-9\.])+$'
if [ [ " ${ ? } " -ne '0' ] ] ;
then
echo "ERROR: That does not seem to be a valid package version!"
echo "Acceptable values are numbers or .'s."
exit
fi
set -e
echo
2016-06-24 18:47:32 -04:00
fi
2016-07-06 09:41:11 -04:00
# Get other bits of info.
# PKGDESC
2016-08-02 18:22:02 -04:00
echo -ne " What is a DESCRIPTION of ${ _PKGNAME } ? (Do not include the package name- e.g.:\n Provides a library for mutating teenage turtles\n): "
2016-07-06 09:41:11 -04:00
read PKGDESC
echo
# PKGURL
2016-08-02 18:22:02 -04:00
echo -n " What is the URL for ${ _PKGNAME } 's website? "
read PKGURL
echo
# SRCURL
2016-07-06 09:41:11 -04:00
if [ [ " ${ PKGTYPE } " = = 'vcs' ] ] ;
2016-06-24 18:47:32 -04:00
then
2016-07-06 09:41:11 -04:00
echo -ne " What is the CHECKOUT URL for ${ _PKGNAME } ?\n(Do not include the directory or VCS type prefix as per https://wiki.archlinux.org/index.php/VCS_package_guidelines#VCS_sources - this is added automatically) e.g.:\n https://github.com/shinnok/johnny.git\nURL: "
read SRCURL
echo
2016-08-02 18:22:02 -04:00
SRCURL = " ${ _PKGNAME } :: ${ VCSTYPE } + ${ SRCURL } "
2016-07-06 09:41:11 -04:00
SRCFILE = ''
else
echo -n " What is the URL to the source tarball for ${ PKGNAME } (version ${ PKGVER } )? "
read SRCURL
echo
SRCFILE = $( echo " ${ SRCURL } " | sed -re 's|^https?.*/(.*)$|\1|g' )
2016-06-24 18:47:32 -04:00
fi
2016-07-06 09:41:11 -04:00
# LICENSE
echo -n " What is the LICENSE for ${ _PKGNAME } ? "
read LICENSE
echo
# DEPENDS
echo -n " What does ${ _PKGNAME } DEPEND on (for runtime)? if no packages, just hit enter. Make sure they correspond to Arch/AUR package names. "
read PKGDEPS
echo
# OPTDEPENDS
echo -ne " What is an OPTIONAL DEPENDENCY (runtime) for ${ _PKGNAME } ? If no packages, just hit enter. They should match the format:\n pkgname:reason why\nOptional deps: "
read OPTDEPS
echo
echo -e " What is a MAKE DEPEND for ${ _PKGNAME } ? If no packages, just hit enter. "
read BUILDDEPS
echo
echo -e " What package names, if any besides itself, does ${ _PKGNAME } PROVIDE? (If a VCS package, do not include the non-VCS package- that's added by default!) "
read PROVIDES
echo
echo -e " What package names, if any besides itself, does ${ _PKGNAME } CONFLICT with? (If a VCS package, do not include the non-VCS package- that's added by default!) "
read CONFLICTS
echo
## SANITY ##
mkdir -p ${ PKGBUILD_DIR }
cd ${ PKGBUILD_DIR }
echo " Will create a package named ${ PKGNAME } . Press enter to continue, or ctrl-C to quit. "
2016-06-24 18:47:32 -04:00
read PKGCHK
## CREATE THE REPO/PACKAGE IN AUR ##
2016-06-26 03:42:30 -04:00
cd /tmp
2016-06-24 18:47:32 -04:00
git clone aur@aur.archlinux.org:${ PKGNAME }
2016-06-26 03:42:30 -04:00
cd /tmp/${ PKGNAME }
2016-07-06 09:41:11 -04:00
cp ${ AUR_PKGS_DIR } /_docs/PKGBUILD.templates.d/gitignore .gitignore
2016-06-26 03:42:30 -04:00
git add .gitignore
2016-06-24 18:47:32 -04:00
## DROP IN A VANILLA PKGBUILD ##
2016-07-06 09:41:11 -04:00
if [ [ " ${ PKGTYPE } " = = 'vcs' ] ] ;
2016-06-24 18:47:32 -04:00
then
2016-07-06 09:41:11 -04:00
cat ${ AUR_PKGS_DIR } /_docs/PKGBUILD.templates.d/vcs/{ 00.*,01.*,02.*,03.*,04.*.${ VCSTYPE } ,05.*,06.*} > PKGBUILD
2016-06-24 18:47:32 -04:00
else
2016-07-06 09:41:11 -04:00
cat ${ AUR_PKGS_DIR } /_docs/PKGBUILD.templates.d/release/* > PKGBUILD
touch " ${ SRCFILE } .sig "
2016-06-24 18:47:32 -04:00
fi
2016-08-02 18:22:02 -04:00
for i in MAINTNAME GPGKEY PKGNAME PKGVER PKGDESC PKGURL SRCURL LICENSE PKGDEPS OPTDEPS BUILDDEPS _PKGNAME SRCFILE;
2016-07-06 09:41:11 -04:00
do
NEWVAL = ${ !i }
#echo "${i} is ${NEWVAL}"
sed -i -re " s@%{2} ${ i } %{2}@ ${ NEWVAL } @g " PKGBUILD
done
2016-06-24 18:47:32 -04:00
2016-06-26 03:42:30 -04:00
# now we need to commit the thing since apparently we can't add empty repos as submodules...?
mksrcinfo
git add --all .
git commit -m "initial commit; setting up .gitignores and skeleton PKGBUILD"
git push origin master
cd /tmp
rm -rf ${ PKGNAME }
cd ${ PKGBUILD_DIR }
git submodule add --force aur@aur.archlinux.org:${ PKGNAME }
#git submodule init ${PKGNAME}
#git submodule update ${PKGNAME}
cd ${ PKGBUILD_DIR } /${ PKGNAME }
2016-06-24 18:47:32 -04:00
cat >> $( git rev-parse --git-dir) /hooks/pre-commit << EOF
#!/bin/bash
/usr/bin/mksrcinfo
git add .SRCINFO
EOF
chmod 700 $( git rev-parse --git-dir) /hooks/pre-commit