aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-04-14 21:53:01 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-04-14 21:53:01 +0000
commit6429fbca1138b055c15777f04750f331ca994892 (patch)
treeed52f8882d07bac35facea773909c04c0a17847f
parent390ce55a2ef21fc71976140b4b1879dd37ea4ce2 (diff)
downloadpaludis-6429fbca1138b055c15777f04750f331ca994892.tar.gz
paludis-6429fbca1138b055c15777f04750f331ca994892.tar.xz
CONFIG_PROTECT improvements, add --no-config-protection
-rw-r--r--ebuild/builtin_merge.bash1
-rwxr-xr-xebuild/utils/merge13
-rwxr-xr-xebuild/utils/unmerge2
-rw-r--r--paludis/fake_repository.cc4
-rw-r--r--paludis/fake_repository.hh6
-rw-r--r--paludis/portage_repository.cc5
-rw-r--r--paludis/portage_repository.hh5
-rw-r--r--paludis/repository.hh40
-rw-r--r--paludis/vdb_repository.cc5
-rw-r--r--paludis/vdb_repository.hh5
-rw-r--r--src/colour.hh2
-rw-r--r--src/command_line.cc1
-rw-r--r--src/command_line.hh3
-rw-r--r--src/install.cc8
-rw-r--r--src/uninstall.cc6
15 files changed, 78 insertions, 28 deletions
diff --git a/ebuild/builtin_merge.bash b/ebuild/builtin_merge.bash
index cd373da..c8cc04c 100644
--- a/ebuild/builtin_merge.bash
+++ b/ebuild/builtin_merge.bash
@@ -36,6 +36,7 @@ builtin_merge()
echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed"
done
+ echo "override cfgpro: '${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT}' '${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK}'"
if [[ -n ${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT} ]]; then
CONFIG_PROTECT=${PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT}
fi
diff --git a/ebuild/utils/merge b/ebuild/utils/merge
index 52bf2d6..a79fce9 100755
--- a/ebuild/utils/merge
+++ b/ebuild/utils/merge
@@ -52,9 +52,10 @@ fi
make_cfgpro_filename()
{
- local fn="${1}" i=0
- while [[ -e "${2}/${fn}" ]]; do
- fn="._cfg$(printf '%.4i' ${i})${1}"
+ local fn="$(basename ${1})" i=0
+ while [[ -e "${2}/${fn}" &&
+ "$(md5sum "${2}/${fn}" |cut -d\ -f 1)" != "$(md5sum "${1}" |cut -d\ -f 1)" ]]; do
+ fn="._cfg$(printf '%.4i' ${i})$(basename ${1})"
(( ++i ))
done
echo ${fn}
@@ -119,10 +120,10 @@ merge_this()
else
local cfgpro=
for c in ${CONFIG_PROTECT}; do
- if [[ ${2#${top_dst}} == "${c}"/* ]]; then
+ if [[ ${2#${top_dst}} == "${c%/}/"* ]]; then
cfgpro=yes
for cm in ${CONFIG_PROTECT_MASK}; do
- if [[ ${2#${top_dst}} == "${cm}"/* ]]; then
+ if [[ ${2#${top_dst}} == "${cm%/}/"* ]]; then
cfgpro=
fi
done
@@ -132,7 +133,7 @@ merge_this()
if [[ -n ${cfgpro} &&
-e ${2}/${ff} &&
"$(md5sum ${f} |cut -d\ -f 1)" != "$(md5sum ${2}/${ff} |cut -d\ -f 1)" ]]; then
- fn="${1}/$(make_cfgpro_filename ${ff} ${2})"
+ fn="${1}/$(make_cfgpro_filename ${f} ${2})"
if [[ ${fn} != ${f} ]]; then
mv "${f}" "${fn}"
fi
diff --git a/ebuild/utils/unmerge b/ebuild/utils/unmerge
index 70957d1..6d8dcf5 100755
--- a/ebuild/utils/unmerge
+++ b/ebuild/utils/unmerge
@@ -76,7 +76,7 @@ while read entry ; do
if [[ ${items[1]} == "${c%/}"/* ]]; then
cfgpro="yes"
for cm in ${CONFIG_PROTECT_MASK}; do
- if [[ ${items[1]} == "${cm}"/* ]]; then
+ if [[ ${items[1]} == "${cm%/}"/* ]]; then
cfgpro=
fi
done
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index eb4bd06..da0798b 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -215,12 +215,12 @@ FakeRepository::do_is_mirror(const std::string &) const
}
void
-FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &) const
+FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
{
}
void
-FakeRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &) const
+FakeRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
{
}
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 2ddbd7c..bf653f6 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -79,9 +79,11 @@ namespace paludis
virtual bool do_is_mirror(const std::string &) const;
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const;
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const;
virtual DepAtom::Pointer do_package_set(const std::string & s) const;
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 9056a33..3fa056e 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -1089,7 +1089,7 @@ PortageRepository::do_is_mirror(const std::string & s) const
}
void
-PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec & v) const
+PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec & v, const InstallOptions & o) const
{
if (! _imp->has_profile)
{
@@ -1245,6 +1245,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
("PALUDIS_COMMAND", _imp->env->paludis_command())
("KV", kernel_version())
+ ("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK", o.get<io_noconfigprotect>() ? "/" : "")
("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
@@ -1306,7 +1307,7 @@ PortageRepository::do_sync() const
}
void
-PortageRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &) const
+PortageRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
{
throw PackageUninstallActionError("PortageRepository doesn't support do_uninstall");
}
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 693ad3d..c59c42c 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -90,10 +90,11 @@ namespace paludis
virtual bool do_is_mirror(const std::string &) const;
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const;
virtual void do_uninstall(const QualifiedPackageName &,
- const VersionSpec &) const PALUDIS_ATTRIBUTE((noreturn));
+ const VersionSpec &, const InstallOptions &) const PALUDIS_ATTRIBUTE((noreturn));
virtual DepAtom::Pointer do_package_set(const std::string & s) const;
diff --git a/paludis/repository.hh b/paludis/repository.hh
index fbc233d..2b57e34 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -41,6 +41,32 @@ namespace paludis
class Environment;
/**
+ * Keys for InstallOptions.
+ */
+ enum InstallOptionsKeys
+ {
+ io_noconfigprotect, ///< Disable config protection
+ io_fetchonly, ///< Fetch only
+ last_io ///< Number of entries
+ };
+
+ /**
+ * Tag for InstallOptions.
+ */
+ struct InstallOptionsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<InstallOptionsKeys, last_io>,
+ SmartRecordKey<io_noconfigprotect, bool>,
+ SmartRecordKey<io_fetchonly, bool>
+ {
+ };
+
+ /**
+ * Defines various options for package installation.
+ */
+ typedef MakeSmartRecord<InstallOptionsTag>::Type InstallOptions;
+
+ /**
* A Repository provides a representation of a physical repository to a
* PackageDatabase.
*
@@ -151,12 +177,14 @@ namespace paludis
/**
* Override in descendents: install.
*/
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &) const = 0;
+ virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const = 0;
/**
* Override in descendents: uninstall.
*/
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const = 0;
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const = 0;
/**
* Override in descendents: package list.
@@ -386,17 +414,17 @@ namespace paludis
/**
* Install a package.
*/
- void install(const QualifiedPackageName & q, const VersionSpec & v) const
+ void install(const QualifiedPackageName & q, const VersionSpec & v, const InstallOptions & i) const
{
- do_install(q, v);
+ do_install(q, v, i);
}
/**
* Uninstall a package.
*/
- void uninstall(const QualifiedPackageName & q, const VersionSpec & v) const
+ void uninstall(const QualifiedPackageName & q, const VersionSpec & v, const InstallOptions & i) const
{
- do_uninstall(q, v);
+ do_uninstall(q, v, i);
}
/**
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index 534d22f..e2dee40 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -515,13 +515,13 @@ VDBRepository::do_is_mirror(const std::string &) const
}
void
-VDBRepository::do_install(const QualifiedPackageName &, const VersionSpec &) const
+VDBRepository::do_install(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
{
throw PackageInstallActionError("PortageRepository doesn't support do_install");
}
void
-VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v) const
+VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v, const InstallOptions & o) const
{
Context context("When uninstalling '" + stringify(q) + "-" + stringify(v) +
"' from '" + stringify(name()) + "':");
@@ -567,6 +567,7 @@ VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec &
("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
("PALUDIS_COMMAND", _imp->env->paludis_command())
("KV", kernel_version())
+ ("PALUDIS_EBUILD_OVERRIDE_CONFIG_PROTECT_MASK", o.get<io_noconfigprotect>() ? "/" : "")
("PALUDIS_EBUILD_LOG_LEVEL", Log::get_instance()->log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index d4551e6..730b22c 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -70,9 +70,10 @@ namespace paludis
virtual bool do_is_mirror(const std::string &) const;
virtual void do_install(const QualifiedPackageName &,
- const VersionSpec &) const PALUDIS_ATTRIBUTE((noreturn));
+ const VersionSpec &, const InstallOptions &) const PALUDIS_ATTRIBUTE((noreturn));
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
+ const InstallOptions &) const;
virtual DepAtom::Pointer do_package_set(const std::string &) const;
diff --git a/src/colour.hh b/src/colour.hh
index 431f375..463941a 100644
--- a/src/colour.hh
+++ b/src/colour.hh
@@ -30,10 +30,12 @@ enum Colour
cl_green = 32,
cl_yellow = 33,
cl_blue = 34,
+ cl_pink = 35,
cl_bold_red = cl_red + 100,
cl_bold_green = cl_green + 100,
cl_bold_blue = cl_blue + 100,
+ cl_bold_pink = cl_pink + 100,
cl_package_name = cl_bold_blue,
cl_flag_on = cl_green,
diff --git a/src/command_line.cc b/src/command_line.cc
index ef531c1..94107d1 100644
--- a/src/command_line.cc
+++ b/src/command_line.cc
@@ -56,6 +56,7 @@ CommandLine::CommandLine() :
install_args(this, "Install, Uninstall options"),
a_pretend(&install_args, "pretend", 'p', "Pretend only"),
a_preserve_world(&install_args, "preserve-world", '1', "Don't modify the world file"),
+ a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
dl_args(this, "DepList behaviour (use with caution)"),
a_dl_rdepend_post(&dl_args, "dl-rdepend-post", '\0', "Treat RDEPEND like PDEPEND",
diff --git a/src/command_line.hh b/src/command_line.hh
index 564889b..ce636c5 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -140,6 +140,9 @@ class CommandLine :
/// --preserve-world
paludis::args::SwitchArg a_preserve_world;
+ /// --no-config-protection
+ paludis::args::SwitchArg a_no_config_protection;
+
/// }
/// \name DepList behaviour arguments
diff --git a/src/install.cc b/src/install.cc
index b3e46b8..5de41b5 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -195,6 +195,10 @@ do_install()
if (CommandLine::get_instance()->a_pretend.specified())
return return_code;
+ p::InstallOptions opts(false, false);
+ if (CommandLine::get_instance()->a_no_config_protection.specified())
+ opts.set<io_noconfigprotect>(true);
+
for (p::DepList::Iterator dep(dep_list.begin()), dep_end(dep_list.end()) ;
dep != dep_end ; ++dep)
{
@@ -209,7 +213,7 @@ do_install()
p::stringify(max_count) + ") Installing " + cpv);
env->package_database()->fetch_repository(dep->get<p::dle_repository>())->
- install(dep->get<p::dle_name>(), dep->get<p::dle_version>());
+ install(dep->get<p::dle_name>(), dep->get<p::dle_version>(), opts);
// figure out if we need to unmerge anything
cout << endl << colour(cl_heading,
@@ -257,7 +261,7 @@ do_install()
p::stringify(max_count) + ") Cleaning " + cpv + ": " + stringify(*c));
env->package_database()->fetch_repository(c->get<p::pde_repository>())->
- uninstall(c->get<p::pde_name>(), c->get<p::pde_version>());
+ uninstall(c->get<p::pde_name>(), c->get<p::pde_version>(), opts);
}
}
}
diff --git a/src/uninstall.cc b/src/uninstall.cc
index dd7807d..8833646 100644
--- a/src/uninstall.cc
+++ b/src/uninstall.cc
@@ -107,6 +107,10 @@ do_uninstall()
env->remove_appropriate_from_world(all);
}
+ p::InstallOptions opts(false, false);
+ if (CommandLine::get_instance()->a_no_config_protection.specified())
+ opts.set<io_noconfigprotect>(true);
+
for (p::PackageDatabaseEntryCollection::Iterator pkg(unmerge->begin()), pkg_end(unmerge->end()) ;
pkg != pkg_end ; ++pkg)
{
@@ -121,7 +125,7 @@ do_uninstall()
p::stringify(max_count) + ") Uninstalling " + cpv);
env->package_database()->fetch_repository(pkg->get<p::pde_repository>())->
- uninstall(pkg->get<p::pde_name>(), pkg->get<p::pde_version>());
+ uninstall(pkg->get<p::pde_name>(), pkg->get<p::pde_version>(), opts);
}
return return_code;