Skip to content

Commit

Permalink
changelog support
Browse files Browse the repository at this point in the history
Date: 2005-08-07
Initial Package Version: 2.9.6
Upstream Status: Not yet submitted
Origin: Miklos Vajna <vmiklos@frugalware.org>
Description: Allow users to view the changelog of a package.
 doc/pacman.8.in |    3 +++
 scripts/makepkg |   18 ++++++++++++++----
 src/pacman.c    |   37 +++++++++++++++++++++++++++++++++++--
 3 files changed, 52 insertions(+), 6 deletions(-)
  • Loading branch information
VMiklos committed Dec 11, 2005
1 parent 64250a8 commit c6e50b0
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 11 deletions.
3 changes: 3 additions & 0 deletions doc/pacman.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ build date, size). This can be run against the local package
database or can be used on individual .tar.gz packages. See
\fBQUERY OPTIONS\fP below.
.TP
.B "\-c, \-\-changelog"
View the changelog of a package.
.TP
.B "\-R, \-\-remove"
Remove a package from the system. Files belonging to the
specified package will be deleted, and the database will
Expand Down
17 changes: 14 additions & 3 deletions lib/libalpm/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,20 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
continue;
}

if(!strcmp(pathname, "._install") || !strcmp(pathname, ".INSTALL")) {
/* the install script goes inside the db */
snprintf(expath, PATH_MAX, "%s/%s-%s/install", db->path, info->name, info->version);
//if(!strcmp(pathname, "._install") || !strcmp(pathname, ".INSTALL")) {
// /* the install script goes inside the db */
// snprintf(expath, PATH_MAX, "%s/%s-%s/install", db->path, info->name, info->version);
if(!strcmp(pathname, "._install") || !strcmp(pathname, ".INSTALL") ||
!strcmp(pathname, ".CHANGELOG")) {
if(!strcmp(pathname, ".CHANGELOG")) {
/* the changelog goes inside the db */
snprintf(expath, PATH_MAX, "%s/%s-%s/changelog", db->path,
info->name, info->version);
} else {
/* the install script goes inside the db */
snprintf(expath, PATH_MAX, "%s/%s-%s/install", db->path,
info->name, info->version);
}
} else {
/* build the new pathname relative to handle->root */
snprintf(expath, PATH_MAX, "%s%s", handle->root, pathname);
Expand Down
3 changes: 3 additions & 0 deletions lib/libalpm/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ int db_remove(pmdb_t *db, pmpkg_t *info)
/* INSTALL */
snprintf(file, PATH_MAX, "%s/install", topdir);
unlink(file);
/* CHANGELOG */
snprintf(file, PATH_MAX, "%s/changelog", topdir);
unlink(file);

/* Package directory */
if(rmdir(topdir) == -1) {
Expand Down
22 changes: 18 additions & 4 deletions scripts/makepkg
Original file line number Diff line number Diff line change
Expand Up @@ -847,15 +847,29 @@ msg "Generating .FILELIST file..."
cd $startdir/pkg
tar cvf /dev/null * | sort >.FILELIST

# changelog
if darcs --commands 2>&1|grep -q add || [ -e $startdir/Changelog ]; then
msg "Generating .CHANGELOG file..."
cd $startdir
if darcs --commands 2>&1|grep -q add; then
cmd="darcs changes $BUILDSCRIPT"
else
cmd="cat Changelog"
fi
$cmd |sed sed "s|\(.*\)source/\(.*\)/FrugalBuild\(.*\)|\1\2\3|;/Can't find changes prior to:/,\$d" >pkg/.CHANGELOG
fi

# tar it up
msg "Compressing package..."
cd $startdir/pkg
if [ -f $startdir/pkg/.INSTALL ]; then
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-$CARCH.fpm .PKGINFO .FILELIST .INSTALL *"
else
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-$CARCH.fpm .PKGINFO .FILELIST *"
extra=".INSTALL"
fi
if [ -f $startdir/pkg/.CHANGELOG ]; then
extra="$extra .CHANGELOG"
fi
$cmd | sort >../filelist
tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel-$CARCH.fpm .PKGINFO .FILELIST \
$extra * | sort >../filelist

cd $startdir
if [ "$SEARCHDEPS" == "1" ]; then
Expand Down
1 change: 1 addition & 0 deletions src/pacman/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef struct __config_t {
unsigned short op_q_orphans;
unsigned short op_q_owns;
unsigned short op_q_search;
unsigned short op_q_changelog;
unsigned short op_s_clean;
unsigned short op_s_downloadonly;
list_t *op_s_ignore;
Expand Down
26 changes: 25 additions & 1 deletion src/pacman/package.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ void dump_pkg_full(PM_PKG *pkg, int level)
printf("\n");
}


/* Display the content of a sync package
*/
void dump_pkg_sync(PM_PKG *pkg, char *treename)
Expand Down Expand Up @@ -160,6 +159,31 @@ void dump_pkg_files(PM_PKG *pkg)
fflush(stdout);
}

/* Display the changelog of an installed package
*/
void dump_pkg_changelog(char *clfile)
{
FILE* fp = NULL;
char line[PATH_MAX+1];

if((fp = fopen(clfile, "r")) == NULL)
{
perror(clfile);
return(1);
}
else
{
while(!feof(fp))
{
fgets(line, PATH_MAX, fp);
printf("%s", line);
line[0] = '\0';
}
fclose(fp);
return(0);
}
}

int split_pkgname(char *target, char *name, char *version)
{
char tmp[512];
Expand Down
1 change: 1 addition & 0 deletions src/pacman/package.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void dump_pkg_full(PM_PKG *pkg, int level);
void dump_pkg_sync(PM_PKG *pkg, char *treename);

void dump_pkg_files(PM_PKG *pkg);
void dump_pkg_changelog(char *clfile);

int split_pkgname(char *target, char *name, char *version);

Expand Down
4 changes: 3 additions & 1 deletion src/pacman/pacman.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ int parseargs(int argc, char *argv[])
{"vertest", no_argument, 0, 'Y'}, /* does the same as the 'vercmp' binary */
{"dbpath", required_argument, 0, 'b'},
{"cascade", no_argument, 0, 'c'},
{"changelog", no_argument, 0, 'c'},
{"clean", no_argument, 0, 'c'},
{"nodeps", no_argument, 0, 'd'},
{"orphans", no_argument, 0, 'e'},
Expand Down Expand Up @@ -434,7 +435,7 @@ int parseargs(int argc, char *argv[])
}
config->dbpath = strdup(optarg);
break;
case 'c': config->op_s_clean++; config->flags |= PM_TRANS_FLAG_CASCADE; break;
case 'c': config->op_s_clean++; config->flags |= PM_TRANS_FLAG_CASCADE; config->op_q_changelog = 1; break;
case 'd': config->flags |= PM_TRANS_FLAG_NODEPS; break;
case 'e': config->op_q_orphans = 1; break;
case 'f': config->flags |= PM_TRANS_FLAG_FORCE; break;
Expand Down Expand Up @@ -531,6 +532,7 @@ void usage(int op, char *myname)
} else if(op == PM_OP_QUERY) {
printf("usage: %s {-Q --query} [options] [package]\n", myname);
printf("options:\n");
printf(" -c, --changelog view the changelog of a package\n");
printf(" -e, --orphans list all packages that were installed as a dependency\n");
printf(" and are not required by any other packages\n");
printf(" -g, --groups view all members of a package group\n");
Expand Down
12 changes: 10 additions & 2 deletions src/pacman/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int pacman_query(list_t *targets)
}
}
} else {
char *pkgname, *pkgver;
char *pkgname, *pkgver, changelog[PATH_MAX];

info = alpm_db_readpkg(db_local, package);
if(info == NULL) {
Expand All @@ -212,7 +212,15 @@ int pacman_query(list_t *targets)
}

/* find a target */
if(config->op_q_info || config->op_q_list) {
if(config->op_q_changelog || config->op_q_info || config->op_q_list) {
if(config->op_q_changelog) {
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
config->root, config->dbpath,
(char*)alpm_db_getinfo(db_local, PM_DB_TREENAME),
(char*)alpm_pkg_getinfo(info, PM_PKG_NAME),
(char*)alpm_pkg_getinfo(info, PM_PKG_VERSION));
dump_pkg_changelog(changelog);
}
if(config->op_q_info) {
dump_pkg_full(info, config->op_q_info);
}
Expand Down

0 comments on commit c6e50b0

Please sign in to comment.