31 static const char OSTREE_DEPLOYMENT_OS_NAME[] =
"dummy-os";
32 static const char OSTREE_DEPLOYMENT_VERSION_FILE[] =
"OSTREE_DEPLOYMENT_VERSION_FILE";
45 OstreeDeployment* booted_ostree_native_deployment;
52 static int isDeploymentInfoLoaded = 0;
54 if (isDeploymentInfoLoaded) {
55 return &DeploymentInfo;
58 const char* deployment_version_file = NULL;
59 if ((deployment_version_file = getenv(OSTREE_DEPLOYMENT_VERSION_FILE)) == NULL) {
63 if (get_ostree_deployment_version(deployment_version_file, &DeploymentInfo.deployed, &DeploymentInfo.booted) != 0) {
69 DeploymentInfo.booted_ostree_native_deployment =
70 ostree_deployment_new(0, OSTREE_DEPLOYMENT_OS_NAME, DeploymentInfo.deployed.rev, DeploymentInfo.deployed.serial,
71 DeploymentInfo.booted.rev, DeploymentInfo.booted.serial);
73 assert(DeploymentInfo.booted_ostree_native_deployment != NULL);
75 isDeploymentInfoLoaded = 1;
77 return &DeploymentInfo;
80 const char* ostree_deployment_get_csum(OstreeDeployment*
self) {
81 const char* (*orig)(OstreeDeployment*) = (
const char* (*)(OstreeDeployment*))(dlsym(RTLD_NEXT, __func__));
84 if (deployment_info != NULL) {
85 return deployment_info->deployed.rev;
91 OstreeDeployment* ostree_sysroot_get_booted_deployment(OstreeSysroot*
self) {
92 OstreeDeployment* (*orig)(OstreeSysroot*) = (OstreeDeployment * (*)(OstreeSysroot*))(dlsym(RTLD_NEXT, __func__));
95 if (deployment_info != NULL) {
96 return deployment_info->booted_ostree_native_deployment;
106 if (fscanf(file,
"%254s\n", deployment_res.rev) != 1) {
112 if (fscanf(file,
"%d\n", &deployment_res.serial) != 1) {
116 *deployment = deployment_res;
122 FILE* file = fopen(filename,
"r");
124 printf(
"\n>>>>>>>>>> Failed to open the file: %s\n\n", filename);
128 int return_code = -1;
132 if (read_deployment_info(file, &deployed_res) != 0) {
136 if (booted != NULL) {
138 if (read_deployment_info(file, &booted_res) != 0) {
141 *booted = booted_res;
144 *deployed = deployed_res;
149 if (return_code != 0) {
150 printf(
"%s: Failed to read the deployment info from: %s\n", __FILE__, filename);