mirror of
https://github.com/clearlinux/common.git
synced 2026-06-16 11:06:15 +00:00
Compare commits
129 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0c61628a8 | |||
| c858d8c2e1 | |||
| 450e84f809 | |||
| d36cb4c6c3 | |||
| 139a6e4a14 | |||
| 37bda022bb | |||
| ddc326e53c | |||
| a3a27cd156 | |||
| 4579fa3816 | |||
| c14cac39e5 | |||
| 070be802aa | |||
| 4102816787 | |||
| 4c9c2abd21 | |||
| 70b4977b53 | |||
| 7276bc89e9 | |||
| fffa8f1e78 | |||
| 9cc15023ed | |||
| 7f5674bf08 | |||
| de60634e85 | |||
| 2b6b201866 | |||
| b24f00531c | |||
| bf4c541b1d | |||
| 25ea756641 | |||
| 367aa5c4de | |||
| 073d828fa2 | |||
| ce049d2064 | |||
| c2d67c1502 | |||
| 98cf84d3f3 | |||
| 2c3c1225bf | |||
| 65dcbd3bc9 | |||
| 76ae6fd76f | |||
| 69164ec2ca | |||
| 185dec68b8 | |||
| cc9b2ee03b | |||
| 0b9161a6d7 | |||
| 7c92a06cb9 | |||
| 214ace3bd0 | |||
| 8d82f1d245 | |||
| b250cfe2b0 | |||
| c7eae41e54 | |||
| 55a3d9c6bf | |||
| 41ed095a08 | |||
| 7a653585b2 | |||
| 8ffb3603dc | |||
| b895daa84f | |||
| 48fbe7cd3e | |||
| 39aed7cee7 | |||
| 23c281b1c8 | |||
| d402ae1449 | |||
| 72cc059f89 | |||
| 0d56579421 | |||
| 02d46e6db4 | |||
| 4adb7a1524 | |||
| be21e942aa | |||
| 4e9b844267 | |||
| facb8827f7 | |||
| 77c5172cf9 | |||
| ae4ea46b1c | |||
| 8e18acca7a | |||
| ed15af71c8 | |||
| 3c20fc2ad8 | |||
| d7f6ddcce1 | |||
| 22a927e26b | |||
| 4a29a2d5c1 | |||
| 81ef638151 | |||
| 50b8b07d34 | |||
| 47b634bc75 | |||
| 292ea0bde9 | |||
| b0f7bbfb90 | |||
| 20d0fece07 | |||
| 0f546b20f5 | |||
| 16a09f7fa6 | |||
| 5a438328f2 | |||
| 9ffb55be69 | |||
| af3c84505d | |||
| a865a99283 | |||
| 9e8f0a6ff0 | |||
| 76301d4b78 | |||
| 08bef91443 | |||
| 93202eb3b5 | |||
| 14977f527c | |||
| fa93c354e1 | |||
| 6a54f15cb6 | |||
| fa42020aa9 | |||
| a727fe3722 | |||
| c41eeea37a | |||
| a07f64294f | |||
| 59a3a29c4c | |||
| cba91e5044 | |||
| a5d39507cc | |||
| dc644c29a0 | |||
| f5febd9cd6 | |||
| 33911b18e5 | |||
| 13e5e26cbf | |||
| 4845303ae6 | |||
| 6fdc492121 | |||
| 7614474aba | |||
| 5bee2e96d2 | |||
| 6cc08f74e7 | |||
| 5b64c9b888 | |||
| 88c420528d | |||
| 98c7c4cb76 | |||
| e2ce4353b6 | |||
| 08512d3f2b | |||
| f6be3f440a | |||
| 1a79ab1700 | |||
| a6fa6599bb | |||
| 9d6c5e6677 | |||
| 460ce05217 | |||
| 8a2da3412d | |||
| 94624262ae | |||
| 15a220803f | |||
| 4130c1c97d | |||
| 7c28f0608d | |||
| 1b0945c33d | |||
| 1300eba2b4 | |||
| 91a900675e | |||
| b137543491 | |||
| bb27567407 | |||
| 2973364b2e | |||
| 865997ad69 | |||
| 70bfbe8c17 | |||
| 3b1e4e5558 | |||
| 2465219907 | |||
| 77775f060c | |||
| 67406f7be2 | |||
| 9bece241c0 | |||
| 602cc9563f | |||
| 02b5ad93e3 |
+33
-12
@@ -49,13 +49,6 @@ spdxcheck: $(SPECFILE)
|
||||
if ! grep -qx "$$LICENSE" $(TOPLVL)/projects/common/licenses-{spdx,exceptions,extra}; then FAIL=yes; echo "ERROR: License '$$LICENSE' is not an allowed SPDX license ID"; fi; \
|
||||
done; test -z "$$FAIL"
|
||||
|
||||
#help cvecheck: Checks
|
||||
#help for common vulnerabilities and exposures in your package.
|
||||
cvecheck:
|
||||
# https://github.com/ikeydoherty/cve-check-tool
|
||||
# Installation: https://github.com/ikeydoherty/cve-check-tool/wiki
|
||||
cve-check-tool -M $(TOPLVL)/projects/common/mapping $(SPECFILE)
|
||||
|
||||
#help clean: Cleans up the src.rpm file. but not the rpm files or log files.
|
||||
clean:
|
||||
rm -f $(SRPMFILE)
|
||||
@@ -143,6 +136,10 @@ pullrebase:
|
||||
echo "No commits exist in remote. Continuing."; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
if [ "$$(git rev-list FETCH_HEAD | head -n 1)" = "$$(git rev-list HEAD | head -n 1)" ]; then \
|
||||
echo "Current branch up-to-date. Continuing."; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
echo "Rebasing to origin/master"; \
|
||||
if git status --porcelain | grep -q '^.[^?]'; \
|
||||
then \
|
||||
@@ -175,9 +172,11 @@ autospec: preautospec-checks pullrebase localreponotice clean-old-content
|
||||
--name $(PKG_NAME) \
|
||||
--archives $(ARCHIVES) \
|
||||
--mock-config $(MOCK_CONFIG_VAL) \
|
||||
--mock-opts "$(MOCK_OPTS)" \
|
||||
--mock-opts="$(MOCK_OPTS)" \
|
||||
$${SETVERSION:+ --version $${SETVERSION}} \
|
||||
${NON_INTERACTIVE} ${SKIP_GIT} ${CLEANUP} \
|
||||
$${NON_INTERACTIVE:+ --non_interactive} \
|
||||
$${SKIP_GIT:+ --skip-git} \
|
||||
$${CLEANUP:+ -C} \
|
||||
$(firstword $(NEWURL) $(URL));
|
||||
$(MAKE) link-new-rpms PKG_REPO_DIR="."
|
||||
@$(MAKE) spdxcheck
|
||||
@@ -202,12 +201,12 @@ for-review.txt:
|
||||
|
||||
#help autospecnogit: Runs autospec, but does not create a commit
|
||||
autospecnogit:
|
||||
$(MAKE) SKIP_GIT=--skip-git autospec
|
||||
$(MAKE) autospec SKIP_GIT=1
|
||||
|
||||
#help autospecnostate: Runs autospec, but cleans up mock chroots
|
||||
#help and disables interactive mode.
|
||||
autospecnostate:
|
||||
$(MAKE) CLEANUP=-C NON_INTERACTIVE=--non_interactive autospec
|
||||
$(MAKE) autospec CLEANUP=1 NON_INTERACTIVE=1
|
||||
|
||||
scanlicense:
|
||||
python3 $(TOPLVL)/projects/autospec/autospec/autospec.py -t . --config $(AUTOSPEC_CONF) --license-only $(firstword $(NEWURL) $(URL)) --name $(PKG_NAME)
|
||||
@@ -216,7 +215,7 @@ scanlicense:
|
||||
bump:
|
||||
git pull --rebase
|
||||
$(MAKE) bumpnogit
|
||||
git add *.spec release
|
||||
git add $(SPECFILE) release
|
||||
git commit -a -m "version bump from $(shell rpmspec -D '_vendor clr' --srpm -q --queryformat '%{VERSION}-%{RELEASE}\n' $(SPECFILE)) to `rpmspec -D '_vendor clr' --srpm -q --queryformat '%{VERSION}-%{RELEASE}\n' $(SPECFILE)`"
|
||||
|
||||
#help bumpnogit: Increments the release file by one and does not commit changes.
|
||||
@@ -374,6 +373,28 @@ repoadd: $(TOPLVL)/repo
|
||||
$(MAKE) localrepocreate
|
||||
$(call localrepoenable,${PM_CONF},${MOCK_CONF})
|
||||
|
||||
#help repostage: Stages locally-built RPMs for this package to the local RPM
|
||||
#help directory. If this directory does not yet exist, it is created and
|
||||
#help enabled.
|
||||
repostage: $(TOPLVL)/repo
|
||||
@if [ -z "${LATEST_RPMS}" ]; then \
|
||||
echo "No rpms found in rpms/ directory."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if [ -f .repo-index ]; then \
|
||||
echo "Cleaning old rpms:"; \
|
||||
for r in `cat .repo-index`; do \
|
||||
echo "-$$r"; \
|
||||
rm -f $(TOPLVL)/repo/$$r; \
|
||||
done; \
|
||||
rm .repo-index; \
|
||||
fi; \
|
||||
for r in ${LATEST_RPMS}; do \
|
||||
echo "+$$r"; \
|
||||
echo $$(basename $$r) >> .repo-index; \
|
||||
ln -f $$r $(TOPLVL)/repo/; \
|
||||
done
|
||||
|
||||
#help repodel: Removes RPMs from the local RPM repository that were
|
||||
#help previously added by 'make repoadd' for this package.
|
||||
repodel:
|
||||
|
||||
+2
-2
@@ -68,10 +68,10 @@ endef
|
||||
# augmented for local repo support.
|
||||
define localrepoenable
|
||||
@cp $(1) $(TOPLVL)/repo/yum.conf
|
||||
@printf "\n\n[local]\nname=Local\nfailovermethod=priority\nenabled=1\ngpgcheck=0\n" >> $(TOPLVL)/repo/yum.conf
|
||||
@printf "\n\n[local]\nname=Local\nfailovermethod=priority\nenabled=1\ngpgcheck=0\npriority=1\n" >> $(TOPLVL)/repo/yum.conf
|
||||
@printf "baseurl=file://$$(realpath $(TOPLVL))/repo/\n\n" >> $(TOPLVL)/repo/yum.conf
|
||||
@cp $(2) $(TOPLVL)/repo/clear.cfg
|
||||
@printf "\n\n[localrepo]\nname=Local repo\nfailovermethod=priority\nenabled=1\ngpgcheck=0\n" >> $(TOPLVL)/repo/clear.cfg
|
||||
@printf "\n\n[localrepo]\nname=Local repo\nfailovermethod=priority\nenabled=1\ngpgcheck=0\npriority=1\n" >> $(TOPLVL)/repo/clear.cfg
|
||||
@printf "baseurl=file://$$(realpath $(TOPLVL))/repo/\n\n" >> $(TOPLVL)/repo/clear.cfg
|
||||
@sed -i '/^"""/d; $$a"""' $(TOPLVL)/repo/clear.cfg
|
||||
endef
|
||||
|
||||
+51
-9
@@ -34,7 +34,7 @@ $(proj_PKGS):
|
||||
git clone $(PRJ_BASE_URL)/$$proj projects/$$proj; \
|
||||
cd projects/$$proj; \
|
||||
if [ "$$proj" = "autospec" ] ; then \
|
||||
git remote set-url --push origin https://github.com/clearlinux/autospec.git; \
|
||||
git remote set-url --push origin git@github.com:clearlinux/autospec.git; \
|
||||
else \
|
||||
$(call gitoliteurl,projects/$$proj); \
|
||||
fi; \
|
||||
@@ -56,12 +56,6 @@ $(clone_PKGS): $(PACKAGES_FILE) packages/common/Makefile.common
|
||||
$(call subjectprefix,$$pkg); \
|
||||
)
|
||||
|
||||
#help cvecheck: Checks for common vulnerabilities and exposures in your code.
|
||||
cvecheck:
|
||||
# https://github.com/ikeydoherty/cve-check-tool
|
||||
# Installation: https://github.com/ikeydoherty/cve-check-tool/wiki
|
||||
cve-check-tool -n -M $(TOPLVL)/projects/common/mapping $(PACKAGES_FILE)
|
||||
|
||||
#help pull: Performs a git pull --rebase for each package repo, avoiding the creation
|
||||
#help of merge commits, while displaying any changes since your last pull. It is
|
||||
#help silent if there are no changes.
|
||||
@@ -83,7 +77,7 @@ ${PULL_PKGS}:
|
||||
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit $$O..$$N; echo; \
|
||||
fi ; \
|
||||
if [ "$$p" = "projects/autospec" ] ; then \
|
||||
git remote set-url --push origin https://github.com/clearlinux/autospec.git; \
|
||||
git remote set-url --push origin git@github.com:clearlinux/autospec.git; \
|
||||
else \
|
||||
$(call gitoliteurl,$$p); \
|
||||
fi ; \
|
||||
@@ -221,7 +215,7 @@ autospecnew: preautospecnew-checks localreponotice
|
||||
--name $(NAME) \
|
||||
--archives $(ARCHIVES) \
|
||||
--mock-config $(MOCK_CONFIG_VAL) \
|
||||
--mock-opts "$(MOCK_OPTS)" \
|
||||
--mock-opts="$(MOCK_OPTS)" \
|
||||
$${SETVERSION:+ --version $${SETVERSION}} \
|
||||
${NON_INTERACTIVE} ${SKIP_GIT} ${CLEANUP} \
|
||||
$(URL); \
|
||||
@@ -233,6 +227,54 @@ autospecnew: preautospecnew-checks localreponotice
|
||||
printf "** NOTICE: A patch with changes is available in the file $(TOPLVL)/packages/$(NAME)/for-review.txt\n"; \
|
||||
printf "** Please look through this file and if you are unsure, please submit for code review with git send-email\n"; \
|
||||
printf "**\n\n"; \
|
||||
else \
|
||||
echo "Autospec of $(NAME) failed."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
else \
|
||||
echo "$(NAME) already exists at $(TOPLVL)/packages/$(NAME)"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
#help autospecnewgo: Creates a new autospec package with (dependencies)
|
||||
#help for a given URL=$(URL) with NAME=$(NAME). Several files used by
|
||||
#help autospec will be created in the help process.
|
||||
#help Use MOCK_OPTS environment varible to pass down arbitrary mock options
|
||||
#help to autospec.
|
||||
#help For more information about autospec, see the project page on Github https://github.com/clearlinux/autospec
|
||||
autospecnewgo: preautospecnew-checks localreponotice
|
||||
@if [ -z $(NAME) ] || [ -z $(URL) ]; then \
|
||||
echo "Please specify NAME and URL. The ARCHIVES variable is optional."; \
|
||||
exit 1; \
|
||||
fi
|
||||
-$(MAKE) clone_$(NAME)
|
||||
@if [ ! -d $(TOPLVL)/packages/$(NAME)/.git ]; then \
|
||||
echo "no remote repository found, creating new package repository and running autospec"; \
|
||||
mkdir -p $(TOPLVL)/packages/$(NAME); \
|
||||
( \
|
||||
cd $(TOPLVL)/packages/$(NAME); \
|
||||
git init; \
|
||||
git remote add origin $(PKG_BASE_URL)/$(NAME); \
|
||||
$(call gitoliteurl,packages/$(NAME)); \
|
||||
$(call subjectprefix,$(NAME)); \
|
||||
); \
|
||||
printf 'PKG_NAME := %s\nURL = %s\nARCHIVES = %s\n\ninclude ../common/Makefile.common\n' $(NAME) '$(value URL)' '$(value ARCHIVES)' > $(TOPLVL)/packages/$(NAME)/Makefile; \
|
||||
python3 $(TOPLVL)/projects/common/go-builder.py \
|
||||
--target packages/$(NAME) \
|
||||
--integrity \
|
||||
--config "$(AUTOSPEC_CONF)" \
|
||||
--name $(NAME) \
|
||||
--archives $(ARCHIVES) \
|
||||
--mock-config $(MOCK_CONFIG_VAL) \
|
||||
--mock-opts "$(MOCK_OPTS)" \
|
||||
$(URL); \
|
||||
if [ $$? -eq 0 ]; then \
|
||||
$(MAKE) link-new-rpms PKG_REPO_DIR="${TOPLVL}/packages/${NAME}"; \
|
||||
$(TOPLVL)/projects/common/checkblacklist.sh $(TOPLVL)/projects/common/blacklist $(TOPLVL)/packages/${NAME}/results/*.rpm; \
|
||||
python3 $(TOPLVL)/projects/common/patchfilter.py <(git -C $(TOPLVL)/packages/$(NAME) show) > $(TOPLVL)/packages/$(NAME)/for-review.txt; \
|
||||
python3 $(TOPLVL)/projects/common/patchfilter.py <(git -C $(TOPLVL)/packages/$(NAME) show); \
|
||||
else \
|
||||
exit 1; \
|
||||
fi; \
|
||||
else \
|
||||
echo "$(NAME) already exists at $(TOPLVL)/packages/$(NAME)"; \
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
## Advanced topics
|
||||
|
||||
### Manual setup
|
||||
|
||||
If you did not run the user-setup script (see "Automated setup" section in the
|
||||
[main README](README.md), you will want to set up the developer tooling
|
||||
workspace manually. This section provides general documentation for the manual
|
||||
setup process, and it is not meant to be exhaustive.
|
||||
|
||||
On your Clear Linux system, create a workspace for Clear Linux development
|
||||
work:
|
||||
|
||||
```
|
||||
$ mkdir clearlinux
|
||||
```
|
||||
|
||||
Clone this repo into a `projects` directory within the workspace:
|
||||
|
||||
```
|
||||
$ cd clearlinux
|
||||
$ mkdir projects
|
||||
$ git clone https://github.com/clearlinux/common projects/common
|
||||
```
|
||||
|
||||
Create the toplevel tooling Makefile:
|
||||
|
||||
```
|
||||
$ ln -s projects/common/Makefile.toplevel Makefile
|
||||
```
|
||||
|
||||
Clone all Clear Linux package and project repositories:
|
||||
|
||||
```
|
||||
$ make clone
|
||||
```
|
||||
|
||||
Note: You can clone the repos in parallel by using make's `-j` option.
|
||||
|
||||
At this point, the `packages` directory will contain all Clear Linux package
|
||||
repos, and `projects` will contain common, clr-bundles, and autospec repos.
|
||||
@@ -152,39 +152,4 @@ If `Makefile.config.site_local` doesn't exist already, create it.
|
||||
|
||||
### Manual setup
|
||||
|
||||
If you did not run the user-setup script (see "Automated setup" section above),
|
||||
you will want to set up the developer tooling workspace manually. This section
|
||||
provides general documentation for the manual setup process, and it is not
|
||||
meant to be exhaustive.
|
||||
|
||||
On your Clear Linux system, create a workspace for Clear Linux development
|
||||
work:
|
||||
|
||||
```
|
||||
$ mkdir clearlinux
|
||||
```
|
||||
|
||||
Clone this repo into a `projects` directory within the workspace:
|
||||
|
||||
```
|
||||
$ cd clearlinux
|
||||
$ mkdir projects
|
||||
$ git clone https://github.com/clearlinux/common projects/common
|
||||
```
|
||||
|
||||
Create the toplevel tooling Makefile:
|
||||
|
||||
```
|
||||
$ ln -s projects/common/Makefile.toplevel Makefile
|
||||
```
|
||||
|
||||
Clone all Clear Linux package and project repositories:
|
||||
|
||||
```
|
||||
$ make clone
|
||||
```
|
||||
|
||||
Note: You can clone the repos in parallel by using make's `-j` option.
|
||||
|
||||
At this point, the `packages` directory will contain all Clear Linux package
|
||||
repos, and `projects` will contain common, clr-bundles, and autospec repos.
|
||||
See the [Manual setup](README-advanced.md#manual-setup) documentation.
|
||||
|
||||
Executable
+285
@@ -0,0 +1,285 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# gowrap.py - part of autospec
|
||||
# Copyright (C) 2019 Intel Corporation
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
def parse_args():
|
||||
"""Parse commandline arguments."""
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("url", help="Location of package archive")
|
||||
parser.add_argument("-t", "--target", dest="target", action="store",
|
||||
default=None,
|
||||
help="Target location to create or reuse")
|
||||
parser.add_argument("-c", "--config", dest="config", action="store",
|
||||
default="/usr/share/defaults/autospec/autospec.conf",
|
||||
help="Set configuration file to use")
|
||||
parser.add_argument("-n", "--name", action="store", dest="name", default="",
|
||||
help="Override the package name")
|
||||
parser.add_argument("-i", "--integrity", action="store_true",
|
||||
default=False,
|
||||
help="Search for package signature from source URL and "
|
||||
"attempt to verify package")
|
||||
parser.add_argument("-m", "--mock-config", action="store", default="clear",
|
||||
help="Value to pass with Mock's -r option. Defaults to "
|
||||
"\"clear\", meaning that Mock will use "
|
||||
"/etc/mock/clear.cfg.")
|
||||
parser.add_argument("-o", "--mock-opts", action="store", default="",
|
||||
help="Arbitrary options to pass down to mock when "
|
||||
"building a package.")
|
||||
parser.add_argument('-a', "--archives", action="store",
|
||||
dest="archives", default=[], nargs='*',
|
||||
help="tarball URLs for additional source archives and"
|
||||
" a location for the sources to be extacted to (e.g."
|
||||
" http://example.com/downloads/dependency.tar.gz"
|
||||
" /directory/relative/to/extract/root )")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def missing_dependencies(name):
|
||||
"""Check if the build failed due to missing dependencies."""
|
||||
root_log = os.path.join("packages", name, "results", "root.log")
|
||||
if not os.path.exists(root_log):
|
||||
return False
|
||||
with open(root_log, "r") as lfile:
|
||||
for line in lfile.readlines():
|
||||
if "No matching package to install" in line:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def already_built(name, version):
|
||||
"""Check if the package and version are already built."""
|
||||
if not os.path.exists(os.path.join("packages", name, "rpms")):
|
||||
return False
|
||||
vpath = os.path.join("packages", name, "versions")
|
||||
if not os.path.exists(vpath):
|
||||
return False
|
||||
with open(vpath, "r") as vfile:
|
||||
if version not in [x.strip() for x in vfile.readlines()]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def build(path, args, name, url, version):
|
||||
"""Try and build a package."""
|
||||
if version:
|
||||
ver_arg = ["-v", version]
|
||||
else:
|
||||
ver_arg = []
|
||||
if already_built(name, version):
|
||||
return True
|
||||
print(f"Trying to autospec {name} - {version}")
|
||||
|
||||
proc = subprocess.run(["python3",
|
||||
f"{path}/../autospec/autospec/autospec.py", url,
|
||||
"-c", args.config, "-t", f"packages/{name}",
|
||||
"-n", name, "-m", args.mock_config,
|
||||
"-o", args.mock_opts, "-i"] + ver_arg, capture_output=True)
|
||||
if proc.returncode == 0:
|
||||
subprocess.run(["make", "link-new-rpms", f"PKG_REPO_DIR=packages/{name}"],
|
||||
capture_output=True)
|
||||
return proc.returncode == 0
|
||||
|
||||
|
||||
def parse_go_mod(path):
|
||||
"""Parse go.mod file for build requirements.
|
||||
|
||||
File content looks as follows:
|
||||
|
||||
module example.com/foo/bar
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
"github.com/spf13/cobra" v0.0.3
|
||||
github.com/spf13/pflag v1.0.3 // indirect
|
||||
)
|
||||
|
||||
Need to handle all require lines including //indirect.
|
||||
Skip requires that use .git for now. May need to be handled
|
||||
differently.
|
||||
"""
|
||||
reqs = []
|
||||
with open(path, "r") as gfile:
|
||||
dep_start = False
|
||||
for line in gfile.readlines():
|
||||
# Ideally the mod file is generated and the format is
|
||||
# always correct but add a few defenses just in case
|
||||
line = line.strip()
|
||||
if line.startswith("//"):
|
||||
# Skip comments
|
||||
continue
|
||||
if dep_start:
|
||||
# End of the require section
|
||||
if line.startswith(")"):
|
||||
break
|
||||
req = line.split()[:2]
|
||||
req[0] = req[0].replace('"', '')
|
||||
if req[0].endswith(".git"):
|
||||
continue
|
||||
reqs.append(req)
|
||||
continue
|
||||
if line.startswith("require ("):
|
||||
dep_start = True
|
||||
return reqs
|
||||
|
||||
|
||||
def get_dependencies(name):
|
||||
"""Return path to the go.mod file if it exists."""
|
||||
command = None
|
||||
path = None
|
||||
pdir = os.path.join("packages", name)
|
||||
reqs = []
|
||||
for fname in os.listdir(pdir):
|
||||
# Find the archive
|
||||
if fname.endswith("zip"):
|
||||
command = ["unzip", fname]
|
||||
elif ".tar." in fname:
|
||||
command = ["tar", "xf", fname]
|
||||
else:
|
||||
command = None
|
||||
|
||||
if command:
|
||||
# Decompress archive
|
||||
tdir = tempfile.mkdtemp()
|
||||
tfile = os.path.join(tdir, fname)
|
||||
shutil.copyfile(os.path.join(pdir, fname), tfile)
|
||||
proc = subprocess.run(command, cwd=tdir, capture_output=True)
|
||||
if not proc.returncode:
|
||||
# inspect contents for a "go.sum" file
|
||||
for root, _, files in os.walk(tdir):
|
||||
if "go.mod" in files:
|
||||
path = f"{name}.gomod"
|
||||
shutil.copyfile(os.path.join(root, "go.mod"), path)
|
||||
reqs += parse_go_mod(path)
|
||||
os.unlink(path)
|
||||
shutil.rmtree(tdir)
|
||||
|
||||
return reqs
|
||||
|
||||
|
||||
def encode_requirements(requirement):
|
||||
"""Encode the project's module and version."""
|
||||
# Default dependency base proxy url
|
||||
base_url = "https://proxy.golang.org/"
|
||||
# Encoding based on
|
||||
# https://tip.golang.org/cmd/go/#hdr-Module_proxy_protocol
|
||||
encoded_module = ""
|
||||
for char in requirement[0]:
|
||||
if char.isupper():
|
||||
encoded_module += "!" + char.lower()
|
||||
else:
|
||||
encoded_module += char
|
||||
encoded_version = ""
|
||||
for char in requirement[1]:
|
||||
if char.isupper():
|
||||
encoded_version += "!" + char.lower()
|
||||
else:
|
||||
encoded_version += char
|
||||
return (encoded_module, encoded_version)
|
||||
|
||||
|
||||
def initialize_package(name, url, version, path, args):
|
||||
"""Setup package and try to build it."""
|
||||
if already_built(name, version):
|
||||
return True
|
||||
print(f"Trying to autospecnew {name} - {version}")
|
||||
|
||||
proc = subprocess.run(["make", "autospecnew", f"URL={url}", f"NAME={name}", f"SETVERSION={version}"], capture_output=True)
|
||||
if f"{name} already exists at" in proc.stdout.decode("utf-8"):
|
||||
return build(path, args, name, url, version)
|
||||
return proc.returncode == 0
|
||||
|
||||
|
||||
def build_recursive(path, args, name, url, version=None, success=None):
|
||||
"""Try and recursively build packages."""
|
||||
if not success:
|
||||
# First package being built, common utilities already run
|
||||
# so just use autospec directly
|
||||
success = {}
|
||||
ret = build(path, args, name, url, version)
|
||||
else:
|
||||
ret = initialize_package(name, url, version, path, args)
|
||||
|
||||
if ret:
|
||||
# Completed so we are done!
|
||||
return True
|
||||
|
||||
if not missing_dependencies(name):
|
||||
# Failed but not due to missing dependencies, bail
|
||||
print(f"Unknown error building {name} - {version}")
|
||||
return False
|
||||
|
||||
reqs = get_dependencies(name)
|
||||
if not reqs:
|
||||
# Didn't try and add anything so don't need to build again
|
||||
print(f"Build failed with no missing requirements: {name} - {version}")
|
||||
return False
|
||||
|
||||
print(f"First attempt to build failed due to missing dependencies {name} - {version}\n")
|
||||
for req in reqs:
|
||||
ereq = encode_requirements(req)
|
||||
rname = "go-" + req[0].replace("/", "-")
|
||||
rurl = f"https://proxy.golang.org/{ereq[0]}/@v/list"
|
||||
if (rname, req[1]) in success:
|
||||
# Rebuild detected, figure out if it is okay or not
|
||||
if success[(rname, req[1])]:
|
||||
# Already succeeded building req short circuit success
|
||||
continue
|
||||
else:
|
||||
# Encountered a build loop, bail out as this likely
|
||||
# requires manual fixing
|
||||
print(f"Detected build loop when building {rname} - {req[1]}")
|
||||
return True
|
||||
success[(rname, req[1])] = False
|
||||
if not build_recursive(path, args, rname, rurl, req[1], success):
|
||||
print(f"Failed to build dependency {rname} - {req[1]}")
|
||||
return False
|
||||
|
||||
success[(rname, req[1])] = True
|
||||
subprocess.run(["make", "repodel"], cwd=f"packages/{rname}", capture_output=True)
|
||||
subprocess.run(["make", "repostage"], cwd=f"packages/{rname}", capture_output=True)
|
||||
|
||||
# Create the repo with the new packages added
|
||||
subprocess.run(["make", "localrepocreate"], capture_output=True)
|
||||
# Retry previously failed build assuming dependencies got added
|
||||
print(f"Rebuilding after resolving dependencies {name} - {version}")
|
||||
ret = build(path, args, name, url, version)
|
||||
print("")
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def main():
|
||||
"""Start program execution."""
|
||||
args = parse_args()
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
return build_recursive(path, args, args.name, args.url)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if not main():
|
||||
sys.exit(-1)
|
||||
print("\n\nBuild completed\n\n")
|
||||
@@ -1,4 +1,5 @@
|
||||
Copyright
|
||||
Distributable
|
||||
ISSL
|
||||
Public-Domain
|
||||
sendmail
|
||||
|
||||
@@ -46,6 +46,7 @@ BSD-3-Clause-LBNL
|
||||
BSD-3-Clause-No-Nuclear-License
|
||||
BSD-3-Clause-No-Nuclear-License-2014
|
||||
BSD-3-Clause-No-Nuclear-Warranty
|
||||
BSD-3-Clause-Open-MPI
|
||||
BSD-4-Clause
|
||||
BSD-4-Clause-UC
|
||||
BSD-Protection
|
||||
@@ -56,6 +57,7 @@ Barr
|
||||
Beerware
|
||||
BitTorrent-1.0
|
||||
BitTorrent-1.1
|
||||
BlueOak-1.0.0
|
||||
Borceux
|
||||
CATOSL-1.1
|
||||
CC-BY-1.0
|
||||
@@ -88,6 +90,7 @@ CC-BY-SA-2.0
|
||||
CC-BY-SA-2.5
|
||||
CC-BY-SA-3.0
|
||||
CC-BY-SA-4.0
|
||||
CC-PDDC
|
||||
CC0-1.0
|
||||
CDDL-1.0
|
||||
CDDL-1.1
|
||||
@@ -234,6 +237,7 @@ MTLL
|
||||
MakeIndex
|
||||
MirOS
|
||||
Motosoto
|
||||
MulanPSL-1.0
|
||||
Multics
|
||||
Mup
|
||||
NASA-1.3
|
||||
@@ -261,6 +265,7 @@ ODC-By-1.0
|
||||
ODbL-1.0
|
||||
OFL-1.0
|
||||
OFL-1.1
|
||||
OGL-Canada-2.0
|
||||
OGL-UK-1.0
|
||||
OGL-UK-2.0
|
||||
OGL-UK-3.0
|
||||
@@ -293,6 +298,7 @@ OpenSSL
|
||||
PDDL-1.0
|
||||
PHP-3.0
|
||||
PHP-3.01
|
||||
Parity-6.0.0
|
||||
Plexus
|
||||
PostgreSQL
|
||||
Python-2.0
|
||||
@@ -311,12 +317,17 @@ SCEA
|
||||
SGI-B-1.0
|
||||
SGI-B-1.1
|
||||
SGI-B-2.0
|
||||
SHL-0.5
|
||||
SHL-0.51
|
||||
SISSL
|
||||
SISSL-1.2
|
||||
SMLNJ
|
||||
SMPPL
|
||||
SNIA
|
||||
SPL-1.0
|
||||
SSH-OpenSSH
|
||||
SSH-short
|
||||
SSPL-1.0
|
||||
SWL
|
||||
Saxpath
|
||||
Sendmail
|
||||
@@ -336,6 +347,7 @@ TORQUE-1.1
|
||||
TOSL
|
||||
TU-Berlin-1.0
|
||||
TU-Berlin-2.0
|
||||
UCL-1.0
|
||||
UPL-1.0
|
||||
Unicode-DFS-2015
|
||||
Unicode-DFS-2016
|
||||
@@ -365,6 +377,7 @@ Zend-2.0
|
||||
Zimbra-1.3
|
||||
Zimbra-1.4
|
||||
Zlib
|
||||
blessing
|
||||
bzip2-1.0.5
|
||||
bzip2-1.0.6
|
||||
copyleft-next-0.3.0
|
||||
@@ -374,6 +387,7 @@ diffmark
|
||||
dvipdfm
|
||||
eCos-2.0
|
||||
eGenix
|
||||
etalab-2.0
|
||||
gSOAP-1.3b
|
||||
gnuplot
|
||||
iMatix
|
||||
|
||||
@@ -51,4 +51,5 @@ rack = rubygem-rack
|
||||
compute = nova
|
||||
international_components_for_unicode = icu4c
|
||||
node.js = nodejs
|
||||
jupyter-core = jupyter_core
|
||||
jupyter-core = jupyter_core
|
||||
flatten-json = flatten_json
|
||||
+10
-2
@@ -225,7 +225,6 @@ def main():
|
||||
zap_line_in_file_start(".spec", "Source99 :")
|
||||
zap_line_in_file_start(".spec", "Source0 :")
|
||||
zap_line_in_file_start(".spec", "export SOURCE_DATE_EPOCH")
|
||||
zap_line_in_file_start(".spec", "export GCC_IGNORE_WERROR=1")
|
||||
zap_line_in_file_start(".spec", "export AR=gcc-ar")
|
||||
zap_line_in_file_start(".spec", "export RANLIB=gcc-ranlib")
|
||||
zap_line_in_file_start(".spec", "export NM=gcc-nm")
|
||||
@@ -266,6 +265,8 @@ def main():
|
||||
zap_line_in_file_start(".spec", "%description license")
|
||||
zap_line_in_file_start(".spec", "%package doc")
|
||||
zap_line_in_file_start(".spec", "cp -a ")
|
||||
zap_line_in_file_start(".spec", "cd %{_builddir}/")
|
||||
zap_line_in_file_start(".spec", "export GCC_IGNORE_WERROR=1")
|
||||
|
||||
zap_line_in_file_start("b/Makefile", "URL =")
|
||||
zap_line_in_file_start("b/Makefile", "PKG_NAME :=")
|
||||
@@ -288,11 +289,13 @@ def main():
|
||||
zap_line_in_file("b/options.conf", "# disable parallelization during build")
|
||||
zap_line_in_file("b/options.conf", "broken_parallel_build = false")
|
||||
zap_line_in_file("b/options.conf", "# this package is a library compatability package and only ships versioned library files")
|
||||
zap_line_in_file("b/options.conf", "# this package is a library compatibility package and only ships versioned library files")
|
||||
zap_line_in_file("b/options.conf", "compat = false")
|
||||
zap_line_in_file("b/options.conf", "# set conservative build flags")
|
||||
zap_line_in_file("b/options.conf", "conservative_flags = false")
|
||||
zap_line_in_file("b/options.conf", "# dev package requires the extras to be installed")
|
||||
zap_line_in_file("b/options.conf", "dev_requires_extras = false")
|
||||
zap_line_in_file("b/options.conf", "nodebug = false")
|
||||
zap_line_in_file("b/options.conf", "# pass -ffast-math to compiler")
|
||||
zap_line_in_file("b/options.conf", "fast-math = false")
|
||||
zap_line_in_file("b/options.conf", "# optimize build for speed over size")
|
||||
@@ -322,9 +325,12 @@ def main():
|
||||
zap_line_in_file("b/options.conf", "# add clang flags")
|
||||
zap_line_in_file("b/options.conf", "use_clang = false")
|
||||
zap_line_in_file("b/options.conf", "# configure build for lto")
|
||||
zap_line_in_file("b/options.conf", "use_lto = false")
|
||||
zap_line_in_file("b/options.conf", "use_lto = true")
|
||||
zap_line_in_file("b/options.conf", "# require package verification for build")
|
||||
zap_line_in_file("b/options.conf", "verify_required = true")
|
||||
zap_line_in_file("b/options.conf", "# do not generate debuginfo for this package")
|
||||
zap_line_in_file("b/options.conf", "nodebug = false")
|
||||
zap_line_in_file("b/options.conf", "domain =")
|
||||
|
||||
zap_line_in_file("b/buildreq_add", "# This file contains additional build requirements that did not get")
|
||||
zap_line_in_file("b/buildreq_add", "# picked up automatically. One name per line, no whitespace.")
|
||||
@@ -350,6 +356,8 @@ def main():
|
||||
zap_plus_line_in_file("symbols32")
|
||||
|
||||
zap_entire_file("b/whatrequires")
|
||||
zap_entire_file("b/versions")
|
||||
zap_entire_file("b/.gitignore")
|
||||
|
||||
zap_empty_chunks()
|
||||
|
||||
|
||||
+2
-2
@@ -145,9 +145,9 @@ if [ "$USE_KOJI" ]; then
|
||||
cp "$CLIENTCA" ~/.koji/clientca.crt
|
||||
cp "$SERVERCA" ~/.koji/serverca.crt
|
||||
|
||||
if [ ! -f /etc/koji.conf ]; then
|
||||
if [ ! -f ~/.koji/config ]; then
|
||||
echo "Setting up koji config . . ."
|
||||
sudo cp projects/common/conf/koji.conf /etc
|
||||
cp -f projects/common/conf/koji.conf ~/.koji/config
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user