scripts/src/new-ebuild

92 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# This file is part of scripts.
# scripts 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.
# scripts 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 scripts. If not, see <https://www.gnu.org/licenses/>.
# Original author: Maciej Barć (xgqt@protonmail.com)
# Copyright (c) 2020, src_prepare group
# Licensed under the GNU GPL v3 License
# shellcheck disable=2016
trap 'exit 128' INT
export PATH
ebuild_template='# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
DESCRIPTION=""
HOMEPAGE=""
if [[ "${PV}" == *9999* ]]; then
inherit git-r3
EGIT_REPO_URI=""
else
SRC_URI=""
KEYWORDS="~amd64"
fi
RESTRICT="
mirror
!test? ( test )
"
LICENSE=""
SLOT="0"
IUSE="test"
BDEPEND=""
DEPEND=""
RDEPEND=""'
metadata_template='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
</pkgmetadata>'
main() {
ebuild="$(basename "$(pwd)")-9999.ebuild"
if [ ! -f "${ebuild}" ]
then
echo "${ebuild_template}" > "${ebuild}"
else
echo "Already exists: ${ebuild}"
fi
if [ ! -f "metadata.xml" ]
then
echo "${metadata_template}" > "metadata.xml"
else
echo "Already exists: metadata.xml"
fi
}
if [ -f ../../profiles/repo_name ]
then
main
else
echo "Are you in a overlay repo?"
echo "To use this script successfully:"
echo "1. Create a \${CATEGOTY}/\${PN} directory"
echo "2. Change directory to it"
echo "3. Execute ${0}"
exit 1
fi