From 8a0733b930a5f1c13321b08981b06262edad78ce Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 26 Feb 2023 20:55:09 -0800 Subject: [PATCH] Use spread-sheet-widget from Git master for flatpak build, too. --- build-pspp | 182 ++++++++++++++++++++++++++--------------------- org.gnu.pspp.yml | 5 +- 2 files changed, 104 insertions(+), 83 deletions(-) diff --git a/build-pspp b/build-pspp index d6ffcceb18..09a0e89c37 100755 --- a/build-pspp +++ b/build-pspp @@ -27,6 +27,7 @@ where TARBALL is the name of a tarball produced by "make dist" Options: --help Print this usage message and exit + --ssw=TARBALL Get ssw from TARBALL instead of from Git. --no-binary Build source tarballs but no binaries. --batch Do not print progress to stdout. --no-perl Do not build Perl module.""" @@ -164,6 +165,83 @@ def ref_to_commit(ref, repo='.'): return backquotes("cd %s && %s rev-parse %s" % (repo, GIT, ref)) +def add_commit_to_version(name, commit, dir, extra_news = None): + abbrev_commit = commit[:6] + + # Extract version number. + start_step("Extract %s repository version number" % name) + fields = backquotes("cd %s && autoconf -t AC_INIT" % dir).split(':') + file, line, macro, package, repo_version = fields[:5] + rest = fields[5:] + set_var("%s_repo_version" % name, repo_version) + + # Is this a "gnits" mode tree? + start_step("Checking %s Automake mode" % name) + + am_mode = "gnu" + for s in open("%s/Makefile.am" % dir): + if "gnits" in s: + am_mode = "gnits" + break + LOG.write("%s Automake mode is %s\n" % (name, am_mode)) + + # Generate version number for build. + # We want to append -g012345, but if we're in Gnits mode and the + # version number already has a hyphen, we have to omit it. + start_step("Generate %s build version number" % name) + version = repo_version + if '-' not in version: + version += '-' + version += 'g' + abbrev_commit + set_var("%s_version" % name, version) + + # Append -g012345 to configure.ac version number. + start_step("Updating %s version number in %s" % (name, file)) + fullname = "%s/%s" % (dir, file) + NEWFILE = open("%s.new" % fullname, "w") + ln = 1 + for s in open(fullname): + if ln != int(line): + NEWFILE.write(s) + else: + NEWFILE.write("AC_INIT([%s], [%s]" % (package, version)) + for field in rest: + NEWFILE.write(", [%s]" % field) + NEWFILE.write(")\n") + ln += 1 + NEWFILE.close() + os.rename("%s.new" % fullname, fullname) + + # Add note to beginning of NEWS (otherwise "make dist" fails). + start_step("Updating %s NEWS" % name) + fullname = "%s/NEWS" % name + NEWFILE = open("%s.new" % fullname, "w") + found_changes = False + for s in open(fullname): + if not found_changes and (s.startswith('Changes') or repo_version in s): + found_changes = True + NEWFILE.write("""\ +Changes from %(repo_version)s to %(version)s: + + * Built from PSPP commit %(revision)s + in branch %(branch)s on builder %(builder)s. + +""" + % {'repo_version': repo_version, + 'version': version, + 'revision': commit, + 'branch': branch, + 'builder': builder}) + if extra_news: + NEWFILE.write(extra_news) + NEWFILE.write('\n') + + NEWFILE.write(s) + NEWFILE.close() + os.rename("%s.new" % fullname, fullname) + + return version + try: opts, args = getopt.gnu_getopt(sys.argv[1:], "ho:", ["help", @@ -171,6 +249,7 @@ try: "batch", "no-batch", "no-perl", "output=", + "ssw=", "builder=", "build-number="]) except getopt.GetoptError as err: # print help information and exit: @@ -183,6 +262,7 @@ builddir = None build_number = None builder = None build_perl = True +ssw = "https://git.savannah.gnu.org/git/ssw.git master" for o, a in opts: if o in ("-h", "--help"): print_usage() @@ -202,6 +282,8 @@ for o, a in opts: build_number = a elif o == "--no-perl": build_perl = False + elif o == "--ssw": + ssw = a else: assert False, "unhandled option" if builder is None: @@ -251,9 +333,6 @@ set_var("build_number", build_number) GIT = "git --git-dir=%s/.git" % topdir -# ssw = "https://alpha.gnu.org/gnu/ssw/spread-sheet-widget-0.4.tar.gz" -ssw = "https://git.savannah.gnu.org/git/ssw.git master" - if ssw.endswith('.tar.gz'): ssw_basename = os.path.basename(ssw) ssw_file = '%s/%s' % (topdir, ssw_basename) @@ -267,9 +346,6 @@ if len(args) == 2: if not Path(ssw_file).exists(): start_step("Retrieve spread-sheet-widget tarball %s" % ssw_file) run("wget -O %s %s" % (ssw_file, ssw)) - - start_step("Extract %s into %s" % (ssw_file, ssw_dir)) - run("tar xzf %s" % ssw_file) elif ' ' in ssw: ssw_url, ssw_ref = ssw.split() @@ -278,13 +354,29 @@ if len(args) == 2: start_step("Check out %s in ssw" % ssw_ref) run("cd %s && git checkout %s" % (ssw_dir, ssw_ref)) - set_var("ssw_commit", ref_to_commit("HEAD", "ssw")) + ssw_commit = ref_to_commit("HEAD", "ssw") + set_var("ssw_commit", ssw_commit) + + ssw_version = add_commit_to_version("ssw", ssw_commit, "ssw") start_step("Bootstrap ssw") - run("cd %s && ./bootstrap" % ssw_dir) + run("cd ssw && ./bootstrap") + + start_step("Configure ssw source") + run("cd ssw && mkdir _build && cd _build && ../configure", + "configure") + + start_step("Make ssw source tarball") + run("cd ssw/_build && make -j128 dist", "dist") + ssw_dir = "spread-sheet-widget-%s" % ssw_version + ssw_file = "ssw/_build/%s.tar.gz" % ssw_dir + save_result("ssw source distribution", ssw_file) else: assert False + start_step("Extract %s into %s" % (ssw_file, ssw_dir)) + run("tar xzf %s" % ssw_file) + start_step("Configure spread-sheet-widget") run("cd %s && ./configure --prefix=''" % ssw_dir) @@ -304,57 +396,12 @@ if len(args) == 2: set_var("pspp_ref", "refs/builds/%s/pspp" % build_number) revision = ref_to_commit("refs/builds/%s/pspp" % build_number) set_var("pspp_commit", revision) - abbrev_commit = revision[:6] # Extract source. start_step("Extract branch into source directory") run("%s archive --format=tar --prefix=pspp/ refs/builds/%s/pspp | tar xf -" % (GIT, build_number)) - # Extract version number. - start_step("Extract repository version number") - fields = backquotes("cd pspp && autoconf -t AC_INIT").split(':') - file, line, macro, package, repo_version = fields[:5] - rest = fields[5:] - set_var("repo_version", repo_version) - - # Is this a "gnits" mode tree? - start_step("Checking Automake mode") - - am_mode = "gnu" - for s in open("pspp/Makefile.am"): - if "gnits" in s: - am_mode = "gnits" - break - LOG.write("Automake mode is %s\n" % am_mode) - - # Generate version number for build. - # We want to append -g012345, but if we're in Gnits mode and the - # version number already has a hyphen, we have to omit it. - start_step("Generate build version number") - version = repo_version - if '-' not in version: - version += '-' - version += 'g' + abbrev_commit - set_var("version", version) - - # Append -g012345 to configure.ac version number. - start_step("Updating version number in %s" % file) - fullname = "pspp/%s" % file - NEWFILE = open("%s.new" % fullname, "w") - ln = 1 - for s in open(fullname): - if ln != int(line): - NEWFILE.write(s) - else: - NEWFILE.write("AC_INIT([%s], [%s]" % (package, version)) - for field in rest: - NEWFILE.write(", [%s]" % field) - NEWFILE.write(")\n") - ln += 1 - NEWFILE.close() - os.rename("%s.new" % fullname, fullname) - # Get Gnulib commit number. start_step("Reading README.Git to find Gnulib commit number") fullname = "pspp/README.Git" @@ -370,33 +417,8 @@ if len(args) == 2: sys.exit(1) set_var("gnulib_commit", gnulib_commit) - # Add note to beginning of NEWS (otherwise "make dist" fails). - start_step("Updating NEWS") - fullname = "pspp/NEWS" - NEWFILE = open("%s.new" % fullname, "w") - found_changes = False - for s in open(fullname): - if not found_changes and s.startswith('Changes'): - found_changes = True - NEWFILE.write("""\ -Changes from %(repo_version)s to %(version)s: - - * Built from PSPP commit %(revision)s - in branch %(branch)s on builder %(builder)s. - - * Built from Gnulib commit %(gnulib_commit)s. - -""" - % {'repo_version': repo_version, - 'version': version, - 'revision': revision, - 'branch': branch, - 'builder': builder, - 'gnulib_commit': gnulib_commit}) - - NEWFILE.write(s) - NEWFILE.close() - os.rename("%s.new" % fullname, fullname) + version = add_commit_to_version("pspp", revision, "pspp", + " * Built from Gnulib commit %(gnulib_commit)s.\n") # If we don't already have that Gnulib commit, update Gnulib. rc = os.system("%s rev-parse --verify --quiet %s^0 > /dev/null" diff --git a/org.gnu.pspp.yml b/org.gnu.pspp.yml index 2d66919f08..ee1428adab 100644 --- a/org.gnu.pspp.yml +++ b/org.gnu.pspp.yml @@ -18,8 +18,7 @@ modules: buildsystem: autotools sources: - type: archive - url: https://alpha.gnu.org/gnu/ssw/spread-sheet-widget-0.8.tar.gz - sha256: 8589d8298fcf3b5850d0968b04801a4f40faf0555544f6cc9d954b0162e9954b + path: SSW_SOURCE_PATH - name: gsl buildsystem: autotools sources: @@ -30,7 +29,7 @@ modules: buildsystem: simple sources: - type: archive - path: SOURCE_PATH + path: PSPP_SOURCE_PATH dest: pspp build-commands: - cd pspp && ./configure --prefix=/app --libdir=/app/lib && make -j$(nproc) && make -j$(nproc) install -- 2.30.2