aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2003-10-01 21:44:22 +0000
committerJason Woodward2003-10-01 21:44:22 +0000
commit741f33225abf6efb4f7d6e6a5ee5674c8dade016 (patch)
tree8bc44a63073ea3c3e9b252ac01bdde957cfacaf4
parent1ef097f85ae490b1b7137becdf3aeeec074568e4 (diff)
downloadslapt-get-741f33225abf6efb4f7d6e6a5ee5674c8dade016.tar.gz
Hardcoded arch and release in makefile
replaced strcmp with cmp_pkg_versions(char *,char *), now greater pkg versions are always correctly returned doc updates
-rw-r--r--ChangeLog3
-rw-r--r--FAQ24
-rw-r--r--Makefile4
-rw-r--r--src/action.c12
-rw-r--r--src/package.c77
-rw-r--r--src/package.h5
6 files changed, 113 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 2ecb822..d94606a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
0.9.5 Oct 01, 2003
* fixed pkg name so that slack-desc shows up... wasn't following
new package naming convention. Thanks Luke Yelavich <luke@audioslack.com>
+ * bug fix... replaced strcmp with cmp_pkg_versions(char *,char *);
+ now greater pkg versions are always correctly returned
+ Thanks to xspace <xspace@digitalhigh.de>
0.9.4 Sep 29, 2003
* downloads CHECKSUMS.md5 from mirror
diff --git a/FAQ b/FAQ
index d396d03..fffa8a2 100644
--- a/FAQ
+++ b/FAQ
@@ -13,6 +13,7 @@ Frequenty Asked Questions:
10. What about package dependencies?
11. What about multiple package sources, ala linuxpackages.net?
12. I don't like the download spinner, how can I get more statistics?
+13. How can I install every available package?
@@ -168,7 +169,7 @@ Frequenty Asked Questions:
a PACKAGES.TXT in the same manner as the slackware official packages are
listed. This would make integrating their package listing trivial.
- I am awaiting a response.
+ We are now working together on a possible solution.
12. I don't like the download spinner, how can I get more statistics?
@@ -176,3 +177,24 @@ Frequenty Asked Questions:
USE_CURL_PROGRESS macro to 1 in include/curl.h. This turns on curl's
internal progress meter. This requires a recompile.
+13. How can I install every available package?
+
+ Even though it's not build in, it's simple since slapt-get is easy to script
+ with. Here is a simple shell script to install every package that is
+ available but not currently installed:
+
+ #!/bin/sh
+ # Dan Barber <danb at mojolin dot com>
+ slapt-get --update
+ slapt-get --installed > /tmp/slapt_get_installed
+ for file in `slapt-get --list | cut -f1 -d" " | sort`
+ do
+ echo -n "$file "
+ if [ -z `grep "\W+$file\W+" /tmp/slapt_get_installed` ]; then
+ echo "not installed"
+ slapt-get --install $file
+ fi
+ done
+
+
+
diff --git a/Makefile b/Makefile
index 4c88526..56786a2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
PROGRAM_NAME=slapt-get
VERSION=0.9.5
+ARCH=i386
+RELEASE=1
CC=gcc
CURLFLAGS=`curl-config --libs`
OBJS=src/configuration.o src/package.o src/curl.o src/action.o src/main.o
@@ -45,5 +47,5 @@ pkg: $(PROGRAM_NAME)
-@cp COPYING Changelog INSTALL README FAQ TODO ./pkg/usr/doc/$(PROGRAM_NAME)-$(VERSION)/
-@cp slack-desc pkg/install/
-@cp $(PROGRAM_NAME).8 pkg/usr/man/man8/
- @( cd pkg; makepkg -c y $(PROGRAM_NAME)-$(VERSION)-i386-1.tgz )
+ @( cd pkg; makepkg -c y $(PROGRAM_NAME)-$(VERSION)-$(ARCH)-$(RELEASE).tgz )
diff --git a/src/action.c b/src/action.c
index c2a2bc7..d04ce28 100644
--- a/src/action.c
+++ b/src/action.c
@@ -214,10 +214,10 @@ void pkg_action_upgrade(const rc_config *global_config,pkg_info_t *installed_pkg
/* if we found an update, make sure it's version is greater */
if(
(update_pkg = get_newest_pkg(update_pkgs->pkgs,installed_pkg->name,update_pkgs->pkg_count)) != NULL
- && strcmp(available_pkg->version,update_pkg->version) < 0
+ && cmp_pkg_versions(available_pkg->version,update_pkg->version) < 0
){
- cmp_result = strcmp(installed_pkg->version,update_pkg->version);
+ cmp_result = cmp_pkg_versions(installed_pkg->version,update_pkg->version);
if( cmp_result < 0 ){ /* update_pkg is newer than installed_pkg */
if( (upgrade_pkg(global_config,installed_pkg,update_pkg)) == -1 ){
@@ -231,7 +231,7 @@ void pkg_action_upgrade(const rc_config *global_config,pkg_info_t *installed_pkg
}
}
}else{
- if( strcmp(installed_pkg->version,available_pkg->version) < 0 ){
+ if( cmp_pkg_versions(installed_pkg->version,available_pkg->version) < 0 ){
if( (upgrade_pkg(global_config,installed_pkg,available_pkg)) == -1 ){
fprintf(stderr,"Failed to update %s.\n",installed_pkg->name);
}
@@ -272,7 +272,7 @@ void pkg_action_upgrade_all(const rc_config *global_config){
if( update_pkg != NULL ){
/* if the update has a newer version */
- if( (strcmp(installed_pkgs->pkgs[iterator]->version,update_pkg->version)) < 0 ){
+ if( (cmp_pkg_versions(installed_pkgs->pkgs[iterator]->version,update_pkg->version)) < 0 ){
/* attempt to upgrade */
if( (upgrade_pkg(global_config,installed_pkgs->pkgs[iterator],update_pkg)) == -1 ){
@@ -295,7 +295,7 @@ void pkg_action_upgrade_all(const rc_config *global_config){
);
if( current_pkg != NULL ){
/* the current version of the pkg is greater than the installed version */
- if( (strcmp(installed_pkgs->pkgs[iterator]->version,current_pkg->version)) < 0 ){
+ if( (cmp_pkg_versions(installed_pkgs->pkgs[iterator]->version,current_pkg->version)) < 0 ){
/* attempt to upgrade */
if( (upgrade_pkg(global_config,installed_pkgs->pkgs[iterator],current_pkg)) == -1 ){
fprintf(
@@ -304,7 +304,7 @@ void pkg_action_upgrade_all(const rc_config *global_config){
installed_pkgs->pkgs[iterator]->name
);
}/* end upgrade attempt */
- }/* end if strcmp */
+ }/* end if cmp_pkg_versions */
}/* end if current_pkg */
}
diff --git a/src/package.c b/src/package.c
index f440de4..993492c 100644
--- a/src/package.c
+++ b/src/package.c
@@ -277,7 +277,7 @@ struct pkg_list *get_installed_pkgs(void){
/* add if no existing_pkg or tmp_pkg has greater version */
if( ((existing_pkg = get_newest_pkg(list->pkgs,tmp_pkg->name,list->pkg_count)) == NULL)
- || (strcmp(existing_pkg->version,tmp_pkg->version) < 0 )){
+ || (cmp_pkg_versions(existing_pkg->version,tmp_pkg->version) < 0 )){
list->pkgs[list->pkg_count] = calloc(1 , sizeof *list->pkgs[list->pkg_count] );
if( list->pkgs[list->pkg_count] == NULL ){
@@ -319,7 +319,7 @@ pkg_info_t *get_newest_pkg(pkg_info_t **pkgs,const char *pkg_name,int pkg_count)
/* if pkg has same name as our requested pkg */
if( (strcmp(pkgs[iterator]->name,pkg_name)) == 0 ){
- if( (pkg == NULL) || strcmp(pkg->version,pkgs[iterator]->version) < 0 ){
+ if( (pkg == NULL) || cmp_pkg_versions(pkg->version,pkgs[iterator]->version) < 0 ){
pkg = pkgs[iterator];
}
}
@@ -450,7 +450,7 @@ int install_pkg(const rc_config *global_config,pkg_info_t *pkg){
command = strcat(command,pkg_file_name);
if( global_config->download_only == 0 ){
- printf("Preparing to install %s - %s\n",pkg->name,pkg->version);
+ printf("Preparing to install %s-%s\n",pkg->name,pkg->version);
if( (cmd_return = system(command)) == -1 ){
printf("Failed to execute command: [%s]\n",command);
exit(1);
@@ -622,7 +622,7 @@ void get_md5sum(const rc_config *global_config,pkg_info_t *pkg,char *md5_sum){
);
sum[pmatch[1].rm_eo - pmatch[1].rm_so] = '\0';
- if( (strcmp(pkg->name,name) == 0) && (strcmp(pkg->version,version) == 0) ){
+ if( (strcmp(pkg->name,name) == 0) && (cmp_pkg_versions(pkg->version,version) == 0) ){
memcpy(md5_sum,sum,pmatch[1].rm_eo - pmatch[1].rm_so + 1);
break;
}
@@ -636,3 +636,72 @@ void get_md5sum(const rc_config *global_config,pkg_info_t *pkg,char *md5_sum){
return;
}
+int cmp_pkg_versions(char *a, char *b){
+ int ver_breakdown_1[] = { 0, 0, 0, 0 };
+ int ver_breakdown_2[] = { 0, 0, 0, 0 };
+ int count1,count2,position = 0,greater = 1,lesser = -1;
+
+ count1 = break_down_pkg_version(ver_breakdown_1,a);
+ count2 = break_down_pkg_version(ver_breakdown_2,b);
+
+ while( position < count1 && position < count2 ){
+ if( ver_breakdown_1[position] != ver_breakdown_2[position] ){
+
+ if( ver_breakdown_1[position] < ver_breakdown_2[position] )
+ return lesser;
+
+ if( ver_breakdown_1[position] > ver_breakdown_2[position] )
+ return greater;
+
+ }
+ ++position;
+ }
+
+ /* if the integer version of each package is equal,
+ we fall back on strcmp */
+ return strcmp(a,b);
+}
+
+int break_down_pkg_version(int *v,char *version){
+ int pos = 0,count = 0,sv_size;
+ char *pointer,*tmp,*short_version;
+
+
+ /* generate a short version, leave out arch and release */
+ if( (pointer = strchr(version,'-')) == NULL ){
+ return 0;
+ }else{
+ sv_size = ( strlen(version) - strlen(pointer) + 1);
+ short_version = malloc( sizeof *short_version * sv_size );
+ memcpy(short_version,version,sv_size);
+ short_version[sv_size - 1] = '\0';
+ pointer = NULL;
+ }
+
+ while(pos < (sv_size - 1) ){
+ if( (pointer = strchr(short_version + pos,'.')) != NULL ){
+ int b_count = ( strlen(short_version + pos) - strlen(pointer) + 1 );
+ tmp = malloc( sizeof *tmp * b_count );
+ memcpy(tmp,short_version + pos,b_count);
+ tmp[b_count - 1] = '\0';
+ v[count] = atoi(tmp);
+ count++;
+ free(tmp);
+ pointer = NULL;
+ pos += b_count;
+ }else{
+ int b_count = ( strlen(short_version + pos) + 1 );
+ tmp = malloc( sizeof *tmp * b_count );
+ memcpy(tmp,short_version + pos,b_count);
+ tmp[b_count - 1] = '\0';
+ v[count] = atoi(tmp);
+ count++;
+ free(tmp);
+ pos += b_count;
+ }
+ }
+
+ free(short_version);
+ return count;
+}
+
diff --git a/src/package.h b/src/package.h
index 02e2cb5..61329fa 100644
--- a/src/package.h
+++ b/src/package.h
@@ -70,3 +70,8 @@ void free_pkg_list(struct pkg_list *);
int is_excluded(const rc_config *,const char *);
/* lookup md5sum of file */
void get_md5sum(const rc_config *,pkg_info_t *,char *);
+/* compare package versions */
+int cmp_pkg_versions(char *, char *);
+/* analyze the pkg version hunk by hunk */
+int break_down_pkg_version(int *,char *);
+