From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BB9B920248 for ; Mon, 1 Apr 2019 15:39:45 +0000 (UTC) Received: from localhost ([127.0.0.1]:57879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAz2F-0000q6-FY for normalperson@yhbt.net; Mon, 01 Apr 2019 11:39:43 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAz2A-0000pi-4V for bug-gnulib@gnu.org; Mon, 01 Apr 2019 11:39:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hAz27-0002S8-P6 for bug-gnulib@gnu.org; Mon, 01 Apr 2019 11:39:38 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::4]:12194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hAz26-0002Qm-Ji for bug-gnulib@gnu.org; Mon, 01 Apr 2019 11:39:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1554133170; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=4XR3VohjRuNcrx6ranKxZcAiCg+w+TLAJat9TgThnoY=; b=NJ+UXyZn+oGKmXQ6FGonHQt8X2RILIKAAzDgLwqVvGyVTODpr0kEfjpA/FOiV0HBjF 4PeeGE152XS8pmcBWXIY5OL5X9vABK1SREB/Hha4oHBmYy/MZySF6ZTW40gFb2diWWO4 uYEkRhj0WJHs/juJEBnqHiiiOyagvT5ZmuWyxmlLuX70j+xMAPRF99UbuhzJYtrm/m6l +1isE6PLSYDLnIs2cDQ1V0JWZC3PN9GtpElMt30/sxaFJWOaRu/xAQF/ARRcRc/wvrhp tk4edWHB26WftNQTPQ8daTvitatB5npLTLqLXAj0PtaKtVWOIX9SkJ4jBC9un3sfPtRI I7dA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOGKf3zZFW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.18 DYNA|AUTH) with ESMTPSA id N07172v31FdPd2H (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Mon, 1 Apr 2019 17:39:25 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: bootstrap/autogen.sh and git submodules Date: Mon, 01 Apr 2019 17:39:23 +0200 Message-ID: <4043031.t4FfOVeHZm@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <2684078.KdmCAigxga@omega> References: <2684078.KdmCAigxga@omega> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::4 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gary V. Vaughan" Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi, On 2019-03-03 I listed the problems that I have with the existing practices of using gnulib as a submodule. Here's my attempt to fix this for the packages I maintain (gettext, libunistring, etc.). It's a new script 'gitsub.sh'. The main point is a clear separation between git / version control related stuff (all in gitsub.sh) and regeneration of files (all in autogen.= sh). Tim R=FChsen wrote: > Make it so that existing build scripts don't have to be modified. E.g. > splitting bootstrap/autogen.sh into two commands is ok as long as the > original command invokes both (and thus being backwards compatible). I disagree, this is not realizable. But to care about this situation, I modify autogen.sh so that it exits with an error message *** Subdirectory 'gnulib' does not yet exist. Use './gitsub.sh pull' to c= reate it, or set the environment variable GNULIB_SRCDIR. when necessary. Here's the rewritten text from HACKING: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D Building off the Git repository =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D Access to the Git repository is described at https://savannah.gnu.org/git/?group=3Dgettext . After fetching the sources from the Git repository, peek at the comments in autogen.sh, then run ./gitsub.sh pull ./autogen.sh Then you can proceed with "./configure" as usual. Each time you want to update the source, do not only "git pull". Instead do git pull && ./gitsub.sh pull ./autogen.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D Here's the proposed gitsub.sh script (to be shared through gnulib, outside of any module, like 'bootstrap'): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D gitsub.sh =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #! /bin/sh # # Copyright (C) 2019 Free Software Foundation, Inc. # Written by Bruno Haible , 2019. # # 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 3 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, see . # Program that manages the subdirectories of a git checkout of a package # that come from other packages (called "dependency packages"). # # This program is similar in spirit to 'git submodule', with three # essential differences: # # 1) Its options are easy to remember, and do not require knowledge of # 'git submodule'. # # 2) The developer may choose to work on a different checkout for each # dependency package. This is important when the developer is # preparing simultaneous changes to the package and the dependency # package, or is using the dependency package in several packages. # # The developer indicates this different checkout by setting the # environment variable _SRCDIR (e.g. GNULIB_SRCDIR) to point t= o it. # # 3) The package maintainer may choose to use or not use git submodules. # # The advantages of management through a git submodule are: # - Changes to the dependency package cannot suddenly break your pac= kage. # In other words, when there is an incompatible change that will c= ause # a breakage, you can fix things at your pace; you are not forced = to # cope with such breakages in an emergency. # - When you need to make a change as a response to a change in the # dependency package, your co-developers cannot accidentally mix t= hings # up (for example, use a combination of your newest change with an # older version of the dependency package). # # The advantages of management without a git submodule (just as a plain # subdirectory, let's call it a "subcheckout") are: # - The simplicity: you are conceptually always using the newest rev= ision # of the dependency package. # - You don't have to remember to periodially upgrade the dependency. # Upgrading the dependency is an implicit operation. # This program is meant to be copied to the top-level directory of the pack= age, # together with a configuration file. The configuration is supposed to be # named '.gitmodules' and to define: # * The git submodules, as described in "man 5 gitmodules" or # . For example: # # [submodule "gnulib"] # url =3D git://git.savannah.gnu.org/gnulib.git # path =3D gnulib # # You don't add this piece of configuration to .gitmodules manually. Ins= tead, # you would invoke # $ git submodule add --name "gnulib" -- git://git.savannah.gnu.org/gnu= lib.git gnulib # # * The subdirectories that are not git submodules, in a similar syntax. F= or # example: # # [subcheckout "gnulib"] # url =3D git://git.savannah.gnu.org/gnulib.git # path =3D gnulib # # Here the URL is the one used for anonymous checkouts of the dependency # package. If the developer needs a checkout with write access, they can # either set the GNULIB_SRCDIR environment variable to point to that checko= ut # or modify the gnulib/.git/config file to enter a different URL. scriptname=3D"$0" scriptversion=3D'2019-04-01' nl=3D' ' IFS=3D" "" $nl" # func_usage # outputs to stdout the --help usage message. func_usage () { echo "\ Usage: gitsub.sh pull [SUBDIR] gitsub.sh upgrade [SUBDIR] gitsub.sh checkout SUBDIR REVISION Operations: gitsub.sh pull [SUBDIR] You should perform this operation after 'git clone ...' and after every 'git pull'. It brings your checkout in sync with what the other developers of your package have committed and pushed. If an environment variable _SRCDIR is set, with a non-empty value, nothing is done for this SUBDIR. If no SUBDIR is specified, the operation applies to all dependencie= s. gitsub.sh upgrade [SUBDIR] You should perform this operation periodically, to ensure currency of the dependency package revisions that you use. This operation pulls and checks out the changes that the developers of the dependency package have committed and pushed. If an environment variable _SRCDIR is set, with a non-empty value, nothing is done for this SUBDIR. If no SUBDIR is specified, the operation applies to all dependencie= s. gitsub.sh checkout SUBDIR REVISION Checks out a specific revision for a dependency package. If an environment variable _SRCDIR is set, with a non-empty value, this operation fails. This script requires the git program in the PATH and an internet connection. " } # func_version # outputs to stdout the --version message. func_version () { year=3D`echo "$scriptversion" | sed -e 's/^\(....\)-.*/\1/'` echo "\ gitsub.sh (GNU gnulib) $scriptversion Copyright (C) 2019-$year Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. " printf "Written by %s.\n" "Bruno Haible" } # func_fatal_error message # outputs to stderr a fatal error message, and terminates the program. # Input: # - scriptname name of this program func_fatal_error () { echo "$scriptname: *** $1" 1>&2 echo "$scriptname: *** Stop." 1>&2 exit 1 } # func_warning message # Outputs to stderr a warning message, func_warning () { echo "gitsub.sh: warning: $1" 1>&2 } # func_note message # Outputs to stdout a note message, func_note () { echo "gitsub.sh: note: $1" } # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Command-line option processing. mode=3D while test $# -gt 0; do case "$1" in --help | --hel | --he | --h ) func_usage exit $? ;; --version | --versio | --versi | --vers | --ver | --ve | --v ) func_version exit $? ;; -- ) # Stop option processing shift break ;; -* ) echo "gitsub.sh: unknown option $1" 1>&2 echo "Try 'gitsub.sh --help' for more information." 1>&2 exit 1 ;; * ) break ;; esac done if test $# =3D 0; then echo "gitsub.sh: missing operation argument" 1>&2 echo "Try 'gitsub.sh --help' for more information." 1>&2 exit 1 fi case "$1" in pull | upgrade | checkout ) mode=3D"$1" shift ;; *) echo "gitsub.sh: unknown operation '$1'" 1>&2 echo "Try 'gitsub.sh --help' for more information." 1>&2 exit 1 ;; esac if test $# =3D 2 && test $mode !=3D checkout || test $# -gt 2; then echo "gitsub.sh: too many arguments in '$mode' mode" 1>&2 echo "Try 'gitsub.sh --help' for more information." 1>&2 exit 1 fi if test $# =3D 0 && test $mode =3D checkout; then echo "gitsub.sh: too few arguments in '$mode' mode" 1>&2 echo "Try 'gitsub.sh --help' for more information." 1>&2 exit 1 fi # Read the configuration. # Output: # - subcheckouts space-separated list of subcheckout names # - submodules space-separated list of submodule names if test -f .gitmodules; then subcheckouts=3D`git config --file .gitmodules --get-regexp --name-only 's= ubcheckout\..*\.url' | sed -e 's/^subcheckout\.//' -e 's/\.url$//' | tr -d = '\r' | tr '\n' ' '` submodules=3D`git config --file .gitmodules --get-regexp --name-only 'sub= module\..*\.url' | sed -e 's/^submodule\.//' -e 's/\.url$//' | tr -d '\r' |= tr '\n' ' '` else subcheckouts=3D submodules=3D fi # func_validate SUBDIR # Verifies that the state on the file system is in sync with the declaratio= ns # in the configuration file. # Input: # - subcheckouts space-separated list of subcheckout names # - submodules space-separated list of submodule names # Output: # - srcdirvar Environment that the user can set # - srcdir Value of the environment variable # - path if $srcdir !=3D "": relative path of the subdi= rectory # - url if $srcdir !=3D "" and $path is not a director= y: # the repository URL func_validate () { srcdirvar=3D`echo "$1" | LC_ALL=3DC sed -e 's/[^a-zA-Z0-9]/_/g' | LC_ALL= =3DC tr '[a-z]' '[A-Z]'`"_SRCDIR" eval 'srcdir=3D$'"$srcdirvar" path=3D url=3D if test -n "$srcdir"; then func_note "Ignoring '$1' because $srcdirvar is set." else found=3Dfalse case " $subcheckouts " in *" $1 "*) found=3Dtrue # It ought to be a subcheckout. path=3D`git config --file .gitmodules "subcheckout.$1.path"` if test -z "$path"; then path=3D"$1" fi if test -d "$path"; then if test -d "$path/.git"; then # It's a plain checkout. : else if test -f "$path/.git"; then # It's a submodule. func_fatal_error "Subdirectory '$path' is supposed to be a plai= n checkout, but it is a submodule." else func_warning "Ignoring '$path' because it exists but is not a g= it checkout." fi fi else # The subdir does not yet exist. url=3D`git config --file .gitmodules "subcheckout.$1.url"` if test -z "$url"; then func_fatal_error "Property subcheckout.$1.url is not defined in .= gitmodules" fi fi ;; esac case " $submodules " in *" $1 "*) found=3Dtrue # It ought to be a submodule. path=3D`git config --file .gitmodules "submodule.$1.path"` if test -z "$path"; then path=3D"$1" fi if test -d "$path"; then if test -d "$path/.git"; then # It's a plain checkout. func_fatal_error "Subdirectory '$path' is supposed to be a submod= ule, but it is a plain checkout." else if test -f "$path/.git"; then # It's a submodule. : else func_warning "Ignoring '$path' because it exists but is not a g= it checkout." fi fi else # The subdir does not yet exist. url=3D`git config --file .gitmodules "submodule.$1.url"` if test -z "$url"; then func_fatal_error "Property submodule.$1.url is not defined in .gi= tmodules" fi fi ;; esac if ! $found; then func_fatal_error "Subdir '$1' is not configured as a subcheckout or a= submodule in .gitmodules" fi fi } # func_cleanup_current_git_clone # Cleans up the current 'git clone' operation. # Input: # - path func_cleanup_current_git_clone () { rm -rf "$path" func_fatal_error "git clone failed" } # func_pull SUBDIR # Implements the 'pull' operation. func_pull () { func_validate "$1" if test -z "$srcdir"; then case " $subcheckouts " in *" $1 "*) # It's a subcheckout. if test -d "$path"; then if test -d "$path/.git"; then (cd "$path" && git pull) || func_fatal_error "git operation faile= d" fi else # The subdir does not yet exist. Create a plain checkout. trap func_cleanup_current_git_clone 1 2 13 15 git clone "$url" "$path" || func_cleanup_current_git_clone trap - 1 2 13 15 fi ;; esac case " $submodules " in *" $1 "*) # It's a submodule. if test -d "$path"; then if test -f "$path/.git"; then # See https://stackoverflow.com/questions/1030169/easy-way-to-pul= l-latest-of-all-git-submodules # https://stackoverflow.com/questions/4611512/is-there-a-way-to-m= ake-git-pull-automatically-update-submodules git submodule update "$path" || func_fatal_error "git operation f= ailed" fi else # The subdir does not yet exist. Create a submodule checkout. git submodule init -- "$path" && git submodule update -- "$path" ||= func_fatal_error "git operation failed" fi ;; esac fi } # func_upgrade SUBDIR # Implements the 'upgrade' operation. func_upgrade () { func_validate "$1" if test -z "$srcdir"; then if test -d "$path"; then case " $subcheckouts " in *" $1 "*) # It's a subcheckout. if test -d "$path/.git"; then (cd "$path" && git pull) || func_fatal_error "git operation faile= d" fi ;; esac case " $submodules " in *" $1 "*) # It's a submodule. if test -f "$path/.git"; then (cd "$path" && git fetch && git merge origin/master) || func_fata= l_error "git operation failed" fi ;; esac else # The subdir does not yet exist. func_fatal_error "Subdirectory '$path' does not exist yet. Use 'gitsu= b.sh pull' to create it." fi fi } # func_checkout SUBDIR REVISION # Implements the 'checkout' operation. func_checkout () { func_validate "$1" if test -z "$srcdir"; then if test -d "$path"; then case " $subcheckouts " in *" $1 "*) # It's a subcheckout. if test -d "$path/.git"; then (cd "$path" && git checkout "$2") || func_fatal_error "git operat= ion failed" fi ;; esac case " $submodules " in *" $1 "*) # It's a submodule. if test -f "$path/.git"; then (cd "$path" && git checkout "$2") || func_fatal_error "git operat= ion failed" fi ;; esac else # The subdir does not yet exist. func_fatal_error "Subdirectory '$path' does not exist yet. Use 'gitsu= b.sh pull' to create it." fi fi } case "$mode" in pull ) if test $# =3D 0; then for subdir in $subcheckouts $submodules; do func_pull "$subdir" done else valid=3Dfalse for subdir in $subcheckouts $submodules; do if test "$subdir" =3D "$1"; then valid=3Dtrue fi done if $valid; then func_pull "$1" else func_fatal_error "Subdir '$1' is not configured as a subcheckout or= a submodule in .gitmodules" fi fi ;; upgrade ) if test $# =3D 0; then for subdir in $subcheckouts $submodules; do func_upgrade "$subdir" done else valid=3Dfalse for subdir in $subcheckouts $submodules; do if test "$subdir" =3D "$1"; then valid=3Dtrue fi done if $valid; then func_upgrade "$1" else func_fatal_error "Subdir '$1' is not configured as a subcheckout or= a submodule in .gitmodules" fi fi ;; checkout ) valid=3Dfalse for subdir in $subcheckouts $submodules; do if test "$subdir" =3D "$1"; then valid=3Dtrue fi done if $valid; then func_checkout "$1" "$2" else func_fatal_error "Subdir '$1' is not configured as a subcheckout or a= submodule in .gitmodules" fi ;; esac =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D Note: This script is not related nor derived from https://github.com/feluxe/gitsub . Comments welcome! Bruno