Some make fixes: made sandbox and bootstrap using custom yum.conf and patched yum priorities plugin to make it able match fully qualified package name
This commit is contained in:
parent
0beb0a4ce4
commit
8de330129f
@ -51,7 +51,23 @@ gpgcheck=0
|
||||
enabled=1
|
||||
endef
|
||||
|
||||
YUM:=sudo yum --installroot=`readlink -f $(INITRAMROOT)` -y --nogpgcheck
|
||||
define bootstrap_yum_conf
|
||||
[main]
|
||||
cachedir=$(BUILD_DIR)/bootstrap/cache
|
||||
keepcache=0
|
||||
debuglevel=6
|
||||
logfile=$(BUILD_DIR)/bootstrap/yum.log
|
||||
exclude=*.i686.rpm
|
||||
exactarch=1
|
||||
obsoletes=1
|
||||
gpgcheck=0
|
||||
plugins=1
|
||||
pluginpath=$(shell readlink -f -m $(BUILD_DIR)/bootstrap/etc/yum-plugins)
|
||||
pluginconfpath=$(shell readlink -f -m $(BUILD_DIR)/bootstrap/etc/yum/pluginconf.d)
|
||||
reposdir=$(shell readlink -f -m $(BUILD_DIR)/bootstrap/etc/yum.repos.d)
|
||||
endef
|
||||
|
||||
YUM:=sudo yum -c $(BUILD_DIR)/bootstrap/etc/yum.conf --installroot=`readlink -f $(INITRAMROOT)` -y --nogpgcheck
|
||||
|
||||
clean: clean-bootstrap
|
||||
|
||||
@ -78,8 +94,13 @@ $(BUILD_DIR)/bootstrap/linux: $(BUILD_DIR)/mirror/build.done
|
||||
rm -r $(BUILD_DIR)/bootstrap/boot
|
||||
touch $(BUILD_DIR)/bootstrap/linux
|
||||
|
||||
$(BUILD_DIR)/bootstrap/etc/yum.conf: export contents:=$(bootstrap_yum_conf)
|
||||
$(BUILD_DIR)/bootstrap/etc/yum.repos.d/base.repo: export contents:=$(yum_local_repo)
|
||||
$(BUILD_DIR)/bootstrap/etc/yum.conf $(BUILD_DIR)/bootstrap/etc/yum.repos.d/base.repo:
|
||||
mkdir -p $(@D)
|
||||
echo "$${contents}" > $@
|
||||
|
||||
$(BUILD_DIR)/bootstrap/customize-initram-root.done: $(call depv,BOOTSTRAP_RPMS_CUSTOM)
|
||||
$(BUILD_DIR)/bootstrap/customize-initram-root.done: export yum_local_repo:=$(yum_local_repo)
|
||||
$(BUILD_DIR)/bootstrap/customize-initram-root.done: \
|
||||
$(BUILD_DIR)/packages/rpm/build.done \
|
||||
$(BUILD_DIR)/bootstrap/prepare-initram-root.done \
|
||||
@ -87,9 +108,6 @@ $(BUILD_DIR)/bootstrap/customize-initram-root.done: \
|
||||
$(SOURCE_DIR)/bin/send2syslog.py \
|
||||
$(SOURCE_DIR)/bootstrap/ssh/id_rsa.pub
|
||||
|
||||
# Defining local repository
|
||||
sudo sh -c "echo \"$${yum_local_repo}\" > $(INITRAMROOT)/etc/yum.repos.d/mirror.repo"
|
||||
|
||||
# Rebuilding rpmdb
|
||||
sudo rpm --root=`readlink -f $(INITRAMROOT)` --rebuilddb
|
||||
|
||||
@ -125,8 +143,11 @@ $(BUILD_DIR)/bootstrap/customize-initram-root.done: \
|
||||
|
||||
$(BUILD_DIR)/bootstrap/prepare-initram-root.done: $(call depv,BOOTSTRAP_RPMS)
|
||||
$(BUILD_DIR)/bootstrap/prepare-initram-root.done: export yum_local_repo:=$(yum_local_repo)
|
||||
$(BUILD_DIR)/bootstrap/prepare-initram-root.done: export yum_local_repo:=$(bootstrap_yum_conf)
|
||||
$(BUILD_DIR)/bootstrap/prepare-initram-root.done: \
|
||||
$(BUILD_DIR)/mirror/build.done
|
||||
$(BUILD_DIR)/mirror/build.done \
|
||||
$(BUILD_DIR)/bootstrap/etc/yum.conf \
|
||||
$(BUILD_DIR)/bootstrap/etc/yum.repos.d/base.repo
|
||||
|
||||
# Installing centos-release package
|
||||
sudo rpm -i --root=$(INITRAMROOT) \
|
||||
@ -136,9 +157,6 @@ $(BUILD_DIR)/bootstrap/prepare-initram-root.done: \
|
||||
# Removing default repositories (centos-release package provides them)
|
||||
sudo rm -f $(INITRAMROOT)/etc/yum.repos.d/Cent*
|
||||
|
||||
# Defining local repository
|
||||
sudo sh -c "echo \"$${yum_local_repo}\" > $(INITRAMROOT)/etc/yum.repos.d/mirror.repo"
|
||||
|
||||
# Rebuilding rpmdb
|
||||
sudo rpm --root=`readlink -f $(INITRAMROOT)` --rebuilddb
|
||||
|
||||
|
@ -2,28 +2,31 @@ include $(SOURCE_DIR)/mirror/centos/yum_repos.mk
|
||||
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.conf: $(call depv,yum_conf)
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.conf: export contents:=$(yum_conf)
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.conf: \
|
||||
$(SOURCE_DIR)/mirror/centos/yum_repos.mk \
|
||||
$(SOURCE_DIR)/mirror/centos/yum-priorities-plugin.py
|
||||
mkdir -p $(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d
|
||||
echo "[main]\nenabled=1" > $(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d/priorities.conf
|
||||
mkdir -p $(BUILD_DIR)/mirror/centos/etc/yum-plugins
|
||||
cp $(SOURCE_DIR)/mirror/centos/yum-priorities-plugin.py $(BUILD_DIR)/mirror/centos/etc/yum-plugins/priorities.py
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.conf:
|
||||
mkdir -p $(@D)
|
||||
echo "$${contents}" > $@
|
||||
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum-plugins/priorities.py: \
|
||||
$(SOURCE_DIR)/mirror/centos/yum-priorities-plugin.py
|
||||
mkdir -p $(@D)
|
||||
cp $(SOURCE_DIR)/mirror/centos/yum-priorities-plugin.py $@
|
||||
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d/priorities.conf:
|
||||
mkdir -p $(@D)
|
||||
echo "[main]\nenabled=1\ncheck_obsoletes=1\nfull_match=1" > $@
|
||||
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo: $(call depv,YUM_REPOS)
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo: \
|
||||
export contents:=$(foreach repo,$(YUM_REPOS),\n$(yum_repo_$(repo)))
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo: \
|
||||
$(SOURCE_DIR)/mirror/centos/yum_repos.mk
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo:
|
||||
@mkdir -p $(@D)
|
||||
echo "$${contents}" > $@
|
||||
|
||||
$(BUILD_DIR)/mirror/centos/yum-config.done: \
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.conf \
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo \
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum-plugins/priorities.py \
|
||||
$(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d/priorities.conf
|
||||
$(ACTION.TOUCH)
|
||||
|
||||
$(BUILD_DIR)/mirror/centos/yum.done: \
|
||||
|
@ -31,10 +31,17 @@
|
||||
# check_obsoletes=1
|
||||
#
|
||||
# By default, this plugin excludes packages from lower priority repositories
|
||||
# based on the package name. If you want to exclude packages based ony the
|
||||
# based on the package name. If you want to exclude packages based only the
|
||||
# package name and architecture, enable the 'only_samearch' bool:
|
||||
#
|
||||
# only_samearch=N
|
||||
# only_samearch=1
|
||||
#
|
||||
# If you want to be able to set package as the fully qualified package name
|
||||
# including architecture and package version, enable 'full_match' bool:
|
||||
#
|
||||
# full_match=1
|
||||
#
|
||||
# If full_match is enabled then check_obsoletes will be forced to disable
|
||||
#
|
||||
# You can add priorities to repositories, by adding the line:
|
||||
#
|
||||
@ -53,6 +60,7 @@ import yum
|
||||
|
||||
check_obsoletes = False
|
||||
only_samearch = False
|
||||
full_match = False
|
||||
|
||||
requires_api_version = '2.1'
|
||||
plugin_type = (TYPE_CORE,)
|
||||
@ -60,10 +68,15 @@ plugin_type = (TYPE_CORE,)
|
||||
def config_hook(conduit):
|
||||
global check_obsoletes
|
||||
global only_samearch
|
||||
global full_match
|
||||
|
||||
# Plugin configuration
|
||||
check_obsoletes = conduit.confBool('main', 'check_obsoletes', default = False)
|
||||
only_samearch = conduit.confBool('main', 'only_samearch', default = False)
|
||||
full_match = conduit.confBool('main', 'full_match', default = False)
|
||||
|
||||
if full_match:
|
||||
check_obsoletes = False
|
||||
|
||||
# Repo priorities
|
||||
if yum.__version__ >= '2.5.0':
|
||||
@ -83,7 +96,7 @@ def config_hook(conduit):
|
||||
help="Priority-exclude packages based on name + arch")
|
||||
|
||||
def _all_repo_priorities_same(allrepos):
|
||||
""" Are all repos are at the same priority """
|
||||
""" Are all repos at the same priority """
|
||||
first = None
|
||||
for repo in allrepos:
|
||||
if first is None:
|
||||
@ -95,6 +108,7 @@ def _all_repo_priorities_same(allrepos):
|
||||
def exclude_hook(conduit):
|
||||
global only_samearch
|
||||
global check_obsoletes
|
||||
global full_match
|
||||
|
||||
allrepos = conduit.getRepos().listEnabled()
|
||||
|
||||
@ -135,12 +149,17 @@ def exclude_hook(conduit):
|
||||
for po in conduit.getPackages(repo):
|
||||
delPackage = False
|
||||
|
||||
if full_match:
|
||||
pname = str(po)
|
||||
else:
|
||||
pname = po.name
|
||||
|
||||
if only_samearch:
|
||||
key = "%s.%s" % (po.name,po.arch)
|
||||
key = "%s.%s" % (pname,po.arch)
|
||||
if key in pkg_priorities and pkg_priorities[key] < repo.priority:
|
||||
delPackage = True
|
||||
else:
|
||||
key = "%s" % po.name
|
||||
key = "%s" % pname
|
||||
if key in pkg_priorities_archless and pkg_priorities_archless[key] < repo.priority:
|
||||
delPackage = True
|
||||
|
||||
@ -170,13 +189,18 @@ def exclude_hook(conduit):
|
||||
conduit._base.up = None
|
||||
|
||||
def _pkglist_to_dict(pl, priority, addArch = False):
|
||||
global full_match
|
||||
out = dict()
|
||||
for p in pl:
|
||||
if full_match:
|
||||
pname = str(p)
|
||||
else:
|
||||
pname = p.name
|
||||
if addArch:
|
||||
key = "%s.%s" % (p.name,p.arch)
|
||||
key = "%s.%s" % (pname,p.arch)
|
||||
out[key] = priority
|
||||
else:
|
||||
out[p.name] = priority
|
||||
out[pname] = priority
|
||||
return out
|
||||
|
||||
def _mergeprioritydicts(dict1, dict2):
|
||||
|
@ -11,7 +11,7 @@ gpgcheck=0
|
||||
plugins=1
|
||||
pluginpath=$(shell readlink -f -m $(BUILD_DIR)/mirror/centos/etc/yum-plugins)
|
||||
pluginconfpath=$(shell readlink -f -m $(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d)
|
||||
reposdir=$(BUILD_DIR)/mirror/centos/etc/yum.repos.d
|
||||
reposdir=$(shell readlink -f -m $(BUILD_DIR)/mirror/centos/etc/yum.repos.d)
|
||||
endef
|
||||
|
||||
|
||||
|
22
sandbox.mk
22
sandbox.mk
@ -1,3 +1,4 @@
|
||||
|
||||
define yum_local_repo
|
||||
[mirror]
|
||||
name=Mirantis mirror
|
||||
@ -6,6 +7,22 @@ gpgcheck=0
|
||||
enabled=1
|
||||
endef
|
||||
|
||||
define sandbox_yum_conf
|
||||
[main]
|
||||
cachedir=$(SANDBOX)/cache
|
||||
keepcache=0
|
||||
debuglevel=6
|
||||
logfile=$(SANDBOX)/yum.log
|
||||
exclude=*.i686.rpm
|
||||
exactarch=1
|
||||
obsoletes=1
|
||||
gpgcheck=0
|
||||
plugins=1
|
||||
pluginpath=$(shell readlink -f -m $(SANDBOX)/etc/yum-plugins)
|
||||
pluginconfpath=$(shell readlink -f -m $(SANDBOX)/etc/yum/pluginconf.d)
|
||||
reposdir=$(shell readlink -f -m $(SANDBOX)/etc/yum.repos.d)
|
||||
endef
|
||||
|
||||
SANDBOX_PACKAGES:=\
|
||||
byacc \
|
||||
flex \
|
||||
@ -23,6 +40,9 @@ SANDBOX_PACKAGES:=\
|
||||
|
||||
define SANDBOX_UP
|
||||
mkdir -p $(SANDBOX)/etc/yum.repos.d
|
||||
cat > $(SANDBOX)/etc/yum.conf <<EOF
|
||||
$(sandbox_yum_conf)
|
||||
EOF
|
||||
cp /etc/resolv.conf $(SANDBOX)/etc/resolv.conf
|
||||
cat > $(SANDBOX)/etc/yum.repos.d/base.repo <<EOF
|
||||
$(yum_local_repo)
|
||||
@ -31,7 +51,7 @@ rpm -i --root=$(SANDBOX) `find $(LOCAL_MIRROR_CENTOS_OS_BASEURL) -name "centos-r
|
||||
echo "centos-release already installed"
|
||||
rm -f $(SANDBOX)/etc/yum.repos.d/Cent*
|
||||
rpm --root=$(SANDBOX) --rebuilddb
|
||||
yum --installroot=$(SANDBOX) -y --nogpgcheck install $(SANDBOX_PACKAGES)
|
||||
yum -c $(SANDBOX)/etc/yum.conf --installroot=$(SANDBOX) -y --nogpgcheck install $(SANDBOX_PACKAGES)
|
||||
mount | grep -q $(SANDBOX)/proc || sudo mount --bind /proc $(SANDBOX)/proc
|
||||
mount | grep -q $(SANDBOX)/dev || sudo mount --bind /dev $(SANDBOX)/dev
|
||||
endef
|
||||
|
Loading…
Reference in New Issue
Block a user