Merge branch 'master' into core-updates
This commit is contained in:
commit
5cc4517590
|
@ -324,8 +324,7 @@ held."
|
||||||
(rename-file source target)
|
(rename-file source target)
|
||||||
|
|
||||||
;; Register TARGET. As a side effect, it resets the timestamps of all
|
;; Register TARGET. As a side effect, it resets the timestamps of all
|
||||||
;; its files, recursively. However, it doesn't attempt to deduplicate
|
;; its files, recursively, and runs a deduplication pass.
|
||||||
;; its files like 'importPaths' does (FIXME).
|
|
||||||
(register-path target
|
(register-path target
|
||||||
#:references references
|
#:references references
|
||||||
#:deriver deriver))
|
#:deriver deriver))
|
||||||
|
|
|
@ -393,7 +393,7 @@ MANIFEST."
|
||||||
(define (info-files top)
|
(define (info-files top)
|
||||||
(let ((infodir (string-append top "/share/info")))
|
(let ((infodir (string-append top "/share/info")))
|
||||||
(map (cut string-append infodir "/" <>)
|
(map (cut string-append infodir "/" <>)
|
||||||
(scandir infodir info-file?))))
|
(or (scandir infodir info-file?) '()))))
|
||||||
|
|
||||||
(define (install-info info)
|
(define (install-info info)
|
||||||
(zero?
|
(zero?
|
||||||
|
|
|
@ -57,6 +57,7 @@ information about which store files are valid, and what their \
|
||||||
references are.";
|
references are.";
|
||||||
|
|
||||||
#define GUIX_OPT_STATE_DIRECTORY 1
|
#define GUIX_OPT_STATE_DIRECTORY 1
|
||||||
|
#define GUIX_OPT_DEDUPLICATE 2
|
||||||
|
|
||||||
static const struct argp_option options[] =
|
static const struct argp_option options[] =
|
||||||
{
|
{
|
||||||
|
@ -64,6 +65,8 @@ static const struct argp_option options[] =
|
||||||
"Open the store that lies under DIRECTORY" },
|
"Open the store that lies under DIRECTORY" },
|
||||||
{ "state-directory", GUIX_OPT_STATE_DIRECTORY, "DIRECTORY", 0,
|
{ "state-directory", GUIX_OPT_STATE_DIRECTORY, "DIRECTORY", 0,
|
||||||
"Use DIRECTORY as the state directory of the target store" },
|
"Use DIRECTORY as the state directory of the target store" },
|
||||||
|
{ "no-deduplication", GUIX_OPT_DEDUPLICATE, 0, 0,
|
||||||
|
"Disable automatic deduplication of registered store items" },
|
||||||
{ 0, 0, 0, 0, 0 }
|
{ 0, 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,6 +74,9 @@ static const struct argp_option options[] =
|
||||||
/* Prefix of the store being populated. */
|
/* Prefix of the store being populated. */
|
||||||
static std::string prefix;
|
static std::string prefix;
|
||||||
|
|
||||||
|
/* Whether to deduplicate the registered store items. */
|
||||||
|
static bool deduplication = true;
|
||||||
|
|
||||||
/* Parse a single option. */
|
/* Parse a single option. */
|
||||||
static error_t
|
static error_t
|
||||||
parse_opt (int key, char *arg, struct argp_state *state)
|
parse_opt (int key, char *arg, struct argp_state *state)
|
||||||
|
@ -97,6 +103,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GUIX_OPT_DEDUPLICATE:
|
||||||
|
deduplication = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
{
|
{
|
||||||
std::ifstream *file;
|
std::ifstream *file;
|
||||||
|
@ -136,6 +146,7 @@ static struct argp argp = { options, parse_opt, 0, doc };
|
||||||
This is really meant as an internal format. */
|
This is really meant as an internal format. */
|
||||||
static void
|
static void
|
||||||
register_validity (LocalStore *store, std::istream &input,
|
register_validity (LocalStore *store, std::istream &input,
|
||||||
|
bool optimize = true,
|
||||||
bool reregister = true, bool hashGiven = false,
|
bool reregister = true, bool hashGiven = false,
|
||||||
bool canonicalise = true)
|
bool canonicalise = true)
|
||||||
{
|
{
|
||||||
|
@ -176,6 +187,19 @@ register_validity (LocalStore *store, std::istream &input,
|
||||||
}
|
}
|
||||||
|
|
||||||
store->registerValidPaths (infos);
|
store->registerValidPaths (infos);
|
||||||
|
|
||||||
|
/* XXX: When PREFIX is non-empty, store->linksDir points to the original
|
||||||
|
store's '.links' directory, which means 'optimisePath' would try to link
|
||||||
|
to that instead of linking to the target store. Thus, disable
|
||||||
|
deduplication in this case. */
|
||||||
|
if (optimize && prefix.empty ())
|
||||||
|
{
|
||||||
|
/* Make sure deduplication is enabled. */
|
||||||
|
settings.autoOptimiseStore = true;
|
||||||
|
|
||||||
|
foreach (ValidPathInfos::const_iterator, i, infos)
|
||||||
|
store->optimisePath (i->path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,17 +224,17 @@ main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argp_parse (&argp, argc, argv, 0, 0, 0);
|
argp_parse (&argp, argc, argv, 0, 0, 0);
|
||||||
|
|
||||||
/* Instantiate the store. This creates any missing directories among
|
|
||||||
'settings.nixStore', 'settings.nixDBPath', etc. */
|
|
||||||
LocalStore store;
|
|
||||||
|
|
||||||
if (!prefix.empty ())
|
if (!prefix.empty ())
|
||||||
/* Under the --prefix tree, the final name of the store will be
|
/* Under the --prefix tree, the final name of the store will be
|
||||||
NIX_STORE_DIR. Set it here so that the database uses file names
|
NIX_STORE_DIR. Set it here so that the database uses file names
|
||||||
prefixed by NIX_STORE_DIR and not PREFIX + NIX_STORE_DIR. */
|
prefixed by NIX_STORE_DIR and not PREFIX + NIX_STORE_DIR. */
|
||||||
settings.nixStore = NIX_STORE_DIR;
|
settings.nixStore = NIX_STORE_DIR;
|
||||||
|
|
||||||
register_validity (&store, *input);
|
/* Instantiate the store. This creates any missing directories among
|
||||||
|
'settings.nixStore', 'settings.nixDBPath', etc. */
|
||||||
|
LocalStore store;
|
||||||
|
|
||||||
|
register_validity (&store, *input, deduplication);
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
# Usage: ./pre-inst-env COMMAND ARG...
|
# Usage: ./pre-inst-env COMMAND ARG...
|
||||||
#
|
#
|
||||||
# Run COMMAND in a pre-installation environment. Typical use is
|
# Run COMMAND in a pre-installation environment. Typical use is
|
||||||
# "./pre-inst-env guix-build hello".
|
# "./pre-inst-env guix build hello".
|
||||||
|
|
||||||
# By default we may end up with absolute directory names that contain '..',
|
# By default we may end up with absolute directory names that contain '..',
|
||||||
# which get into $GUILE_LOAD_PATH, leading to '..' in the module file names
|
# which get into $GUILE_LOAD_PATH, leading to '..' in the module file names
|
||||||
|
|
|
@ -43,13 +43,28 @@ $new_file
|
||||||
0
|
0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Make sure it's valid, and delete it.
|
# Register an idendical file, and make sure it gets deduplicated.
|
||||||
|
new_file2="$new_file-duplicate"
|
||||||
|
cat "$new_file" > "$new_file2"
|
||||||
|
guix-register <<EOF
|
||||||
|
$new_file2
|
||||||
|
|
||||||
|
0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
guile -c "
|
||||||
|
(exit (= (stat:ino (stat \"$new_file\"))
|
||||||
|
(stat:ino (stat \"$new_file2\"))))"
|
||||||
|
|
||||||
|
# Make sure both are valid, and delete them.
|
||||||
guile -c "
|
guile -c "
|
||||||
(use-modules (guix store))
|
(use-modules (guix store))
|
||||||
(define s (open-connection))
|
(define s (open-connection))
|
||||||
(exit (and (valid-path? s \"$new_file\")
|
(exit (and (valid-path? s \"$new_file\")
|
||||||
|
(valid-path? s \"$new_file2\")
|
||||||
(null? (references s \"$new_file\"))
|
(null? (references s \"$new_file\"))
|
||||||
(pair? (delete-paths s (list \"$new_file\")))))"
|
(null? (references s \"$new_file2\"))
|
||||||
|
(pair? (delete-paths s (list \"$new_file\" \"$new_file2\")))))"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue