Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dbp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
packages
dbp
Commits
733143ec
Commit
733143ec
authored
Nov 01, 2015
by
Steven Arnow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed struct and function namespace of libdbpbase to better fit that of a shared library
parent
b36a2815
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
206 additions
and
331 deletions
+206
-331
dbp-cfg/main.c
dbp-cfg/main.c
+5
-5
dbp-desktopd/desktopd.c
dbp-desktopd/desktopd.c
+4
-4
dbp-meta/dbp-meta.c
dbp-meta/dbp-meta.c
+6
-6
dbp-run/common/dbp.vapi
dbp-run/common/dbp.vapi
+15
-22
dbp-run/dep-check/deb_dep_check.c
dbp-run/dep-check/deb_dep_check.c
+0
-88
dbp-run/dep-check/deb_dep_check.h
dbp-run/dep-check/deb_dep_check.h
+0
-9
dbp-run/dep-check/deb_dep_check.nodpkg.c
dbp-run/dep-check/deb_dep_check.nodpkg.c
+0
-16
dbpd/daemon.c
dbpd/daemon.c
+14
-14
dbpd/mountwatch.c
dbpd/mountwatch.c
+2
-2
dbpd/package.c
dbpd/package.c
+41
-41
dbpd/state.c
dbpd/state.c
+18
-18
libdbpbase/config.c
libdbpbase/config.c
+17
-22
libdbpbase/config.h
libdbpbase/config.h
+9
-9
libdbpbase/desktop.c
libdbpbase/desktop.c
+25
-25
libdbpbase/desktop.h
libdbpbase/desktop.h
+18
-18
libdbpbase/loop.c
libdbpbase/loop.c
+21
-21
libdbpbase/loop.h
libdbpbase/loop.h
+6
-6
libdbpbase/meta.c
libdbpbase/meta.c
+2
-2
libdbpbase/meta.h
libdbpbase/meta.h
+3
-3
No files found.
dbp-cfg/main.c
View file @
733143ec
...
...
@@ -11,14 +11,14 @@ FILE *dbp_error_log;
void
usage
(
char
*
name
)
{
fprintf
(
stderr
,
_
(
"Extracts configuration keys out of the DBP config
\n
"
));
fprintf
(
stderr
,
_
(
"By Steven Arnow, 2015, version %s
\n
"
),
config_version_get
());
fprintf
(
stderr
,
_
(
"By Steven Arnow, 2015, version %s
\n
"
),
dbp_
config_version_get
());
fprintf
(
stderr
,
"
\n
"
);
fprintf
(
stderr
,
_
(
"Usage: %s <config key>
\n
"
),
name
);
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
desktop_file_s
*
df
;
struct
DBPDesktopFile
*
df
;
const
char
*
value
;
dbp_error_log
=
stderr
;
...
...
@@ -31,12 +31,12 @@ int main(int argc, char **argv) {
if
(
!
strcmp
(
argv
[
1
],
"--help"
))
return
usage
(
argv
[
0
]),
0
;
if
(
!
(
df
=
d
esktop_parse_file
(
CONFIG_FILE_PATH
)))
{
fprintf
(
stderr
,
_
(
"Unable to open config file %s
\n
"
),
CONFIG_FILE_PATH
);
if
(
!
(
df
=
d
bp_desktop_parse_file
(
DBP_
CONFIG_FILE_PATH
)))
{
fprintf
(
stderr
,
_
(
"Unable to open config file %s
\n
"
),
DBP_
CONFIG_FILE_PATH
);
return
-
1
;
}
if
(
!
(
value
=
desktop_lookup
(
df
,
argv
[
1
],
""
,
"Package Daemon Config"
)))
{
if
(
!
(
value
=
d
bp_d
esktop_lookup
(
df
,
argv
[
1
],
""
,
"Package Daemon Config"
)))
{
fprintf
(
stderr
,
_
(
"Key '%s' doesn't exist in config
\n
"
),
argv
[
1
]);
return
-
1
;
}
...
...
dbp-desktopd/desktopd.c
View file @
733143ec
...
...
@@ -109,14 +109,14 @@ static void add_package_meta(char *pkg_id) {
asprintf
(
&
prefix
,
"__dbp__%s_"
,
pkg_id
);
if
(
!
(
dir_s
=
opendir
(
config_struct
.
desktop_directory
)))
{
fprintf
(
stderr
,
"Unable to open '%s' for directory list
\n
"
,
config_struct
.
desktop_directory
);
if
(
!
(
dir_s
=
opendir
(
dbp_
config_struct
.
desktop_directory
)))
{
fprintf
(
stderr
,
"Unable to open '%s' for directory list
\n
"
,
dbp_
config_struct
.
desktop_directory
);
return
free
(
prefix
);
}
for
(
readdir_r
(
dir_s
,
&
ent
,
&
result
);
result
;
readdir_r
(
dir_s
,
&
ent
,
&
result
))
{
if
(
HAS_PREFIX
(
ent
.
d_name
,
prefix
)
&&
HAS_SUFFIX
(
ent
.
d_name
,
".desktop"
))
{
asprintf
(
&
source
,
"%s/%s"
,
config_struct
.
desktop_directory
,
ent
.
d_name
);
asprintf
(
&
source
,
"%s/%s"
,
dbp_
config_struct
.
desktop_directory
,
ent
.
d_name
);
add_meta
(
source
,
0
);
free
(
source
);
}
...
...
@@ -136,7 +136,7 @@ int main(int argc, char **argv) {
struct
DBPList
*
list
,
*
next
;
(
void
)
argc
;
(
void
)
argv
;
dbp_error_log
=
stderr
;
config_init
();
dbp_
config_init
();
if
(
!
(
desktop_directory
=
find_desktop
()))
return
1
;
nuke_desktop
(
desktop_directory
);
...
...
dbp-meta/dbp-meta.c
View file @
733143ec
...
...
@@ -9,7 +9,7 @@ FILE *dbp_error_log;
void
usage
()
{
fprintf
(
stdout
,
_
(
"Extracts meta keys from a DBP
\n
"
));
fprintf
(
stdout
,
_
(
"By Steven Arnow, 2015, version %s
\n
"
),
config_version_get
());
fprintf
(
stdout
,
_
(
"By Steven Arnow, 2015, version %s
\n
"
),
dbp_
config_version_get
());
fprintf
(
stdout
,
"
\n
"
);
fprintf
(
stdout
,
_
(
"Usage:
\n
"
));
fprintf
(
stdout
,
_
(
"dbp-meta list <path-to-dbp> - lists all meta keys for the package
\n
"
));
...
...
@@ -18,7 +18,7 @@ void usage() {
int
main
(
int
argc
,
char
**
argv
)
{
struct
meta_package_s
mp
;
struct
DBPMetaPackage
mp
;
const
char
*
str
;
setlocale
(
LC_ALL
,
""
);
...
...
@@ -30,7 +30,7 @@ int main(int argc, char **argv) {
return
1
;
}
if
(
meta_package_open
(
argv
[
2
],
&
mp
))
{
if
(
dbp_
meta_package_open
(
argv
[
2
],
&
mp
))
{
fprintf
(
stderr
,
_
(
"Unable to open package %s
\n
"
),
argv
[
2
]);
return
1
;
}
...
...
@@ -38,7 +38,7 @@ int main(int argc, char **argv) {
if
(
!
strcmp
(
argv
[
1
],
"list"
))
{
int
section
,
i
;
section
=
desktop_lookup_section
(
mp
.
df
,
mp
.
section
);
section
=
d
bp_d
esktop_lookup_section
(
mp
.
df
,
mp
.
section
);
for
(
i
=
0
;
i
<
mp
.
df
->
section
[
section
].
entries
;
i
++
)
fprintf
(
stdout
,
"%s[%s]=
\"
%s
\"\n
"
,
mp
.
df
->
section
[
section
].
entry
[
i
].
key
,
mp
.
df
->
section
[
section
].
entry
[
i
].
locale
,
mp
.
df
->
section
[
section
].
entry
[
i
].
value
);
return
0
;
...
...
@@ -52,9 +52,9 @@ int main(int argc, char **argv) {
}
if
(
argc
<
5
)
str
=
desktop_lookup
(
mp
.
df
,
argv
[
3
],
""
,
mp
.
section
);
str
=
d
bp_d
esktop_lookup
(
mp
.
df
,
argv
[
3
],
""
,
mp
.
section
);
else
str
=
desktop_lookup
(
mp
.
df
,
argv
[
3
],
argv
[
4
],
mp
.
section
);
str
=
d
bp_d
esktop_lookup
(
mp
.
df
,
argv
[
3
],
argv
[
4
],
mp
.
section
);
if
(
str
)
fprintf
(
stdout
,
"%s
\n
"
,
str
);
return
0
;
...
...
dbp-run/common/dbp.vapi
View file @
733143ec
...
...
@@ -46,7 +46,7 @@ namespace DBP {
[CCode (cheader_filename = "config.h")]
namespace Config {
[CCode (cname = "struct
config_s
", has_type_id = false)]
[CCode (cname = "struct
DBPConfig
", has_type_id = false)]
struct Config {
[CCode (array_length_cname = "file_extensions", array_length_type = "int")]
string[] file_extension;
...
...
@@ -83,59 +83,52 @@ namespace DBP {
Desktop df;
}
[CCode (cname = "config_struct")]
[CCode (cname = "
dbp_
config_struct")]
Config config;
[CCode (cprefix = "CONFIG_")]
[CCode (cprefix = "
DBP_
CONFIG_")]
public const string FILE_PATH;
[CCode (cname = "config_init")]
[CCode (cname = "
dbp_
config_init")]
void init();
[CCode (cname = "config_version_get")]
[CCode (cname = "
dbp_
config_version_get")]
public unowned string version();
}
[CCode (cheader_filename = "desktop.h", cname = "struct
desktop_file_s", free_function = "
desktop_free")]
[CCode (cheader_filename = "desktop.h", cname = "struct
DBPDesktopFile", free_function = "dbp_
desktop_free")]
[Compact]
public class Desktop {
[CCode (cname = "desktop_parse")]
[CCode (cname = "d
bp_d
esktop_parse")]
public Desktop(char[] str);
[CCode (cname = "desktop_parse_file")]
[CCode (cname = "d
bp_d
esktop_parse_file")]
public Desktop.from_file(string path);
[CCode (cname = "desktop_write")]
[CCode (cname = "d
bp_d
esktop_write")]
public void write(string path);
[CCode (cname = "desktop_lookup")]
[CCode (cname = "d
bp_d
esktop_lookup")]
public unowned string? lookup(string key, string locale, string section);
[CCode (cname = "desktop_lookup_section")]
[CCode (cname = "d
bp_d
esktop_lookup_section")]
public int lookup_section(string section);
[CCode (cname = "desktop_lookup_entry")]
[CCode (cname = "d
bp_d
esktop_lookup_entry")]
public int lookup_entry(string key, string locale, int section);
}
[CCode (cheader_filename = "loop.h", cprefix = "loop_")]
[CCode (cheader_filename = "loop.h", cprefix = "
dbp_
loop_")]
namespace Loop {
int mount(string image, string id, string user, string src_mount, string appdata);
void umount(string pkg_id, int loop, string user);
int directory_setup(string path, int umask);
}
[CCode (cheader_filename = "deb_dep_check.h", cprefix = "deb_")]
namespace DebDepCheck {
void do_init();
void do_free();
bool check_package(string pkgname, string package_arch);
}
[CCode (cheader_filename = "meta.h")]
namespace Meta {
[CCode (cname = "struct
meta_package_s
", has_type_id = false, destroy_function = "", default_value = "{}")]
[CCode (cname = "struct
DBPMetaPackage
", has_type_id = false, destroy_function = "", default_value = "{}")]
public struct Package {
[CCode (cname = "df")]
Desktop desktop_file;
string section;
}
[CCode (cname = "meta_package_open")]
[CCode (cname = "
dbp_
meta_package_open")]
int package_open(string path, out Package mp);
}
...
...
dbp-run/dep-check/deb_dep_check.c
deleted
100644 → 0
View file @
b36a2815
/* deb_dep_check.c - Steven Arnow <s@rdw.se>, 2014 */
#define LIBDPKG_VOLATILE_API
#include <stdlib.h>
#include <string.h>
#include <dpkg/dpkg.h>
#include <dpkg/arch.h>
#include <dpkg/dpkg-db.h>
#include <dbpmgr/dbpmgr.h>
#if 0
/* Defines for old versions of libdpkg (wheezy) */
#ifndef DPKG_ARCH_NATIVE
#define DPKG_ARCH_NATIVE arch_native
#endif
#ifndef enum pkgstatus
#define PKG_STAT_INSTALLED stat_installed
#endif
#endif
void
dbp_deb_dep_check_do_init
()
{
push_error_context
();
dpkg_db_set_dir
(
NULL
);
modstatdb_open
(
msdbrw_readonly
);
}
void
dbp_deb_dep_check_do_free
()
{
modstatdb_done
();
pop_error_context
(
ehflag_normaltidy
);
}
int
dbp_deb_dep_check_check_package
(
const
char
*
pkgname
,
const
char
*
main_arch
)
{
struct
pkgset
*
pkg
;
struct
dpkg_arch
*
arch
;
struct
dpkg_version
in_ver
;
struct
dpkg_error
err
;
int
flags
,
ver_match
;
char
*
pkgstr
,
*
version
,
*
pkg_arch
;
fprintf
(
stderr
,
"%s %s
\n
"
,
pkgname
,
main_arch
);
dpkg_version_blank
(
&
in_ver
);
if
(
parseversion
(
&
in_ver
,
version
,
&
err
))
{
fprintf
(
stderr
,
"Invalid package version in package
\n
"
);
return
0
;
}
pkgstr
=
strdup
(
pkgname
);
flags
=
extract_version_arch
(
pkgstr
,
&
version
,
&
pkg_arch
,
main_arch
);
pkg
=
pkg_db_find_set
(
pkgstr
);
if
(
!
pkg
)
return
(
free
(
pkgstr
),
0
);
for
(;
pkg
;
pkg
=
pkg
->
next
)
{
//fprintf(stderr, "pkg=%s\n", pkgstr);
if
(
strcmp
(
pkg
->
name
,
pkgstr
))
continue
;
if
(
pkg
->
pkg
.
status
!=
PKG_STAT_INSTALLED
)
continue
;
for
(
arch
=
(
struct
dpkg_arch
*
)
pkg
->
pkg
.
installed
.
arch
;
arch
;
arch
=
(
struct
dpkg_arch
*
)
arch
->
next
)
{
if
(
strcmp
(
arch
->
name
,
"any"
)
&&
strcmp
(
arch
->
name
,
"all"
)
&&
strcmp
(
arch
->
name
,
pkg_arch
)
&&
strcmp
(
pkg_arch
,
"any"
))
continue
;
//fprintf(stderr, "Arch: %s\n", arch->name);
ver_match
=
dpkg_version_compare
(
&
pkg
->
pkg
.
installed
.
version
,
&
in_ver
);
//fprintf(stderr, "Version comparison: %i\n", ver_match);
free
(
pkgstr
);
/* TODO: Use dpkg built in functions for this when dpkg changes have calmed down */
if
((
flags
&
1
)
&&
ver_match
<
0
)
return
1
;
if
((
flags
&
2
)
&&
!
ver_match
)
return
1
;
if
((
flags
&
4
)
&&
ver_match
>
0
)
return
1
;
return
0
;
}
}
free
(
pkgstr
);
return
0
;
}
/* Nothing's ever going to change, is it? */
dbp-run/dep-check/deb_dep_check.h
deleted
100644 → 0
View file @
b36a2815
#ifndef __DEB_DEP_CHECK_H__
#define __DEB_DEP_CHECK_H__
void
deb_do_init
();
void
deb_do_free
();
int
dbp_deb_dep_check_check_package
(
const
char
*
pkgname
,
const
char
*
wanted_arch
);
#endif
dbp-run/dep-check/deb_dep_check.nodpkg.c
deleted
100644 → 0
View file @
b36a2815
/* deb_dep_check.c - Steven Arnow <s@rdw.se>, 2014 */
#include <stdlib.h>
#include <string.h>
void
dbp_deb_dep_check_do_init
()
{
}
void
dbp_deb_dep_check_do_free
()
{
}
int
dbp_deb_dep_check_check_package
(
const
char
*
pkgname
,
const
char
*
wanted_arch
)
{
return
1
;
}
dbpd/daemon.c
View file @
733143ec
...
...
@@ -70,10 +70,10 @@ static int daemon_nuke_execs() {
FILE
*
fp
;
char
buff
[
512
],
path
[
PATH_MAX
];
if
(
!
(
d
=
opendir
(
config_struct
.
exec_directory
)))
if
(
!
(
d
=
opendir
(
dbp_
config_struct
.
exec_directory
)))
return
0
;
for
(
readdir_r
(
d
,
&
de
,
&
result
);
result
;
readdir_r
(
d
,
&
de
,
&
result
))
{
snprintf
(
path
,
PATH_MAX
,
"%s/%s"
,
config_struct
.
exec_directory
,
de
.
d_name
);
snprintf
(
path
,
PATH_MAX
,
"%s/%s"
,
dbp_
config_struct
.
exec_directory
,
de
.
d_name
);
if
(
!
(
fp
=
fopen
(
path
,
"r"
)))
continue
;
*
buff
=
0
;
...
...
@@ -93,8 +93,8 @@ static int daemon_nuke_execs() {
static
int
daemon_nuke
()
{
if
(
!
daemon_nuke_dir
(
config_struct
.
desktop_directory
));
else
if
(
!
daemon_nuke_dir
(
config_struct
.
icon_directory
));
if
(
!
daemon_nuke_dir
(
dbp_
config_struct
.
desktop_directory
));
else
if
(
!
daemon_nuke_dir
(
dbp_
config_struct
.
icon_directory
));
else
if
(
!
daemon_nuke_execs
());
else
return
1
;
...
...
@@ -103,12 +103,12 @@ static int daemon_nuke() {
static
int
daemon_init
()
{
if
(
!
loop_directory_setup
(
config_struct
.
img_mount
,
0755
));
else
if
(
!
loop_directory_setup
(
config_struct
.
union_mount
,
0755
));
else
if
(
!
loop_directory_setup
(
config_struct
.
icon_directory
,
0755
));
else
if
(
!
loop_directory_setup
(
config_struct
.
exec_directory
,
0755
));
else
if
(
!
loop_directory_setup
(
config_struct
.
desktop_directory
,
0755
));
else
if
(
!
loop_directory_setup
(
config_struct
.
dbpout_directory
,
0777
));
if
(
!
dbp_loop_directory_setup
(
dbp_
config_struct
.
img_mount
,
0755
));
else
if
(
!
dbp_loop_directory_setup
(
dbp_
config_struct
.
union_mount
,
0755
));
else
if
(
!
dbp_loop_directory_setup
(
dbp_
config_struct
.
icon_directory
,
0755
));
else
if
(
!
dbp_loop_directory_setup
(
dbp_
config_struct
.
exec_directory
,
0755
));
else
if
(
!
dbp_loop_directory_setup
(
dbp_
config_struct
.
desktop_directory
,
0755
));
else
if
(
!
dbp_loop_directory_setup
(
dbp_
config_struct
.
dbpout_directory
,
0777
));
else
if
(
!
daemon_nuke
());
else
return
1
;
...
...
@@ -143,15 +143,15 @@ int main(int argc, char **argv) {
dbp_error_log
=
stderr
;
p_s
=
&
p
;
if
(
!
config_init
())
if
(
!
dbp_
config_init
())
return
-
1
;
if
(
!
(
dbp_error_log
=
fopen
(
config_struct
.
daemon_log
,
"w"
)))
{
if
(
!
(
dbp_error_log
=
fopen
(
dbp_
config_struct
.
daemon_log
,
"w"
)))
{
dbp_error_log
=
stderr
;
fprintf
(
stderr
,
"Unable to open %s
\n
"
,
config_struct
.
daemon_log
);
fprintf
(
stderr
,
"Unable to open %s
\n
"
,
dbp_
config_struct
.
daemon_log
);
}
else
setbuf
(
dbp_error_log
,
NULL
);
fprintf
(
dbp_error_log
,
"DBPd version %s starting...
\n
"
,
config_version_get
());
fprintf
(
dbp_error_log
,
"DBPd version %s starting...
\n
"
,
dbp_
config_version_get
());
p
=
package_init
();
state_recover
(
&
p
);
...
...
dbpd/mountwatch.c
View file @
733143ec
...
...
@@ -171,8 +171,8 @@ static void mountwatch_inotify_add(const char *mount, const char *device) {
char
path
[
PATH_MAX
];
int
i
;
for
(
i
=
0
;
i
<
config_struct
.
search_dirs
;
i
++
)
{
sprintf
(
path
,
"%s/%s"
,
mount
,
config_struct
.
search_dir
[
i
]);
for
(
i
=
0
;
i
<
dbp_
config_struct
.
search_dirs
;
i
++
)
{
sprintf
(
path
,
"%s/%s"
,
mount
,
dbp_
config_struct
.
search_dir
[
i
]);
mountwatch_inotify_add_entry
(
mount
,
device
,
path
);
}
...
...
dbpd/package.c
View file @
733143ec
...
...
@@ -39,11 +39,11 @@ struct package_s package_init() {
static
int
package_filename_interesting
(
const
char
*
path
)
{
int
i
;
for
(
i
=
0
;
i
<
config_struct
.
file_extensions
;
i
++
)
{
if
(
strlen
(
path
)
<
strlen
(
config_struct
.
file_extension
[
i
]))
for
(
i
=
0
;
i
<
dbp_
config_struct
.
file_extensions
;
i
++
)
{
if
(
strlen
(
path
)
<
strlen
(
dbp_
config_struct
.
file_extension
[
i
]))
continue
;
if
(
!
strcmp
(
&
path
[
strlen
(
path
)
-
strlen
(
config_struct
.
file_extension
[
i
])],
config_struct
.
file_extension
[
i
]))
if
(
!
strcmp
(
&
path
[
strlen
(
path
)
-
strlen
(
dbp_
config_struct
.
file_extension
[
i
])],
dbp_
config_struct
.
file_extension
[
i
]))
return
1
;
}
return
0
;
...
...
@@ -96,7 +96,7 @@ static int package_add(struct package_s *p, char *path, char *id, char *device,
p
->
entry
[
nid
].
appdata
=
appdata
;
p
->
entry
[
nid
].
sys_dep
=
sys
;
p
->
entry
[
nid
].
pkg_dep
=
pkg
;
p
->
entry
[
nid
].
desktop
=
strdup
(
loop_desktop_directory
(
path
)
?
"desk"
:
"nodesk"
);
p
->
entry
[
nid
].
desktop
=
strdup
(
dbp_
loop_desktop_directory
(
path
)
?
"desk"
:
"nodesk"
);
p
->
entry
[
nid
].
exec
=
NULL
,
p
->
entry
[
nid
].
execs
=
0
;
comm_dbus_announce_new_package
(
id
);
...
...
@@ -138,40 +138,40 @@ static const char *find_filename(const char *path) {
static
void
package_desktop_write
(
struct
package_s
*
p
,
int
id
,
const
char
*
fname
,
char
*
data
,
int
announce
)
{
char
writename
[
PATH_MAX
],
*
override_path
;
const
char
*
pkg_id
=
p
->
entry
[
id
].
id
;
struct
desktop_file_s
*
df
;
struct
DBPDesktopFile
*
df
;
int
sec
,
ent
;
FILE
*
fp
;
asprintf
(
&
override_path
,
"%s/%s/%s/%s_%s_ovr"
,
p
->
entry
[
id
].
mount
,
config_struct
.
data_directory
,
p
->
entry
[
id
].
appdata
,
pkg_id
,
fname
);
df
=
desktop_parse_file
(
override_path
);
asprintf
(
&
override_path
,
"%s/%s/%s/%s_%s_ovr"
,
p
->
entry
[
id
].
mount
,
dbp_
config_struct
.
data_directory
,
p
->
entry
[
id
].
appdata
,
pkg_id
,
fname
);
df
=
d
bp_d
esktop_parse_file
(
override_path
);
free
(
override_path
);
if
(
df
)
df
=
desktop_parse_append
(
data
,
df
);
df
=
d
bp_d
esktop_parse_append
(
data
,
df
);
else
df
=
desktop_parse
(
data
);
df
=
d
bp_d
esktop_parse
(
data
);
if
((
sec
=
desktop_lookup_section
(
df
,
"Desktop Entry"
))
<
0
)
if
((
sec
=
d
bp_d
esktop_lookup_section
(
df
,
"Desktop Entry"
))
<
0
)
goto
write
;
if
((
ent
=
desktop_lookup_entry
(
df
,
"Icon"
,
""
,
sec
))
<
0
)
if
((
ent
=
d
bp_d
esktop_lookup_entry
(
df
,
"Icon"
,
""
,
sec
))
<
0
)
goto
write
;
snprintf
(
writename
,
PATH_MAX
,
"%s/%s%s_%s"
,
config_struct
.
icon_directory
,
DBP_META_PREFIX
,
pkg_id
,
df
->
section
[
sec
].
entry
[
ent
].
value
);
snprintf
(
writename
,
PATH_MAX
,
"%s/%s%s_%s"
,
dbp_
config_struct
.
icon_directory
,
DBP_META_PREFIX
,
pkg_id
,
df
->
section
[
sec
].
entry
[
ent
].
value
);
free
(
df
->
section
[
sec
].
entry
[
ent
].
value
);
df
->
section
[
sec
].
entry
[
ent
].
value
=
strdup
(
writename
);
write:
snprintf
(
writename
,
PATH_MAX
,
"%s/%s%s_%s"
,
config_struct
.
desktop_directory
,
DBP_META_PREFIX
,
pkg_id
,
fname
);
snprintf
(
writename
,
PATH_MAX
,
"%s/%s%s_%s"
,
dbp_
config_struct
.
desktop_directory
,
DBP_META_PREFIX
,
pkg_id
,
fname
);
if
(
!
(
fp
=
fopen
(
writename
,
"w"
)))
goto
desktop_free
;
desktop_write
(
df
,
writename
);
d
bp_d
esktop_write
(
df
,
writename
);
chmod
(
writename
,
0755
);
package_meta_exec_export
(
desktop_lookup
(
df
,
"Exec"
,
""
,
"Package Entry"
),
1
,
p
,
id
);
package_meta_exec_export
(
desktop_lookup
(
df
,
"NoEnvExec"
,
""
,
"Package Entry"
),
0
,
p
,
id
);
package_meta_exec_export
(
d
bp_d
esktop_lookup
(
df
,
"Exec"
,
""
,
"Package Entry"
),
1
,
p
,
id
);
package_meta_exec_export
(
d
bp_d
esktop_lookup
(
df
,
"NoEnvExec"
,
""
,
"Package Entry"
),
0
,
p
,
id
);
if
(
announce
)
comm_dbus_announce_new_meta
(
writename
);
desktop_free:
desktop_free
(
df
);
d
bp_d
esktop_free
(
df
);
return
;
}
...
...
@@ -181,8 +181,8 @@ static void package_emit_exec(const char *path, const char *bin, int env, const
int
sz
,
tok_var
;
char
*
script
,
*
saveptr
=
NULL
,
*
tok
;
if
(
!
(
fp
=
fopen
(
config_struct
.
exec_template
,
"r"
)))
{
fprintf
(
dbp_error_log
,
"Unable to open exec template %s
\n
"
,
config_struct
.
exec_template
);
if
(
!
(
fp
=
fopen
(
dbp_
config_struct
.
exec_template
,
"r"
)))
{
fprintf
(
dbp_error_log
,
"Unable to open exec template %s
\n
"
,
dbp_
config_struct
.
exec_template
);
return
;
}
...
...
@@ -245,7 +245,7 @@ static void package_meta_exec_export(const char *exec, int env, struct package_s
return
;
exec_tok
=
strdup
(
exec
);
for
(
tok
=
strtok_r
(
exec_tok
,
";"
,
&
saveptr
);
tok
;
tok
=
strtok_r
(
NULL
,
";"
,
&
saveptr
))
{
snprintf
(
path
,
PATH_MAX
,
"%s/%s"
,
config_struct
.
exec_directory
,
find_filename
(
tok
));
snprintf
(
path
,
PATH_MAX
,
"%s/%s"
,
dbp_
config_struct
.
exec_directory
,
find_filename
(
tok
));
if
(
!
access
(
path
,
F_OK
))
{
fprintf
(
dbp_error_log
,
"Executable collision! %s already exists
\n
"
,
path
);
continue
;
...
...
@@ -293,7 +293,7 @@ static void package_meta_extract(const char *path, struct package_s *p, int id,
data
[
size
]
=
0
;
if
(
strstr
(
pathname
,
"icons/"
)
==
pathname
)
{
snprintf
(
writename
,
PATH_MAX
,
"%s/%s%s_%s"
,
config_struct
.
icon_directory
,
DBP_META_PREFIX
,
pkg_id
,
dbp_
config_struct
.
icon_directory
,
DBP_META_PREFIX
,
pkg_id
,
find_filename
(
pathname
));
if
(
!
(
fp
=
fopen
(
writename
,
"w"
)))
{
...
...
@@ -318,25 +318,25 @@ static void package_meta_extract(const char *path, struct package_s *p, int id,
static
int
package_register
(
struct
package_s
*
p
,
const
char
*
path
,
const
char
*
device
,
const
char
*
mount
,
int
*
coll_id
)
{
struct
meta_package_s
mp
;
struct
DBPMetaPackage
mp
;
char
*
pkg_id
=
"none"
,
*
appdata
,
*
sys
,
*
pkg
;
int
id
,
errid
;
*
coll_id
=
-
1
;
if
((
errid
=
meta_package_open
(
path
,
&
mp
))
<
0
)
if
((
errid
=
dbp_
meta_package_open
(
path
,
&
mp
))
<
0
)
goto
error
;
if
(
!
(
pkg_id
=
desktop_lookup
(
mp
.
df
,
"Id"
,
""
,
mp
.
section
)))
{
if
(
!
(
pkg_id
=
d
bp_d
esktop_lookup
(
mp
.
df
,
"Id"
,
""
,
mp
.
section
)))
{
errid
=
DBP_ERROR_BAD_PKG_ID
;
goto
error
;
}
if
(
!
(
appdata
=
desktop_lookup
(
mp
.
df
,
"Appdata"
,
""
,
mp
.
section
)))
if
(
!
(
appdata
=
d
bp_d
esktop_lookup
(
mp
.
df
,
"Appdata"
,
""
,
mp
.
section
)))
appdata
=
pkg_id
;
else
if
(
!
package_id_validate
(
appdata
))
appdata
=
pkg_id
;
if
(
!
(
sys
=
desktop_lookup
(
mp
.
df
,
"SysDependency"
,
""
,
mp
.
section
)))
if
(
!
(
sys
=
d
bp_d
esktop_lookup
(
mp
.
df
,
"SysDependency"
,
""
,
mp
.
section
)))
sys
=
""
;
if
(
!
(
pkg
=
desktop_lookup
(
mp
.
df
,
"PkgDependency"
,
""
,
mp
.
section
)))
if
(
!
(
pkg
=
d
bp_d
esktop_lookup
(
mp
.
df
,
"PkgDependency"
,
""
,
mp
.
section
)))
pkg
=
""
;
if
((
id
=
package_add
(
p
,
strdup
(
path
),
strdup
(
pkg_id
),
strdup
(
device
),
strdup
(
mount
),
strdup
(
appdata
),
strdup
(
sys
),
strdup
(
pkg
)))
<
0
)
{
...
...
@@ -349,14 +349,14 @@ static int package_register(struct package_s *p, const char *path, const char *d
package_meta_extract
(
path
,
p
,
id
,
!
strcmp
(
p
->
entry
[
id
].
desktop
,
"desk"
));
fprintf
(
dbp_error_log
,
"Registered package %s at '%s'
\n
"
,
pkg_id
,
path
);
mp
.
df
=
desktop_free
(
mp
.
df
);
mp
.
df
=
d
bp_d
esktop_free
(
mp
.
df
);
return
id
;
error:
fprintf
(
dbp_error_log
,
"An error occured while registering a package %s at '%s'
\n
"
,
pkg_id
,
path
);
if
(
mp
.
df
)
mp
.
df
=
desktop_free
(
mp
.
df
);
mp
.
df
=
d
bp_d
esktop_free
(
mp
.
df
);
return
errid
;
}
...
...
@@ -416,9 +416,9 @@ void package_crawl_mount(struct package_s *p, const char *device, const char *pa
pthread_mutex_lock
(
&
p
->
mutex
);
for
(
i
=
0
;
i
<
config_struct
.
search_dirs
;
i
++
)
{
new_path
=
realloc
(
new_path
,
strlen
(
path
)
+
2
+
strlen
(
config_struct
.
search_dir
[
i
]));
snprintf
(
new_path
,
PATH_MAX
,
"%s/%s"
,
path
,
config_struct
.
search_dir
[
i
]);
for
(
i
=
0
;
i
<
dbp_
config_struct
.
search_dirs
;
i
++
)
{
new_path
=
realloc
(
new_path
,
strlen
(
path
)
+
2
+
strlen
(
dbp_
config_struct
.
search_dir
[
i
]));
snprintf
(
new_path
,
PATH_MAX
,
"%s/%s"
,
path
,
dbp_
config_struct
.
search_dir
[
i
]);
package_crawl
(
p
,
device
,
new_path
,
path
);
}
...
...
@@ -451,8 +451,8 @@ static void package_meta_remove(const char *pkg_id, int announce) {
char
prefix
[
PATH_MAX
];
snprintf
(
prefix
,
PATH_MAX
,
"%s%s_"
,
DBP_META_PREFIX
,
pkg_id
);
package_kill_prefix
(
config_struct
.
icon_directory
,
prefix
,
0
);
package_kill_prefix
(
config_struct
.
desktop_directory
,
prefix
,
announce
);
package_kill_prefix
(
dbp_
config_struct
.
icon_directory
,
prefix
,
0
);
package_kill_prefix
(
dbp_
config_struct
.
desktop_directory
,
prefix
,
announce
);
return
;
}
...
...
@@ -462,12 +462,12 @@ static void package_kill(struct package_s *p, int entry) {
int
i
;
char
ulinkpath
[
PATH_MAX
];
if
(
config_struct
.
verbose_output
)
if
(
dbp_
config_struct
.
verbose_output
)
fprintf
(
dbp_error_log
,
"Package at '%s' released
\n
"
,
p
->
entry
[
entry
].
path
);
package_meta_remove
(
p
->
entry
[
entry
].
id
,
!
strcmp
(
p
->
entry
[
entry
].
desktop
,
"desk"
));
for
(
i
=
0
;
i
<
p
->
entry
[
entry
].
execs
;
i
++
)
{
snprintf
(
ulinkpath
,
PATH_MAX
,
"%s/%s"
,
config_struct
.
exec_directory
,
p
->
entry
[
entry
].
exec
[
i
]);
snprintf
(
ulinkpath
,
PATH_MAX
,
"%s/%s"
,
dbp_
config_struct
.
exec_directory
,
p
->
entry
[
entry
].
exec
[
i
]);
unlink
(
ulinkpath
);
free
(
p
->
entry
[
entry
].
exec
[
i
]);
}
...
...
@@ -523,7 +523,7 @@ void package_release_mount(struct package_s *p, const char *device) {
last
=
p
->
entry
[
i
].
id
;
if
(
strcmp
(
p
->
entry
[
i
].
device
,
device
))
{
if
(
config_struct
.
verbose_output
)
if
(
dbp_
config_struct
.
verbose_output
)
fprintf
(
dbp_error_log
,
"Package '%s' does not reside on '%s', it's on '%s', skipping
\n
"
,
p
->
entry
[
i
].
path
,
device
,
p
->
entry
[
i
].
device
);
continue
;
}
...
...
@@ -563,7 +563,7 @@ int package_run(struct package_s *p, const char *id, const char *user) {
return
DBP_ERROR_BAD_PKG_ID
;
}
if
((
loop
=
loop_mount
(
p
->
entry
[
pkg_n
].
path
,
id
,
user
,
p
->
entry
[
pkg_n
].
mount
,
p
->
entry
[
pkg_n
].
appdata
))
<
0
)
{
if
((
loop
=
dbp_
loop_mount
(
p
->
entry
[
pkg_n
].
path
,
id
,
user
,
p
->
entry
[
pkg_n
].
mount
,
p
->
entry
[
pkg_n
].
appdata
))
<
0
)
{
pthread_mutex_unlock
(
&
p
->
mutex
);
return
loop
;
}
...
...
@@ -638,11 +638,11 @@ static int package_purgatory_revive(struct package_s *p, const char *pkgid) {
}
static
int
package_purgatory_reap
(
struct
package_s
*
p
,
int
id
)
{
p
->
purgatory
[
id
].
reusable
=
loop_umount
(
p
->
purgatory
[
id
].
package_id
,
p
->
purgatory
[
id
].
loop_number
,
NULL
,
p
->
purgatory
[
id
].
reusable
);
p
->
purgatory
[
id
].
reusable
=
dbp_
loop_umount
(
p
->
purgatory
[
id
].
package_id
,
p
->
purgatory
[
id
].
loop_number
,
NULL
,
p
->
purgatory
[
id
].
reusable
);
if
(
!
p
->
purgatory
[
id
].
reusable
)
{
package_purgatory_remove
(
p
,
id
);
return
1
;
}
else
if
(
config_struct
.
verbose_output
)
}
else
if
(
dbp_
config_struct
.
verbose_output
)
fprintf
(
dbp_error_log
,
"Unable to reap package %s in purgatory, reason %i
\n
"
,
p
->
purgatory
[
id
].
package_id
,
p
->
purgatory
[
id
].
reusable
);
return
0
;
}
...
...
dbpd/state.c
View file @
733143ec
...
...
@@ -33,36 +33,36 @@ signed long long state_btime() {
<