#!/bin/bash # # fblint for Frugalware # # Copyright (c) 2006, 2007, 2008, 2009 by Miklos Vajna # # 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # export LC_ALL="POSIX" myver="0.6.5" die() { echo "$0: $@" exit 1 } check() { [ "$_fblint_verbose" ] && echo -n "checking for $1... " eval $2 if [ "$?" = 0 ]; then [ "$_fblint_verbose" ] && echo "done." _fblint_done=$(($_fblint_done+1)) else [ ! "$_fblint_verbose" -a ! "$_fblint_quiet" ] && echo -n "checking for $1... " [ "$_fblint_quiet" ] || echo "failed." _fblint_failed=$(($_fblint_failed+1)) fi } get_root() { local i i=`git rev-parse --git-dir 2>/dev/null` if [ -n "$i" ]; then echo $(basename $(dirname $i)) _scm=git return fi i=`pwd` while true do if [ -e "$i/_darcs" ]; then break elif [ "$i" == "" ]; then break fi i=`echo $i|sed 's|\(.*\)/.*|\1|'` done echo $i _scm=darcs } # so that grep [A-Z] will reall match only uppercase letters unset LANG LC_ALL if [ "$1" = "--version" ]; then echo "fblint (pacman-tools) $myver" exit 0 fi if [ "$1" = "--help" ]; then man fblint exit 0 fi if [ "$1" = "-q" ]; then _fblint_quiet="y" shift 1 fi if [ "$1" = "-v" ]; then _fblint_verbose="y" shift 1 fi if [ "$1" = "-p" ]; then _fblint_fb="$2" else _fblint_fb="FrugalBuild" fi _fblint_done="0" _fblint_failed="0" CHROOT=1 . /usr/lib/frugalware/fwmakepkg . /etc/makepkg.conf [ "$_fblint_verbose" ] && echo -n "Checking if FrugalBuild exists ... " if [ -e $_fblint_fb ]; then [ "$_fblint_verbose" ] && echo "OK!" else echo "Error! File to check does not exist!" exit 1 fi check "no last modified line" "! grep -q -i '^# Last Modified: ' $_fblint_fb" check "sbu" "grep -i -q \"^# Compiling Time: [~0-9\.]\+ SBU$\" $_fblint_fb" check "maintainer" "grep -q '^# Maintainer: ' $_fblint_fb" check "syntax errors" "source $_fblint_fb" check "pkgname" "[ ! -z \"$pkgname\" ]" # fst is a special exception for chroot builds check "parent dir is the same as the first group" "[ $groups == `pwd|sed 's|.*/\(.*\)/.*|\1|'` -o tmp == `pwd|sed 's|.*/\(.*\)/.*|\1|'` ]" check "dirname is the same as pkgname" "[ $pkgname == `pwd|sed 's|.*/||'` -o fst == `pwd|sed 's|.*/||'` ]" check "uppercase letters in pkgname" "! echo $pkgname | grep -q '[A-Z]'" check "pkgver" "[ ! -z \"$pkgver\" ]" check "hyphen-less pkgver" "[ ! `echo $pkgver | grep '-'` ]" check "pkgrel" "[ ! -z "$pkgrel" ]" check "hyphen-less pkgrel" "[ ! `echo $pkgrel | grep '-'` ]" check "pkgdesc" "[ ! -z \"$pkgdesc\" ]" check "url" "[ ! -z \"$url\" ]" check "depends" "[ ! -z \"$depends\" -o ! -z \"$rodepends\" ] || set|grep -q ^depends=" check "buggy empty depends" "[ ! -z \"$depends\" -o ${#depends[@]} == 0 ]" check "groups" "[ ! -z \"$groups\" ]" # this var is used internally by gensync/updatesync, FBs should not deal # with it check "empty option" "[ -z \"$option\" ]" check "valid first group" "! echo $groups |grep -q -- - || echo $groups|grep -q -- -extra$" check "valid options()" "[ -z \"$(echo ${options[@]}|tr ' ' '\n' |grep -v '\(nodocs\|nostrip\|force\|nobuild\|nofakeroot\|scriptlet\|stick\|nomirror\|noversrc\)')\" ]" check "archs" "[ ! -z \"$archs\" ]" check "up2date" "test -n \"`echo $up2date|sed 's/\$(/\\\\\$(/g'`\"" _fblint_have_remote_source=n for i in ${source[@]} do if echo $i|grep -q ://; then _fblint_have_remote_source=y else check "not downloadable file $i is added to the repo" "git ls-files |grep -q $i" fi done if [ "$_fblint_have_remote_source" = "y" ]; then check "md5sums/sha1sums/signatures" "[ ${#md5sums[@]} -gt 0 -o ${#sha1sums[@]} -gt 0 -o ${#signatures[@]} -gt 0 ]" fi if [ ${#md5sums[@]} -gt 0 ]; then check "right number of md5sums" "[ ${#md5sums[@]} -eq ${#source[@]} ]" fi if [ ${#sha1sums[@]} -gt 0 ]; then check "the need of sha1sums (they are not needed when signatures present)" "[ ${#signatures[@]} -eq 0 ]" check "right number of sha1sums" "[ ${#sha1sums[@]} -eq ${#source[@]} ]" fi if [ ${#signatures[@]} -gt 0 ]; then check "right number of signatures" "[ ${#signatures[@]} -eq ${#source[@]} ]" fi if [ ! -z "$subpkgs" ]; then for subpkg in "${subpkgs[@]}" do check "uppercase letters in subpkgs" "! echo $subpkg | grep -q [A-Z]" done check "subdescs" "[ ! -z \"$subdescs\" ]" check "subgroups" "[ ! -z \"$subgroups\" ]" check "subarchs" "[ ! -z \"$subarchs\" ]" check "right number of subdescs" "[ \"${#subdescs[@]}\" = 0 ] || [ \"${#subdescs[@]}\" == \"${#subpkgs[@]}\" ]" check "right number of sublicense" "[ \"${#sublicense[@]}\" = 0 ] || [ \"${#sublicense[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subreplaces" \ "[ \"${#subreplaces[@]}\" = 0 ] || [ \"${#subreplaces[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subgroups" "[ \"${#subgroups[@]}\" = 0 ] || [ \"${#subgroups[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subarchs" "[ \"${#subarchs[@]}\" = 0 ] || [ \"${#subarchs[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subdepends" "[ \"${#subdepends[@]}\" = 0 ] || [ \"${#subdepends[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subrodepends" \ "[ \"${#subrodepends[@]}\" = 0 ] || [ \"${#subrodepends[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subremoves" "[ \"${#subremoves[@]}\" = 0 ] || [ \"${#subremoves[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subconflicts" \ "[ \"${#subconflicts[@]}\" = 0 ] || [ \"${#subconflicts[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subprovides" \ "[ \"${#subprovides[@]}\" = 0 ] || [ \"${#subprovides[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subbackup" "[ \"${#subbackup[@]}\" = 0 ] || [ \"${#subbackup[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of subinstall" "[ \"${#subinstall[@]}\" = 0 ] || [ \"${#subinstall[@]}\" = \"${#subpkgs[@]}\" ]" check "right number of suboptions" "[ \"${#suboptions[@]}\" = 0 ] || [ \"${#suboptions[@]}\" = \"${#subpkgs[@]}\" ]" fi codename=$(sed 's/.*(\(.*\))/\1/' /etc/frugalware-release|tr '[A-Z]' '[a-z]') if [ "`get_root`" = "stable" -o "`get_root`" = "$codename" ]; then check "unchanged pkgrel" "echo $pkgrel | grep -q '$codename'" fi check "trailing whitespace" "! grep -q ' $' $_fblint_fb" [ "$_fblint_verbose" ] && echo "done: $_fblint_done, failed $_fblint_failed" if [ $_fblint_failed -gt 0 ]; then exit 1 else exit 0 fi