X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=inc%2Frpm-installer-util.h;h=813b2a4eb85fa88aa155bd2318cfc7deae726ccf;hb=09011705882637cb333426945c689c3ba536da6f;hp=3a1bcc1cf339a1b77caa193bac8c66733544b1a1;hpb=09314103f9341d1eec5a73f82053dc101c1f1e58;p=platform%2Fcore%2Fbase%2Frpm-installer.git diff --git a/inc/rpm-installer-util.h b/inc/rpm-installer-util.h index 3a1bcc1..813b2a4 100755 --- a/inc/rpm-installer-util.h +++ b/inc/rpm-installer-util.h @@ -35,33 +35,116 @@ extern "C" { #include #include #include +#include +#include +#include +#include + + +#include +#include +#include +#include + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#define LOG_TAG "rpm-installer" +#endif + +#define _LOGE(fmt, arg...) do { \ + fprintf(stderr, " ## "fmt"\n", ##arg); \ + LOGE(fmt, ##arg); \ + } while (0) + +#define _LOGD(fmt, arg...) do { \ + fprintf(stderr, " ## "fmt"\n", ##arg); \ + LOGD(fmt, ##arg); \ + } while (0) + +#define _LOGP(fmt, arg...) fprintf(stderr, "[coretpk-installer] "fmt"\n", ##arg) #define RPM_BACKEND_EXEC "rpm-backend" -#define PKGTYPE "rpm" +#define WGT_CONFIG "config.xml" +#define SIGNATURE1_XML "signature1.xml" +#define SIGNATURE2_XML "signature2.xml" +#define AUTHOR_SIGNATURE_XML "author-signature.xml" + +#define ASCII(s) (const char *)s +#define XMLCHAR(s) (const xmlChar *)s + +#define PKG_MAX_LEN 128 +#define VERSION_MAX_LEN 11 + +#define DIRECTORY_PERMISSION_755 0755 +#define DIRECTORY_PERMISSION_644 0644 +#define FILE_PERMISSION_755 0755 +#define FILE_PERMISSION_644 0644 + +struct pkginfo_t { + char package_name[PKG_MAX_LEN]; + char version[VERSION_MAX_LEN]; +}; +typedef struct pkginfo_t pkginfo; + +struct privilegeinfo_t { + char package_id[PKG_MAX_LEN]; + int visibility; +}; +typedef struct privilegeinfo_t privilegeinfo; -#define RPM_INSTALLER_SUCCESS 0 -#define RPM_INSTALLER_ERR_WRONG_PARAM 101 +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif + +#define FREE_AND_STRDUP(from, to) do { \ + if (to) free((void *)to); \ + if (from) to = strdup(from); \ + } while (0) + + +#define FREE_AND_NULL(ptr) do { \ + if (ptr) { \ + free((void *)ptr); \ + ptr = NULL; \ + } \ + } while (0) + + +/*Error number according to Tizen Native Package Manager Command Specification v1.0*/ +#define RPM_INSTALLER_SUCCESS 0 +#define RPM_INSTALLER_ERR_WRONG_PARAM 64 #define RPM_INSTALLER_ERR_DBUS_PROBLEM 102 -#define RPM_INSTALLER_ERR_NOT_ENOUGH_MEMORY 62 -#define RPM_INSTALLER_ERR_PACKAGE_EXIST 103 -#define RPM_INSTALLER_ERR_PACKAGE_NOT_INSTALLED 104 +#define RPM_INSTALLER_ERR_PACKAGE_EXIST 121 +#define RPM_INSTALLER_ERR_PACKAGE_NOT_INSTALLED 104 #define RPM_INSTALLER_ERR_RESOURCE_BUSY 105 -#define RPM_INSTALLER_ERR_UNKNOWN 120 -#define RPM_INSTALLER_ERR_PKG_NOT_FOUND 1 -#define RPM_INSTALLER_ERR_NOT_SUPPOTED_VERSION 107 -#define RPM_INSTALLER_ERR_NO_RPM_FILE 108 +#define RPM_INSTALLER_ERR_NOT_ENOUGH_MEMORY 63 +#define RPM_INSTALLER_ERR_NOT_SUPPOTED_VERSION 107 +#define RPM_INSTALLER_ERR_NO_RPM_FILE 2 #define RPM_INSTALLER_ERR_DB_ACCESS_FAILED 109 -#define RPM_INSTALLER_ERR_RPM_OPERATION_FAILED 110 -#define RPM_INSTALLER_ERR_PACKAGE_NOT_UPGRADED 111 -#define RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS 112 -#define RPM_INSTALLER_ERR_NEED_USER_CONFIRMATION 113 +#define RPM_INSTALLER_ERR_RPM_OPERATION_FAILED 110 +#define RPM_INSTALLER_ERR_PACKAGE_NOT_UPGRADED 111 +#define RPM_INSTALLER_ERR_RPM_SCRIPT_WRONG_ARGS 112 +#define RPM_INSTALLER_ERR_NEED_USER_CONFIRMATION 113 #define RPM_INSTALLER_ERR_PACKAGE_INSTALLATION_DISABLED 114 #define RPM_INSTALLER_ERR_PACKAGE_UNINSTALLATION_DISABLED 115 #define RPM_INSTALLER_ERR_CLEAR_DATA_FAILED 116 -#define RPM_INSTALLER_ERR_INTERNAL 117 +#define RPM_INSTALLER_ERR_INTERNAL 117 +#define RPM_INSTALLER_ERR_PKG_NOT_FOUND 1 +#define RPM_INSTALLER_ERR_UNKNOWN 119 #define RPM_INSTALLER_ERR_NO_MANIFEST 11 #define RPM_INSTALLER_ERR_INVALID_MANIFEST 12 +#define RPM_INSTALLER_ERR_SIG_NOT_FOUND 21 +#define RPM_INSTALLER_ERR_SIG_INVALID 22 +#define RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED 23 +#define RPM_INSTALLER_ERR_ROOT_CERT_NOT_FOUND 31 +#define RPM_INSTALLER_ERR_CERT_INVALID 32 +#define RPM_INSTALLER_ERR_CERTCHAIN_VERIFICATION_FAILED 33 +#define RPM_INSTALLER_ERR_NO_CONFIG 34 +#define RPM_INSTALLER_ERR_INVALID_CONFIG 35 +#define RPM_INSTALLER_ERR_CMD_NOT_SUPPORTED 36 #define RPM_INSTALLER_SUCCESS_STR "Success" #define RPM_INSTALLER_ERR_WRONG_PARAM_STR "Wrong Input Param" @@ -84,29 +167,51 @@ extern "C" { #define RPM_INSTALLER_ERR_INTERNAL_STR "Internal Error" #define RPM_INSTALLER_ERR_NO_MANIFEST_STR "Manifest File Not Found" #define RPM_INSTALLER_ERR_INVALID_MANIFEST_STR "Manifest Validation Failed" - +#define RPM_INSTALLER_ERR_SIG_NOT_FOUND_STR "Signature Not Found" +#define RPM_INSTALLER_ERR_SIG_INVALID_STR "Invalid Signature" +#define RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED_STR "Signature Verification Failed" +#define RPM_INSTALLER_ERR_ROOT_CERT_NOT_FOUND_STR "Root Cert Not Found" +#define RPM_INSTALLER_ERR_CERT_INVALID_STR "Invalid Certificate" +#define RPM_INSTALLER_ERR_CERTCHAIN_VERIFICATION_FAILED_STR "Certificate Chain Verification Failed" +#define RPM_INSTALLER_ERR_NO_CONFIG_STR "Config file is not present" +#define RPM_INSTALLER_ERR_INVALID_CONFIG_STR "Config file is not valid" +#define RPM_INSTALLER_ERR_CMD_NOT_SUPPORTED_STR "Unsupported Command" #define DEBUG_ERR 0x0001 #define DEBUG_INFO 0x0002 #define DEBUG_RESULT 0x0004 #define RPM_LOG 1 +#define SIZE_KB 1024 +#define BUFF_SZE 1024 +#define RPM_INSTALLER_RW_INSTALL_PATH "/opt/usr" +#define DIR_RPM_INSTALLER_APPLICATIONS_TEMP "/tmp/wgt_unzip" +#define RPM_UNZIP "/usr/bin/unzip" +#define DIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) +#define DIR_RPM_WGT_SMACK_RULE_OPT "/opt/usr/.wgt/" - void _print_msg(int type, int exetype, char *format, ...); -#define _d_msg(type, fmtstr, args...) { \ -_print_msg(type, RPM_LOG, "%s:%d:%s(): " fmtstr, basename(__FILE__), \ -__LINE__, __func__, ##args); \ -} - - void _d_msg_init(char *program); - void _d_msg_deinit(); - int _ri_xsystem(const char *argv[]); - char *_ri_substring(const char *str, size_t begin, size_t len); - int _ri_tok_split_string(char tok, char *input, char **list, - unsigned long listmax); void _ri_error_no_to_string(int errnumber, char **errstr); + int _ri_recursive_delete_dir(char *dirname); int _ri_string_to_error_no(char *errstr); + int _ri_get_available_free_memory(const char *opt_path, unsigned long *free_mem); + int _ri_process_wgt_package(char** pkgid); + unsigned long _ri_calculate_file_size(const char *filename); + int _ri_wgt_package_extract(char *pkgid); + int _ri_stream_config_file(const char* filename, pkginfo *info); + void _ri_process_config_node(xmlTextReaderPtr reader, pkginfo * info); + int _verify_wgt_package_signature_files(); + void _ri_remove_wgt_unzip_dir(); + int _ri_xsystem(const char *argv[]); + int _get_package_name_from_xml(char* manifest,char** pkgname); + int _get_pkgname_from_rpm_name(char* pkgfile,char** pkgname); + int _child_element(xmlTextReaderPtr reader, int depth); + char *_ri_basename(char *name); + int _ri_verify_sig_and_cert(const char *sigfile, int *visibility); + char* _manifest_to_package(const char* manifest); + int _rpm_delete_dir(char *dirname); + unsigned long _ri_calculate_rpm_size( char* rpm_file); + int _ri_get_attribute(xmlTextReaderPtr reader,char *attribute, const char **xml_attribute); #ifdef __cplusplus } #endif /* __cplusplus */