%cmake . \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DLIBISU_VERSION=%{libisu_version} \
- -DCHECK_ISU_FEATURE=OFF
+ -DCHECK_ISU_FEATURE=OFF \
+ -DSYSTEMD_DIR:PATH=%{_unitdir}
make %{?_smp_mflags}
%install
install -m644 config/upgrade.cfg %{buildroot}/etc/isu/upgrade.cfg
install -m750 src/pkg_manager/isu %{buildroot}/%{_bindir}/isu.sh
+%install_service delayed.target.wants %{name}-cleaner.service
+
%files
%manifest isu.manifest
%license LICENSE.MIT
/etc/isu/upgrade.cfg
%{_bindir}/isu.sh
%{_bindir}/isu
+%{_bindir}/isu-cleaner
+%{_unitdir}/%{name}-cleaner.service
+%{_unitdir}/delayed.target.wants/%{name}-cleaner.service
%files tools
%manifest isu.manifest
--- /dev/null
+INCLUDE(GNUInstallDirs)
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(deps REQUIRED "glib-2.0 gio-2.0 capi-system-info dlog")
+
+ADD_EXECUTABLE(isu-cleaner isu-cleaner.c)
+SET_TARGET_PROPERTIES(isu-cleaner PROPERTIES OUTPUT_NAME "isu-cleaner")
+TARGET_INCLUDE_DIRECTORIES(isu-cleaner PRIVATE . ${deps_INCLUDE_DIRS} ../libisu/)
+TARGET_LINK_LIBRARIES(isu-cleaner PUBLIC isu -pie -larchive ${deps_LIBRARIES})
+
+INSTALL(TARGETS isu-cleaner DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/isu-cleaner.service DESTINATION ${SYSTEMD_DIR})
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <assert.h>
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "libisu-internal.h"
+
+#define LOG_TAG "ISUCLEANER"
+#include <dlog/dlog.h>
+
+#define ISU_APP_PATH "/opt/usr/globalapps"
+#define ISU_APP_PREFIX "org.tizen.isu."
+
+int main(int argc, char *argv[])
+{
+ DIR *dir = opendir(ISU_APP_PATH);
+
+ if (dir == NULL) {
+ SLOGE("Open dir %s error (%d): %m\n", ISU_APP_PATH, errno);
+ return ISU_RES_ERR_NOT_EXIST;
+ }
+
+ struct dirent *entry;
+ int result = 0;
+ while ((entry = readdir(dir)) != NULL) {
+ if (entry->d_type != DT_DIR) continue;
+
+ char pathbuff[PATH_MAX];
+ snprintf(pathbuff, sizeof(pathbuff), "%s/%s", ISU_APP_PATH, entry->d_name);
+ if (strcmp(entry->d_name, ".") == 0
+ || strcmp(entry->d_name, "..") == 0
+ || strncmp(entry->d_name, ISU_APP_PREFIX, sizeof(ISU_APP_PREFIX)-1))
+ continue;
+ result = remove_dir_contents(pathbuff);
+ if (result != 0) {
+ SLOGE("Can't remove unnecessary files from apps path: %s (result: %d)", pathbuff, result);
+ break;
+ }
+ }
+
+ if (result == 0)
+ SLOGE("ISU clean-up succeded.");
+ else
+ SLOGE("ISU clean-up failed.");
+
+ closedir(dir);
+ return result;
+}