From nobody Mon Jan 16 21:07:30 2023 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Nwl366m7Xz2p99L; Mon, 16 Jan 2023 21:07:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Nwl3667YCz41L4; Mon, 16 Jan 2023 21:07:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673903250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C0/bTVBEHPZyBMt9OEQ+O18eJbn5xJjPHNCtKpgM5+w=; b=IaCGjy7lEGCmPgrcR7+X07tm/+mfVQduT+Apd/FCiIdod7LVGx1Tnx4X0uETbML76gqX/+ 8IEQ+Stpym66Vg5SNz/qqVso0DhN+LC1WTEX0vGL6F3r3rC+/R8txw5JtIvpRMvllNt3Td GERM8pQJ7SXK/WozJM/2Lt61S7oy4YMshApaisvEGbUrIDFtuW3btQl+u5Tr6og6YiHNIX C14XukErBVJaegL4GQk+7Ci1r1stxsm/wDHbSjMqfJIeoj+NnXFACwwFTGZAlIMOxzKWB0 4ouXvxzdDTEub/M80Y1yIEJ526/CTpXdkQ8sLCDZMUjl8eVhIp3H+zRXmGbo/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673903250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C0/bTVBEHPZyBMt9OEQ+O18eJbn5xJjPHNCtKpgM5+w=; b=jyEvueMqYgbJSj7YFjdpIo1kCCdj/AvO2gnGuqlwwR2MdCRMQlU+67BJN74Z13GJXTQVLh nFekLklzXLlfX36bXsv4uNBlYvmc5D0uC1Epf0QqfSl1VmnZ82zMD6Vek0eCIYDQ4ZkfXz TEFc+S+3O6PHLjok2pgMYROZg5urhhGgDVoWgdIpt1rDvF0huoKdnXws6NxLox4fRNnmDZ W360Rd9fal7Dxk0HfPGm6o7+/IIFsfi1fTXHCzDjoOZl4sXqQWVzS532nAfglFFyZpC/ZR sIaMqKUWAYhycV4UweF5m8i6rU/yCr2BrqxUO0j4oP4W3W36A3gW2QHzAis8+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673903250; a=rsa-sha256; cv=none; b=EFfCnXDQaIJ1E4QnTP3Nj8/W2ThPs6msVJHE6S7cV8MoQEYEZTyeJbtunh3q5YNu+6om+Y sbUvuFet7OgvfzSU3P7pv5vhcVCpu+fqwF+uGdk0VsQWBxKHtJ01kNM+pkcmMFISrxqV9C 5/Xuwp7SNT8+GfAtcEj8LrQVmu4E2xGQw69qviMq3hF33VFuzkwJ4rFB1l5kLo7B6u9nmX TRKNvHS+tcEFI+NzDgz71yB9QhSR2EH6IXI2r9DxocmyREBZIv284rbfsdW+4l+lsjX/5I y61VQHYSH1oPuWVSqqxX8e1eETan9vpCL2R0fW98ybKNdeNh/D2t1rjPcJsROQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Nwl365Ckzz1LRG; Mon, 16 Jan 2023 21:07:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30GL7Uno009516; Mon, 16 Jan 2023 21:07:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30GL7UsE009515; Mon, 16 Jan 2023 21:07:30 GMT (envelope-from git) Date: Mon, 16 Jan 2023 21:07:30 GMT Message-Id: <202301162107.30GL7UsE009515@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: 1eba137b81f9 - main - Tools/scripts: Add add-port-to-category-makefile.sh, command that adds new port to category's Makefile List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1eba137b81f9c3e322da49764244d17c5c7c59b2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=1eba137b81f9c3e322da49764244d17c5c7c59b2 commit 1eba137b81f9c3e322da49764244d17c5c7c59b2 Author: Yuri Victorovich AuthorDate: 2023-01-16 20:56:41 +0000 Commit: Yuri Victorovich CommitDate: 2023-01-16 21:07:27 +0000 Tools/scripts: Add add-port-to-category-makefile.sh, command that adds new port to category's Makefile PR: 268737 --- Tools/scripts/add-port-to-category-makefile.sh | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Tools/scripts/add-port-to-category-makefile.sh b/Tools/scripts/add-port-to-category-makefile.sh new file mode 100755 index 000000000000..691b21fff996 --- /dev/null +++ b/Tools/scripts/add-port-to-category-makefile.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# MAINTAINER: yuri@FreeBSD.org + +PORT="$1" + +set -e +set -o pipefail + +## +## add-port-to-category-makefile.sh: adds a new port to {category}/Makefile +## + + +# sanity checks +[ -z "$PORT" ] && echo "this command requires the argument" && exit 1 +(echo "$PORT" | grep -q "/") && echo "port's name can't contain slash" && exit 1 +! [ -f Makefile ] && echo "no Makefile found, are you in the ports tree?" && exit 1 +! grep -q "^ SUBDIR += " Makefile && echo "this command can only be run from the ports tree category directory" && exit 1 +! grep -q "^\\.include $" Makefile && echo "this command can only be run from the ports tree category directory" && exit 1 +! [ -d "$PORT" ] && echo "the '$PORT' directory is missing" && exit 1 +! [ -f "$PORT/Makefile" ] && echo "'$PORT/Makefile' is missing" && exit 1 +grep -q "^ SUBDIR += $PORT$" Makefile && echo "port '$PORT' is already added" && exit 1 + + +# add port to Makefile +/usr/bin/awk ' +BEGIN { + done = 0 + seen = 0 + str = " SUBDIR += '$PORT'" +} +/^ SUBDIR \+= / { + if (!done && str < $0) { + print str + done = 1 + } + print $0; + seen = seen + 1 +} +!/^ SUBDIR \+= / { + if (seen > 0 && !done) { + print str + done = 1 + } + print $0 +}' < Makefile > Makefile.new && +/bin/mv Makefile.new Makefile