Skip to content

Commit

Permalink
WIP local store on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Apr 18, 2024
1 parent b973cd4 commit 7da8987
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
File renamed without changes.
22 changes: 12 additions & 10 deletions src/libstore/unix/local-store.cc → src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@
#include <new>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
#include <utime.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <time.h>
#include <grp.h>

#ifndef _WIN32
# include <grp.h>
#endif

#if __linux__
#include <sched.h>
#include <sys/statvfs.h>
#include <sys/mount.h>
#include <sys/ioctl.h>
# include <sched.h>
# include <sys/statvfs.h>
# include <sys/mount.h>
# include <sys/ioctl.h>
#endif

#ifdef __CYGWIN__
#include <windows.h>
# include <windows.h>
#endif

#include <sqlite3.h>


namespace nix {

using namespace nix::unix;

std::string LocalStoreConfig::doc()
{
return
Expand Down Expand Up @@ -224,6 +224,7 @@ LocalStore::LocalStore(const Params & params)
}
}

#ifndef _WIN32
/* Optionally, create directories and set permissions for a
multi-user install. */
if (isRootUser() && settings.buildUsersGroup != "") {
Expand All @@ -245,6 +246,7 @@ LocalStore::LocalStore(const Params & params)
}
}
}
#endif

/* Ensure that the store and its parents are not symlinks. */
if (!settings.allowSymlinkedStore) {
Expand Down Expand Up @@ -1309,7 +1311,7 @@ StorePath LocalStore::addToStoreFromDump(
narHash = narSink.finish();
}

canonicalisePathMetaData(realPath, {}); // FIXME: merge into restorePath
canonicalisePathMetaData(realPath); // FIXME: merge into restorePath

optimisePath(realPath, repair);

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/libstore/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ else
endif
endif

$(d)/unix/local-store.cc: $(d)/unix/schema.sql.gen.hh $(d)/unix/ca-specific-schema.sql.gen.hh
$(d)/local-store.cc: $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh

$(d)/unix/build.cc:

clean-files += $(d)/unix/schema.sql.gen.hh $(d)/unix/ca-specific-schema.sql.gen.hh
clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh

$(eval $(call install-file-in, $(buildprefix)$(d)/nix-store.pc, $(libdir)/pkgconfig, 0644))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ void canonicaliseTimestampAndPermissions(const Path & path)

static void canonicalisePathMetaData_(
const Path & path,
#ifndef _WIN32
std::optional<std::pair<uid_t, uid_t>> uidRange,
#endif
InodesSeen & inodesSeen)
{
checkInterrupt();
Expand Down Expand Up @@ -145,7 +147,9 @@ static void canonicalisePathMetaData_(

void canonicalisePathMetaData(
const Path & path,
#ifndef _WIN32
std::optional<std::pair<uid_t, uid_t>> uidRange,
#endif
InodesSeen & inodesSeen)
{
canonicalisePathMetaData_(path, uidRange, inodesSeen);
Expand All @@ -161,8 +165,11 @@ void canonicalisePathMetaData(
}


void canonicalisePathMetaData(const Path & path,
std::optional<std::pair<uid_t, uid_t>> uidRange)
void canonicalisePathMetaData(const Path & path
#ifndef _WIN32
, std::optional<std::pair<uid_t, uid_t>> uidRange
#endif
)
{
InodesSeen inodesSeen;
canonicalisePathMetaData(path, uidRange, inodesSeen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ typedef std::set<Inode> InodesSeen;
* without execute permission; setuid bits etc. are cleared)
*
* - the owner and group are set to the Nix user and group, if we're
* running as root.
* running as root. (Unix only.)
*
* If uidRange is not empty, this function will throw an error if it
* encounters files owned by a user outside of the closed interval
* [uidRange->first, uidRange->second].
*/
void canonicalisePathMetaData(
const Path & path,
#ifndef _WIN32
std::optional<std::pair<uid_t, uid_t>> uidRange,
#endif
InodesSeen & inodesSeen);

void canonicalisePathMetaData(
const Path & path,
std::optional<std::pair<uid_t, uid_t>> uidRange);
const Path & path
#ifndef _WIN32
, std::optional<std::pair<uid_t, uid_t>> uidRange = std::nullopt
#endif
);

void canonicaliseTimestampAndPermissions(const Path & path);

Expand Down
File renamed without changes.

0 comments on commit 7da8987

Please sign in to comment.